When I execute route -n, from where exactly (from which structs) is the information displayed retrieved?

I tried executing strace route -n but I didn't help me finding the right place it's stored.

  • 1
    Please go through this superuser.com/questions/322717/how-does-route-n-work-in-linux
    – Sreeraj
    Commented May 19, 2015 at 5:56
  • It's stored in memory. Are you looking for the memory address it's at?
    – Bandrami
    Commented May 19, 2015 at 6:15
  • @Bandrami I would like to see what struct is responsible for holding the information.
    – syntagma
    Commented May 19, 2015 at 6:15
  • For anyone looking for the file on disk, it's either built from whatever the DHCP server gives out, or from what can be found in /etc/sysconfig/network-scripts/ifcfg-${DEV} in simple cases and/or from what can be found in /etc/sysconfig/network-scripts/route-${DEV} in more convoluted cases (case of Red Hat / CentOS 7). The latter file contains the output of ip -r. See Add a Static Route on CentOS. Commented Nov 2, 2018 at 14:11

1 Answer 1


The route or the ip utility get their information from a pseudo filesystem called procfs. It is normally mounted under /proc. There is a file called /proc/net/route, where you can see the kernel's IP routing table. You can print the routing table with cat instead, but the route utility formats the output human readable, because the IP adresses are stored in hex.

That file is not just a normal file. It is always generated at exactly the moment when opening it with an attempt to read, as all files in the proc filesystem.

I you are interessted how that file is written, then you need to look at the kernel sources: That function outputs the routeing table. You see at line 2510, the header of the routing table is printed. The routing table appears to be mostly in the struct fib_info that is defined in the header file ip_fib.h, line 98.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .