Network/routing problem with centos
Solution 1
If you had configured scope point to point link (because NETMASK=255.255.255.255
) then you wanted to route all traffic via eth0:
IPADDR=136.243.34.136 NETMASK=255.255.255.255 SCOPE="peer 136.243.34.129"
I don't understand for what did you configure default route via eth1?
I think you have to change configuration of eth0 interface :
IPADDR=136.243.34.136
NETMASK=255.255.255.127
And delete the routing configuration file for eth0 interface. I see that two interfaces are connected to two independent providers. That's why i recommend you to use iproute2. How to configure it you can see at Configuring Multiple Default Routes in Linux
Solution 2
I would suggest you to use nmtui
interface to setup IP, route, DNS etc.,
This will update corresponding configuration files automatically.
nmtui
is packaged along with NetworkManager-tui-1.4.0-12.el7.x86_64 rpm
.
Živorad Antonijević
Updated on September 18, 2022Comments
-
Živorad Antonijević over 1 year
I have problem with my centos box. After upgrading few packages, after some time network get broken.
What happens is that eth0 is not functional anymore. Only error in log file I have found was this one:
Invalid IP4 netmask 'NETMASK0' "0.0.0.0"
After some research I figured out it was problem with route-eth0 config file because network starts, but routes are not added. If I add them manually, then all goes fine.
Without it, routing table is very strange one:
[root@CentOS-70-64-minimal network-scripts]# route -e Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface default gateway 0.0.0.0 UG 0 0 0 eth1 default gateway 0.0.0.0 UG 0 0 0 eth0 gateway 0.0.0.0 255.255.255.255 UH 0 0 0 eth0 CentOS-70-64-mi 0.0.0.0 255.255.255.255 UH 0 0 0 eth0 link-local 0.0.0.0 255.255.0.0 U 0 0 0 eth0 188.40.24.199 gateway 255.255.255.255 UGH 0 0 0 eth0 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
It is CentOS Linux release 7.2.1511 (Core).
/etc/sysconfig/network-scripts/ifcfg-eth0:
DEVICE=eth0 BOOTPROTO=none ONBOOT=yes HWADDR=44:8A:5B:D8:74:B3 IPADDR=136.243.34.136 NETMASK=255.255.255.255 SCOPE="peer 136.243.34.129" IPV6INIT=yes IPV6ADDR=2a01:4f8:212:283::2/64 IPV6_DEFAULTGW=fe80::1 IPV6_DEFAULTDEV=eth0
/etc/sysconfig/network-scripts/route-eth0
# routing for eth0 ADDRESS0=0.0.0.0 NETMASK0=0.0.0.0 GATEWAY0=136.243.34.129
Btw, eth1 is working fine. Also on other server all interfaces are working with same configuration.
Problem may be because it was centos 6 and then updated to centos 7. Maybe some setting left and make problem.
Because site is live, I made temporary solution adding this line to crontab to run every minute:
/etc/sysconfig/network-scripts/ifup-routes eth0
-
sjsam over 7 yearspls add
centos
version to question -
Rabin over 7 yearsplease include the configuration file for eth0 (
/etc/sysconfig/network-scripts/ifcfg-eth0
) -
Eric Renouf over 7 yearsYou can only have a single default route/gateway. It looks like you're trying to set them on both eth1 and eth0.
-
-
Živorad Antonijević over 7 yearsIt does not help. If I run
service network restart
eth0 is again without proper gateway. -
bodgit over 7 yearsThat's probably because you have a default gateway configured on
eth1
already. As I said, you can't have two default gateways, not without advanced configuration anyway, which is beyond the scope of this question.