Operating System - Linux
1819684 Members
3349 Online
109605 Solutions
New Discussion юеВ

adding default gateway on redhat 8

 
ricky_8
Frequent Advisor

adding default gateway on redhat 8

Hi Guys,

Iam trying to add default gateway to my redhat 8 server.
I can do it by adding route add default gw xxx.xx.xx.xx dev ethx
it works fine and iam on network.
But once i reboot the default gateway info vanishes.hence want to know how to set it permanently.

I know in HPUX u can do it by adding to netconf file.Is there anysuch file for redhat 8

Please help, thanxs,
7 REPLIES 7
Donald Kok
Respected Contributor

Re: adding default gateway on redhat 8

Hi,

There is even a gui for it! From the statrmenu, choose systemconfiguration -> network

You can also start it by hand: /usr/bin/redhat-config-network

From there you can choose the edit button and there is a filed with DG.

Greetzz
Donald
My systems are 100% Murphy Compliant. Guaranteed!!!
Jerome Henry
Honored Contributor

Re: adding default gateway on redhat 8

Hi !
You can also do it by hand : your default gateway is in /etc/sysconfig/network file. Check it, or edit it to add : GATEWAY=xxx.xx.xx.xx.
You can also echo GATEWAY=xxx.xx.xx.xx > /etc/sysconfig/network if you do not like vi or other editor !
You can lean only on what resists you...
ricky_8
Frequent Advisor

Re: adding default gateway on redhat 8

Well i need to explain more,we use local gateway as servers IP itself.
So if server ip is 10.9.10.100
and gatway ip is 10.9.10.1

Then if i add
route add default gw 10.9.10.100 dev eth1

then it works and i can connect to network.

so now i tried putting this gateway in via GUI and network file but after reboot i have to again run the route add command to get on network.

In HPUX we can specify in netconf whether it is remote or local route by setting 1 or 0.

How do i do it in redhat?.

I tried adding the gateway info in /etc/default-route but it seems it gets erased after reboot.

Any clue ?
Jerome Henry
Honored Contributor

Re: adding default gateway on redhat 8

your route add should work perfectly (aprt from dev which is not required, just eht0 is ok).
Nevertheless, your configuration still needs to be precised more :
do you use dynamic routing or static ?
If you use dynamic, then it is normal that gateway disapears on reboot as the routed daemon deals it for you. Check that in /etc/gateways your default gw is set (name and ip). Have a man routed for details.
If you use static route, check that in /etc/hosts, your gw is set (name and ip), otherwise this active setiing you are putting isn't recognised on reboot.
Whatever, you can add an external default gw on linux, for sure. This 1 you are talking about has a 'looks like' in dynamic routing by precising in /etc/gatewas 'external' when it is the case, it has no 'looks like' in static routing.
Try this, if it doesn't work, let us know about your netmask, and position of DNS on your network (which should be set properly according tou your question level ! :-))
Yours
You can lean only on what resists you...
Sergejs Svitnevs
Honored Contributor

Re: adding default gateway on redhat 8

1 var. You can add "route add default gw 10.9.10.100 dev eth1" to the "/etc/rc.d/rc.local" script.
2 var. You can add "eth1 net 0.0.0.0 gw 10.9.10.100" to the "/etc/sysconfig/static-routes" file.

After configuring you need restart a Linux box.

Regards,
Sergejs
Jerome Henry
Honored Contributor

Re: adding default gateway on redhat 8

Or at least restart your network function, /etc/rc.d/init.d/network restart.
Before doing so, check that your /etc/sysconfig/network contains GATEWAY=10.0.0.100 (your gateway), which should be there accordingly with your route add. It happens that route adds does not set it up permanently in this file in some red hat distro. Just do it by hand.
rgds
You can lean only on what resists you...
ricky_8
Frequent Advisor

Re: adding default gateway on redhat 8

Hi All,

Thanxs i was able to correctly add static IP to network file and now itis working fine.I think is was mostly due to incorrect info in network file.

Thanxs a lot ,

Rgds,