1

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.

1

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

| improve this answer | |
0

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.

Example:

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

Returns network subnet and source IP.

| improve this answer | |
0

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

| improve this answer | |

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.