Is there a way to access information available in

ip route show

command via some special file (or other method), the same way that output of

route -n

can be read from /proc/net/route? I know that I can just parse the output, but I am looking for something in more machine-readable format.


strace shows ip route show creating a NETLINK_ROUTE socket to get that: http://man7.org/linux/man-pages/man7/netlink.7.html


What specific information are you trying to get?

This is the perfect thing to use either cut, awk to pull the specific fields you want out of it.


ip route show |  awk '{print $1 " " $9 }' 

Returns network subnet and source IP.


Same information is on "/proc/net/route". You could check that file, instead of capture standar output information from "netstat -n" command.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.