Skip to main content

how to Find Your Gateway IP(linux/win/osx)

It's important for you to know the internal IP address of your default gateway, which is normally your router's LAN IP address.
If you have ever had to access your router to configure it, you should know the address. It's what you type in your browser address bar to reach the configuration interface (example: http://192.168.1.1/) and, if not, you can find it with the following steps:
  • Windows:

    • Click Start > All Programs > Accessories > Command Prompt.
    • When Command Prompt is open, type the following command: ipconfig | findstr /i "Gateway" (You can copy & paste it in the command prompt; just right-click anywhere in the command prompt window and select Paste.)
    • You should see something like this:
      C:\Documents and Settings\administrator>ipconfig | findstr /i "Gateway"
      Default Gateway . . . . . . . . . : 192.168.1.1
    • In this example, your default gateway (router) IP address is 192.168.1.1.


  • Linux:

    • You'll need to open a Terminal. Depending on your Linux distribution, it can be located in the menu items at the top, or at the bottom of your screen. In this example, we will use Fedora. Click Applications > System Tools > Terminal.
    • When terminal is open, type the following command: ip route | grep default
    • The output of this should look something like the following:
      joe$ ip route | grep default
      default via 192.168.1.1 dev eth0 proto static
    • In this example, again, 192.168.1.1 is your default gateway (router) IP address.



  • Mac OS X:

    • Open the Terminal application. Do do this, click Finder > Applications > Utilities > Terminal.app.
    • When Terminal.app is open, type the following command: netstat -nr | grep default
    • This will output the following:
      joe$ netstat -nr | grep default
      default 192.168.1.1 UGSc 50 46 en1
    • In this example, again, 192.168.1.1 is your default gateway (router) IP address.

    MORE WAY TO FIND GATEWAY IP IN LINUX

     H ow do I find out my gateway IP for a computer or a network device that allows or controls access to another computer or network under Linux / UNIX operating systems?

    A gateway is a network point that acts as an entrance to another network. On the Internet, a node or stopping point can be either a gateway node or a host (end-point) node. Both the computers of Internet users and the computers that serve pages to users are host nodes. The computers that control traffic within your company’s network or at your local Internet service provider (ISP) are gateway nodes. In the network for an enterprise, a computer server acting as a gateway node is often also acting as a proxy server and a firewall server. A gateway is often associated with both a router, which knows where to direct a given packet of data that arrives at the gateway, and a switch, which furnishes the actual path in and out of the gateway for a given packet.

    Find out Gateway / router IP address under Linux / UNIX using route command

    You need to use route command. This command can manipulates the kernel’s IP routing tables. It can be also use to print gateway / router IP address. Type the following command to see default gateway:
    $ route -n
    Output:
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 ra0
    0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 ra0
    192.168.1.1 is gateway IP address for our computer. The flag U indicates that route is up and G indicates that it is gateway. You can print gateway name, enter:
    $ route
    Output:
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    192.168.1.0     *               255.255.255.0   U     0      0        0 ra0
    default         wrt             0.0.0.0         UG    0      0        0 ra0
    Second column prints Gateway hostname / IP address. In our example wrt is gateway.

    netstat command example to find out gateway/router IP

    Open a terminal and type the following command:
    # netstat -r -n
    Sample outputs:
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
    0.0.0.0         192.168.1.254   0.0.0.0         UG        0 0          0 eth1
    192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth1

    route and netstat command demo