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


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


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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