Rename plural to singular; cleaner and more consistent with 'ip' utility
This commit is contained in:
@@ -8,20 +8,20 @@ require 'netlink/route'
|
||||
# The data is memoized - that is, it's downloaded from the kernel once
|
||||
# and then manipulated internally.
|
||||
|
||||
rt = Netlink::Route::Socket.new
|
||||
ip = Netlink::Route::Socket.new
|
||||
|
||||
puts "\nInterface eth0:"
|
||||
pp rt.links["eth0"]
|
||||
pp ip.link["eth0"]
|
||||
|
||||
puts "\nAddresses on interface eth0:"
|
||||
pp rt.addrs.list(:index=>"eth0").to_a
|
||||
pp ip.addr.list(:index=>"eth0").to_a
|
||||
|
||||
puts "\nAll routes in main routing table:"
|
||||
pp rt.routes.list(:table=>Netlink::RT_TABLE_MAIN).to_a
|
||||
pp ip.route.list(:table=>Netlink::RT_TABLE_MAIN).to_a
|
||||
|
||||
puts "\nV4 default route is probably:"
|
||||
pp rt.routes.list(:family=>Socket::AF_INET, :table=>Netlink::RT_TABLE_MAIN).
|
||||
pp ip.route.list(:family=>Socket::AF_INET, :table=>Netlink::RT_TABLE_MAIN).
|
||||
min_by { |route| route.dst_len }
|
||||
|
||||
puts "\nTraffic to 192.168.1.1 goes out via:"
|
||||
puts rt.ifname(rt.routes.get(:dst=>"192.168.1.1").oif)
|
||||
puts ip.ifname(ip.route.get(:dst=>"192.168.1.1").oif)
|
||||
|
Reference in New Issue
Block a user