Changing default global IP gateway in CentOS 5.6

Issues related to configuring your network
mdef
Posts: 3
Joined: 2012/07/09 09:27:00

Changing default global IP gateway in CentOS 5.6

Post by mdef » 2012/07/09 13:23:01

Hello everybody,

I need to change the global IP gateway in CentOS 5.6, i.e., the one chosen when no other more specific route is available.
Apparently, CentOS selects the gateway for the physical device with the highest index (in my case, eth3). But I want eth0.
I can only change it manually:
> route add default gw
> route del default gw
But I want to change it permanently (surviving reboots).
I have tried /etc/sysconfig/network-scripts/route-eth0 and NETWORK=0.0.0.0 with no success.

Any help would be appreciated.

Thank you.

Regards,

Jos?.

gerald_clark
Posts: 10642
Joined: 2005/08/05 15:19:54
Location: Northern Illinois, USA

Changing default global IP gateway in CentOS 5.6

Post by gerald_clark » 2012/07/09 13:29:25

Welcome to centOS.
New members should read:
http://www.centos.org/modules/newbb/viewforum.php?forum=47

Set "GATEWAY=XXX.XXX.XXX.XXX" in /etc/sysconfig/network.

mdef
Posts: 3
Joined: 2012/07/09 09:27:00

Re: Changing default global IP gateway in CentOS 5.6

Post by mdef » 2012/07/09 16:11:51

We already have that parameter in /etc/sysconfig/network, but unfortunately CentOS ignores it.

mdef
Posts: 3
Joined: 2012/07/09 09:27:00

Re: Changing default global IP gateway in CentOS 5.6

Post by mdef » 2012/07/09 16:43:58

Your clue was very helpful.
There was a profile called "default" (created by the DVD installer), and the interpreted network file was rather /etc/sysconfig/networking/profiles/default/network.
Once I have set GATEWAY there, the default gateway has been applied correctly.

Thank you very much.

User avatar
jlehtone
Posts: 4530
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Changing default global IP gateway in CentOS 5.6

Post by jlehtone » 2012/07/09 18:27:45

The /etc/sysconfig/networking/* are probably created by "system-config-network" or equivalent. Pay attention to what files are symlinked and whether you could get rid of the /etc/sysconfig/networking/* entirely.

kamel.berrayah
Posts: 6
Joined: 2014/01/03 22:55:41
Location: Algiers
Contact:

Re: Changing default global IP gateway in CentOS 5.6

Post by kamel.berrayah » 2014/01/04 00:27:58

Hi
I already chabge the value in /etc/sysconfig/networking/profiles/default/network but it s not woek for me

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Changing default global IP gateway in CentOS 5.6

Post by TrevorH » 2014/01/04 00:41:52

Please post the contents of /etc/sysconfig/network and also /etc/sysconfig/network-scripts/ifcfg-*

The 'network' file should work unless you also have GATEWAY= lines in the ifcfg files (which should be removed).
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

kamel.berrayah
Posts: 6
Joined: 2014/01/03 22:55:41
Location: Algiers
Contact:

Re: Changing default global IP gateway in CentOS 5.6

Post by kamel.berrayah » 2014/01/05 00:25:16

Hi

My problem is resolved when I did this :

ifconfig eth0 ip 192.168.1.6 mask 255.255.255.0

route delete default gw 192.168.1.6 eth0
route add default gw 192.168.1.254 eth0

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Changing default global IP gateway in CentOS 5.6

Post by TrevorH » 2014/01/05 00:40:37

You really should not need to do this manually. As I requested before, please post the contents of /etc/sysconfig/network and /etc/sysconfig/network-scripts/ifcfg-* and I am fairly sure we can fix this.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

kamel.berrayah
Posts: 6
Joined: 2014/01/03 22:55:41
Location: Algiers
Contact:

Re: Changing default global IP gateway in CentOS 5.6

Post by kamel.berrayah » 2014/01/05 01:13:05

now I have this in the configuration

[root@CENTOS6 ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=CENTOS6
[root@CENTOS6 ~]#


[root@CENTOS6 ~]# cat /etc/sysconfig/network-scripts/ifcfg-*
TYPE=Ethernet
BOOTPROTO=none
IPADDR=192.168.1.195
PREFIX=24
GATEWAY=192.168.1.2
DNS1=8.8.8.8
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=eth6
UUID=492b341a-b7c8-4c57-873c-e44b64b1f8e1
ONBOOT=yes
DEVICE=eth6
USERCTL=yes
HWADDR=00:0c:29:ea:81:40
NETMASK=255.255.255.0
DEVICE=lo
IPADDR=127.0.0.1
NETMASK=255.0.0.0
NETWORK=127.0.0.0
# If you're having problems with gated making 127.0.0.0/8 a martian,
# you can change this to something else (255.255.255.255, for example)
BROADCAST=127.255.255.255
ONBOOT=yes
NAME=loopback

Post Reply