How to Find Default Gateway in Linux
A gateway is a node or a router that acts as an access point to passes network data from local networks to remote networks. There are many ways to find out your gateway in Linux. Here are some of them from Terminal.
You can find default gateway using ip, route and netstat commands in Linux systems.
Using route command
Open up your terminal and type the following commands:
sk@sk:~$ route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth1 192.168.1.0 0.0.0.0 255.255.255.0 U 1 0 0 eth1
The above output shows my default gateway is 192.168.1.1. UG stands for the network link is Up and G stands for Gateway.
Using ip route
Use the following command:
sk@sk:~$ ip route show default via 192.168.1.1 dev eth1 proto static 192.168.1.0/24 dev eth1 proto kernel scope link src 192.168.1.100 metric 1
Use the following command:
sk@sk:~$ netstat -rn Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 0.0.0.0 192.168.1.1 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
And finally you can view it using the eth config files. If your network interface is eth0, then the command should be:
In RHEL based systems:
[root@server ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE="eth0" BOOTPROTO=none NM_CONTROLLED="yes" ONBOOT=yes TYPE="Ethernet" UUID="bcb0a409-d7d4-4f2f-882f-ec46e07e670d" HWADDR=08:00:27:A6:0C:AC IPADDR=192.168.1.200 PREFIX=24 GATEWAY=192.168.1.1 DNS1=188.8.131.52 DNS2=192.168.1.200 DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no NAME="System eth0"
And for Debian based systems, use the following command:
sk@sk:~$ cat /etc/network/interfaces # interfaces(5) file used by ifup(8) and ifdown(8) auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 192.168.1.100 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1
Like us on Facebook
We need your assistance to stay live
This week Top Posts
- Top Things To Do After Installing Ubuntu 13.10 'Saucy Salamander' : Ubuntu 13.10 Saucy Salamander will be released on coming October 17th with many new salient featur...0 comments |
- Install Fail2Ban On Ubuntu Server 13.04/13.10 : Introduction Fail2Ban is an intrusion prevention framework written in the Python programming l...0 comments |
- 5 Android Apps that’s Going to Make Running Your Business Less Stressful : Running a business can be very stressful. You have to think about team collaboration, making sure th...0 comments |
- Install Crashplan backup tool in Linux : CashPlan is an automated backup solution that either uses the CrashPlan Central server or any other ...0 comments |
- install Git in Ubuntu : Git is a distributed revision control system with an emphasis on speed. Git was initially designed a...0 comments |
- Install Corosync and Pacemaker On CentOS 6.5 : I will show you in this tutorial how to install your first cluster Corosync and the Linux Cluster Ma...0 comments |
- Install Uget Download Manager In Ubuntu, Fedora, Debian
- Download Elementary OS ‘Luna’ Official Wallpapers
- Install Power Commands 0.1.5 On Ubuntu 14.04/13.10/12.10/12.04
- 5 Android Apps that’s Going to Make Running Your Business Less Stressful
- Puppet agent Install Using Script
- Install Corosync and Pacemaker On CentOS 6.5
- Install Fail2Ban On Ubuntu Server 13.04/13.10
- How To Install Google Chrome in Fedora 20, 19, 18
- How to surf using Tor Browser Bundle
- New Games got Greenlit on Linux by Steam Today!
This work by unixmen.com is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
Copyright © 2008-2013 Unixmen.com .