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.
ifconfig
only displays information about local interfaces. The IP address of your gateway is part of the gateway's local interface information.traceroute 8.8.8.8
- first one on the list will be your router's ip address. If this does not work it will also tell you that you do not have a valid connection established with router. (I'm ommiting situation when your router is blocking ICMP traffic on LAN which is rare configuration).ifconfig
.