Why is router IP not listed in ifconfig?

If the router IP address were something else instead of 192.168.1.1, how would I find out what it is?

Assuming some flavour of Linux:

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.2.1     0.0.0.0         UG    0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0

(note on some flavours like Debian, route is not in $PATH for a non-root user, and you may have to use /sbin/route, or you can invoke netstat -rn for the same info)

In most common home cases, the router will be listed as the gateway for 0.0.0.0- in this made-up example 192.168.2.1.

If you want to find out more about the meaning of the output of route, see the question over on unix.se:

Understanding the output of route -n

Shouldn't ifconfig give me the IP address of the router?

ifconfig does not show gateway information - use 'route' to view or manipulate routing info.


netstat -nr

It will display directly the gateway address, which in the case of connections via router is the router IP address (example: 192.168.1.1).


Issue the command: ip route to find the address of the router(s) configured on your system.

To learn how to use it, simply do ip route help to see all the options.

The command ip can give you a lot of information about the IP configuration. Keep in mind that ifconfigis being deprecated on Linux.