8

I am looking for the address that I type into my browser to get to the router configuration file. It ended up being 192.168.1.1, as usual. But when I enter ifconfig into the command line, this IP address is not listed anywhere.

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

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

9
  • 2
    ifconfig only displays information about local interfaces. The IP address of your gateway is part of the gateway's local interface information.
    – Larssend
    Jun 30, 2015 at 11:26
  • 1
    i think the easiest way to find the router IP is to use 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).
    – mnmnc
    Jun 30, 2015 at 11:34
  • 1
    @geewee bertieb commented and it should be put here too. (to the point that the public IP wont' be shown there). "OP's question asks about configuration page and mentions a private subnet IP, so the assumption is that he is looking for the LAN interface IP. The router's IPs - WAN or LAN - are not shown by a client ifconfig, hence the enquiry" - bertieb
    – barlop
    Jun 30, 2015 at 14:31
  • @barlop: doesn't change the fact that the router's interface isn't local to the PC/host, hence beyond the scope of ifconfig.
    – Larssend
    Jun 30, 2015 at 17:09
  • @geewee well, one of the router's interfaces is local, one isn't. He's referring to the private/local one though
    – barlop
    Jun 30, 2015 at 17:36

3 Answers 3

6

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.

2
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).

2

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.

You must log in to answer this question.

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