Operating System - Linux
1832995 Members
2218 Online
110048 Solutions
New Discussion

Re: probelem adding default gateway

 
SOLVED
Go to solution
Deoncia Grayson_1
Honored Contributor

probelem adding default gateway

Here is my problem, every time I try to add the default gateway, it doesn't add it properly the command I use is

route add default gw (ip address) dev eth0

and when I do a netstat -nar to see the routing tables. I see instead of default and the ip address, it gives 0.0.0.0, the ip address and a genmask of 0.0.0.0.. I even tried adding the gateway through netconf to no avai.
If no one ever took risks, Michelangelo would have painted the Sistine floor. -Neil Simon
5 REPLIES 5
Maxim Rozin
Frequent Advisor
Solution

Re: probelem adding default gateway

Hello Deoncia Grayson,

In RedHat, the default gateway is written in /etc/sysconfig/network. After you edit that file, restart network (/etc/init.d/network restart).
If you don't write the default gateway in that file, then after reboot, it wont be configured.

Max.
Stuart Browne
Honored Contributor

Re: probelem adding default gateway

'netstat -nr' will show the default route as:

0.0.0.0 0.0.0.0 UG 0 0 0 eth0

using that format.

The Destination is be 0.0.0.0 with a genmask (netmask) of 0.0.0.0 as it has to match *EVERYTHING*.

It's also why the route will always appear at the end of the routing list.

If you have multiple lines with the destination of '0.0.0.0', then you have multiple default routes. Make sure to remove the incorrect ones.

The file 'maxim' mentions is if you use 'netconf' and only have one interface. If you have multiple interfaces, the keyword 'DEFAULT' can appear within the individual interface's configuration file (usually '/etc/sysconfig/network-scripts/ifcfg-' or '/etc/sysconfig/networking/' somewhere).
One long-haired git at your service...
Gopi Sekar
Honored Contributor

Re: probelem adding default gateway


see whether this is what you are getting:

Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 x.x.x.x 0.0.0.0 UG 0 0 0 eth0

as you see the first entry is destination IP address range match. 0.0.0.0 is a wild card which will match all ip address ranges and x.x.x.x shows the gateway server ip address.

Hope this helps,
Gopi
Never Never Never Giveup
Suraj Singh_1
Trusted Contributor

Re: probelem adding default gateway

There is nothing wrong in 0.0.0.0/0.0.0.0, this refers to everything.

Look for the Flags column. an UG in the row containing 0.0.0.0 0.0.0.0 shows that the IP present in the Gateway column is indeed the default gateway.

You may check this by issuing a traceroute command to an unknown IP, and see what is the first hop in the o/p.

eg, traceroute 1.2.3.4

Regards
What we cannot speak about we must pass over in silence.
Deoncia Grayson_1
Honored Contributor

Re: probelem adding default gateway

Everyone response was greatly appreciated but I went the first guys response and it worked just fine... Thanks guys!


If no one ever took risks, Michelangelo would have painted the Sistine floor. -Neil Simon