大网数据广告活动
服务器运维问答

route table issue when I appended option net.ifnames=0 to grub2

· 52CE 我爱测

I appended two options net.ifnames=0 biosdevname=0 to grub2 because I want to change default network name to old name eth0 on RHEL 7 . After that, I edited /etc/sysconfig/network to set default gateway for machine: GATEWAY=192.16…

问题原文

原帖链接 · Hai Nguyen · CC BY-SA 3.0

I appended two options net.ifnames=0 biosdevname=0 to grub2 because I want to change default network name to old name eth0 on RHEL 7.

After that, I edited /etc/sysconfig/network to set default gateway for machine:

GATEWAY=192.168.88.1

And configured network interface. When I have only one network interface eth0, everything works well.

Here is the route table with one network interface eth0:

[root@devmachine ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.88.1    0.0.0.0         UG    100    0        0 eth0
192.168.88.0    0.0.0.0         255.255.255.0   U     100    0        0 eth0
[root@devmachine ~]#

But I got the issue with route table, when more than one network interface online.

[root@devmachine ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.88.1    0.0.0.0         UG    100    0        0 eth0
0.0.0.0         192.168.88.1    0.0.0.0         UG    101    0        0 eth1
172.168.0.0     0.0.0.0         255.255.0.0     U     100    0        0 eth1
192.168.88.0    0.0.0.0         255.255.255.0   U     100    0        0 eth0
192.168.88.1    0.0.0.0         255.255.255.255 UH    100    0        0 eth1
[root@devmachine ~]#

As you can see, gateway address 192.168.88.1 was added to eth1 at the last line. And the gateway address is appended continuously with new network interface.

[root@devmachine network-scripts]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.88.1    0.0.0.0         UG    100    0        0 eth0
default         192.168.88.1    0.0.0.0         UG    101    0        0 eth1
default         192.168.88.1    0.0.0.0         UG    102    0        0 eth2
172.168.0.0     0.0.0.0         255.255.0.0     U     100    0        0 eth1
172.168.0.0     0.0.0.0         255.255.0.0     U     101    0        0 eth2
192.168.88.0    0.0.0.0         255.255.255.0   U     100    0        0 eth0
192.168.88.1    0.0.0.0         255.255.255.255 UH    100    0        0 eth1
192.168.88.1    0.0.0.0         255.255.255.255 UH    101    0        0 eth2

Actually, the issue appears only when i appended the option net.ifnames=0 to grub2. Someone help me please.

已采纳解答

原帖链接 · chutz · CC BY-SA 3.0

You'll have to add

DEFROUTE=no

To all the interfaces that should not have the default route. In your case, adding DEFROUTE=no to /etc/sysconfig/network-scripts/ifcfg-eth1 should do the trick.

Alternatively, instead of setting GATEWAY in /etc/sysconfig/network you can set it in /etc/sysconfig/network-scripts/route-eth0 instead. I.e.

echo 0.0.0.0/0 via 192.168.88.1 > /etc/sysconfig/network-scripts/route-eth0

You can refer to the RHEL 7 Network Guide

By the way, I believe your problem has nothing to do with what you did with the grub configuration.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-01-22)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。