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.
Command to find out my Linux Gateway / Router IP address using ip command
The latest version of all Linux distribution based upon systemd. These Linux distros user can use the ip command to find out router IP address.
ip r
ip route
From the above output it is clear that 10.105.28.1 is the default gateway IP address.
How to find default Gateway IP in Linux
Some computers might have multiple default gateways. For example, OpenVPN client software might setup gateway for VPN traffic. Another case is static gateway IP address set up for different networks on your system:
ip r | grep default
In this above example 10.8.0.1 and 192.168.2.254 are the default gateway IP address. The gateway with lowest Metric is the first to be searched and used as the default gateway. In this case, 10.8.0.1 has the 50 as metric cost and 192.168.2.254 has the 100 as metric cost. Linux will always use the one with the lowest cost first. So all traffic will be routed using 10.8.0.1 gateway IP address.
Find out Gateway / router IP address under Linux / UNIX using route command
You need to use the router command command. This command can manipulate the kernel’s IP routing tables. It can also be used to print gateway/router IP address. Type the following command to see default gateway:
$ route -n
Sample outputs:
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
Sample 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 on Unix/FreeBSD/OpenBSD/macOS
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

The route command you mentioned helps solve my problem. Thanks!
nice one
Thank you very much for the information……….
an add , if allowed :
the command “netstat -r” could also reached the same result.
thanks nix
in our college we have linux proxy server for internet, troughe is a bsnl DSL router. router ip is chenged by our administrator so, i just want to know router ip from my pc which have windows xp for direct internet acsses, can u tell me what i have to do for this? plzzzzzzzzzzz help me.
there is a way, use a software called colasoft capsa on your computer. It will give all the IP address in use, now try each IP address you think may be a gateway and you will get to the internet. But I just want to know which BSNL router you are using?
There is one more issue that if you are going through linux proxy server, it is difficult to go through it, remember it is difficult not impossible. Just you have to go 1 step ahead your administrator
i’m working in corporate office … i want to know ip address of router even some of them told that default gateway is the ip address i telnet it but not connecting … how i have to found the ip address . send to my mail if u have the idea {snip_email_id_removed}
Let me clear you can not telnet each device on the network. So try ping command first
syntex is
ping xxx.xxx.xxx.xxx
i tried that but it does not have anything except a (*) in the gateway column. what should I do?
route -nee
How to find gateways of multiple intrefaces? I have two interfaces, one is default, and it’s OK, but I need gateway of second interface …
For some reason, when I type the router’s IP address in a Firefox address bar, it doesn’t show up… any tips for solving this annoyance?
router -n
Thanks.
Hello Vivek,
Is there a way to get version, model number and other pertinent info of Linksys router via linux? I have an ancient router with the relevant tags scratched up.
Thanks!
Just open the router settings, you will get the model number and versions their
Thank you .
thanx…simple way,,,
Thanks
thank you very much .Information is very needful.
Access Denied Help Me PLzzzzzZZZZzzzzz
Add “sudo” before it.
sudo cant work if user is not added in sudoers file
Thanks for the information ! Very helpful!
thank u so much… it was very helpful
THX man. learning linux now and i like it. it is so complex, so many things to learn :D
thanks :)
Thanks………..
Hi. I ve seen a couple of very helpful replies here so I was hoping to get an answer to my problem here.
I am located in Japan and got my self an internet contract. It looks like a DSL router. Though I am not sure what I actually ordered. The usual way to establish connection is only by a CD on Windows. I am pretty sure I can somehow make that darn thing work with Ubuntu as well, I just dont know how.
If editing a DSL connection to the Network Manager it still doesnt work. But I am not very skilled with that. There I tiped in my User data and thats it. I dont know wether of how to fill out the PPPoE or do it automatically. I also wouldnt know the addresse to fill in here.
Then I also tried some sudo pppoe config command but that wouldnt help me either. Afterwards I would always have to get to the etc/network/interfaces file to set everything back so that it wouldnt take 10 times longer to start the laptop cause of the wrong network configurations.
I thought to myself it could be done by accessing the router with an Windows Laptop, but I dont know my neighbours too well to borrow one. However do you think that might be a solution as well ?
Thanks for your comments in advance
Walle
if you plug the router in and turn it on, plug a network cable between your linux computer, it should connect just by using DHCP… The CDs ISPs give out have bloatware like anti-virus, online backup storage (never enough!), dumb wireless managers etc. A network is a netowrk, and there is no need for all the software on the CD…
Nice description…Thanks..
If you have curl installed you can also use:
curl ident.me
Hello i dont have this ip i have just 0.0.0.0
0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 venet0
what is the good ip ?
i have been told to use ‘ip route’. does this work the same way? sorry if this is obvious i am new to linux
any help is appreciated.
thanks in advance
route -n | awk ‘/UG/ {print $2}’