• RSS
  • SmsJobs
  • Sms
  • GoogleBuzz
  • Facebook
  • Twitter
  • Linkedin
  • Youtube
The Linux Juggernaut

The Linux Juggernaut

roles on……

Do you like www.linuxnix.com ? Please consider supporting us by becoming a subscriber and get a Linux basics e-book for free.

This is asked in some of the interviews. We can get default gateway information in linux in many ways. Such as viewing network card file or executing a command.
To see default gateway by view network interface card file content.
#cat /etc/sysconfig/networking/devices/interface-no

Example :
[root@example ~]# cat /etc/sysconfig/networking/devices/ifcfg-eth0
# Intel Corporation 82546EB Gigabit Ethernet Controller (Copper)
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:02:a5:4c:af:99
ONBOOT=yes
TYPE=Ethernet
NETMASK=255.255.255.0
IPADDR=10.200.0.21
GATEWAY=10.200.0.1

Through route command
route

Example:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.0 * 255.255.255.0 U 0 0 0 eth1
10.78.0.0 * 255.255.255.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth1
default 10.200.0.1 0.0.0.0 UG 0 0 0 eth0

Through ip route command
ip route

Example :
[root@example ~]# ip route
192.168.0.0/24 dev eth1 proto kernel scope link src 192.168.0.1
10.78.0.0/24 dev eth0 proto kernel scope link src 10.78.0.21
169.254.0.0/16 dev eth1 scope link
default via 10.200.0.1 dev eth0

Through netstat command
netstat -r

Example:
[root@example ~]# netstat -r

Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.0.0 * 255.255.255.0 U 0 0 0 eth1
10.78.0.0 * 255.255.255.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth1
default 10.200.0.1 0.0.0.0 UG 0 0 0 eth0

Note:For any system/server there will be only one default gateway, if suppose if you assign two default gateways to your machine, your system will not come to know where to send the packets.

Do you like www.linuxnix.com ? Please consider supporting us by becoming a subscriber and get a Linux basics e-book for free.
bySurendra On Wednesday-July - 7 - 2010
  • Shaik

    If you want to add gateway to different NIC interface like eth1 then we need to add execute route add -net xxx.xxx.xxx.xxx netmask xxx.xxx.xxx.xxx gw xxx.xxx.xxx.xxx eth1

    To make this gateway persistent across reboots, add above command in /etc/rc.d/rc.local file. This the last file which executes across every reboot after executing all booting scripts.

email newsletter

Linux_redirection_operators

Linux/Unix redirecti

 Redirecting operators in Linux  In order to understand about Redirecting operators ...

dns records, dns configuration, dns stuff, dns server, open dns, dns report, how dns works, dns port number, dns in linux, global dns, types of dns, define dns, universal dns, dns address, domain name system, dns advantage, dns ip address, dns watch, dns query types, open dns address, check dns, dns namespace, dns resource records, dns tutorial, dns details, a dns, what is a dns, who is dns, how to dns, dns who is, dyn dns, dns servers, dns server service, dns a name, search dns, dns name, domain dns, dns setup, set dns

Domain Name Server(D

History of DNS server How DNS server evolved? To understand why we ...

Linux Bash Shell sho

This is a small post on improving your productivity when working with ...

Up coming posts on D

We are very much happy to announce that we started posting on ...

Wishing you Happy an

Dear Friends/Readers, I take this opportunity to convey our sincere thanks ...

  • About Linux Juggernaut

    How the blog name selected? Juggernaut: * a massive inexorable force that seems to crush everything in its way ...readmore>>

  • Contact Me

    Contact us Send an Email Phone number and vCard LinkedIn profile Advertise with us
  • About Me

    Surendra Kumar Chowdary

    My name is Surendra Kumar Anne. I am from Vijayawada which is cultural capital of south Indian state of Andhra Pradesh. I am a Linux evangelist who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. At present i work at Persistent Systems as Module Lead.   read more »