我有一个装有 5 个网卡的 SciLinux 6 盒子。我没有得到我想要的网络配置(特别是路由)。虽然我可以在 rc.local 的末尾放置一堆路由语句,但我宁愿采用“redhat”方式。
我想要的是一些关于如何做的指导:
- 按照如下所示更正路由。
- 按照如下所示更正默认路由。
- 我很想让 169.254 这个愚蠢的事情消失,因此,如果能得到一些关于如何做到这一点的指导,我将非常感激。
因此有 5 个网卡,eth0-eth4。请注意,eth4 插入思科交换机上的 RSPAN 端口,仅出于完整性考虑才包含。
# ifconfig -a
eth0 Link encap:Ethernet HWaddr 14:DA:E9:1F:C3:F4
inet addr:172.17.21.185 Bcast:172.17.21.255 Mask:255.255.255.0
inet6 addr: fe80::16da:e9ff:fe1f:c3f4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:138237 errors:0 dropped:0 overruns:0 frame:0
TX packets:16628 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:14693874 (14.0 MiB) TX bytes:2744136 (2.6 MiB)
Interrupt:18 Memory:fb700000-fb720000
eth1 Link encap:Ethernet HWaddr 00:15:17:BC:09:FC
inet addr:172.19.21.185 Bcast:172.19.21.255 Mask:255.255.255.0
inet6 addr: fe80::215:17ff:febc:9fc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:310208 errors:0 dropped:0 overruns:0 frame:0
TX packets:1252 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:30318084 (28.9 MiB) TX bytes:173742 (169.6 KiB)
Interrupt:17 Memory:fb2a0000-fb2c0000
eth2 Link encap:Ethernet HWaddr 00:15:17:BC:09:FD
inet addr:172.22.21.185 Bcast:172.22.21.255 Mask:255.255.255.0
inet6 addr: fe80::215:17ff:febc:9fd/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:60431 errors:0 dropped:0 overruns:0 frame:0
TX packets:10028 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3717284 (3.5 MiB) TX bytes:2221656 (2.1 MiB)
Interrupt:18 Memory:fb240000-fb260000
eth3 Link encap:Ethernet HWaddr 00:15:17:BC:09:FE
inet addr:172.21.21.185 Bcast:172.21.21.255 Mask:255.255.255.0
inet6 addr: fe80::215:17ff:febc:9fe/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2181043 errors:0 dropped:0 overruns:0 frame:0
TX packets:3531189 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:626303081 (597.2 MiB) TX bytes:5131547226 (4.7 GiB)
Interrupt:18 Memory:fb1a0000-fb1c0000
eth4 Link encap:Ethernet HWaddr 00:15:17:BC:09:FF
inet addr:1.1.1.1 Bcast:1.255.255.255 Mask:255.255.255.255
inet6 addr: fe80::215:17ff:febc:9ff/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:57507 errors:0 dropped:0 overruns:0 frame:0
TX packets:100 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3556510 (3.3 MiB) TX bytes:20238 (19.7 KiB)
Interrupt:19 Memory:fb140000-fb160000
当前的路线如下:
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
172.22.21.0 0.0.0.0 255.255.255.0 U 0 0 0 eth2
172.21.21.0 0.0.0.0 255.255.255.0 U 0 0 0 eth3
172.17.21.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
172.19.21.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 1003 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1004 0 0 eth2
169.254.0.0 0.0.0.0 255.255.0.0 U 1005 0 0 eth3
169.254.0.0 0.0.0.0 255.255.0.0 U 1006 0 0 eth4
0.0.0.0 172.22.21.3 0.0.0.0 UG 0 0 0 eth2
这是我想要的路线:
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
172.22.21.0 172.22.21.3 255.255.255.0 U 0 0 0 eth2
172.21.21.0 172.21.21.3 255.255.255.0 U 0 0 0 eth3
172.17.21.0 172.17.21.3 255.255.255.0 U 0 0 0 eth0
172.19.21.0 172.19.21.3 255.255.255.0 U 0 0 0 eth1
0.0.0.0 172.17.21.3 0.0.0.0 UG 0 0 0 eth2
以下是配置文件(我知道的)
$ cat /etc/sysconfig/network-scripts/ifcfg-zEM
DEVICE="eth0"
HWADDR=14:DA:E9:1F:C3:F4
NM_CONTROLLED="no"
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=static
IPADDR=172.17.21.185
BROADCAST=172.17.21.255
PREFIX=24
GATEWAY=172.17.21.3
DNS1=172.17.21.20
DNS2=172.17.21.21
DOMAIN=em.local
DEFROUTE=no
IPV4_FAILURE_FATAL=yes
PEERDNS=yes
IPV6INIT=no
IPV6_AUTOCONF=no
USERCTL=no
NAME=EM
UUID=3a73717e-65ab-93e8-b518-24f5af32dc0d
$ cat /etc/sysconfig/network-scripts/ifcfg-FEP
DEVICE=eth1
HWADDR=00:15:17:BC:09:FC
NM_CONTROLLED="no"
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=static
IPADDR=172.19.21.185
BROADCAST=172.19.21.255
PREFIX=24
BROADCAST=172.19.21.255
GATEWAY=172.19.21.3
#DNS1=172.17.21.20
#DNS2=172.17.21.21
DOMAIN=em.local
DEFROUTE=no
IPV4_FAILURE_FATAL=yes
PEERDNS=yes
IPV6INIT=no
IPV6_AUTOCONF=no
USERCTL=no
NAME=FEP
$ cat /etc/sysconfig/network-scripts/ifcfg-QA
DEVICE=eth2
HWADDR=00:15:17:BC:09:FD
NM_CONTROLLED="no"
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=static
IPADDR=172.22.21.185
PREFIX=24
BROADCAST=172.22.21.255
GATEWAY=172.22.21.3
DNS1=172.17.21.20
DNS2=172.17.21.21
DOMAIN=em.local
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
PEERDNS=yes
IPV6INIT=no
IPV6_AUTOCONF=no
USERCTL=no
NAME=QA
$ cat /etc/sysconfig/network-scripts/ifcfg-PD
DEVICE=eth3
HWADDR=00:15:17:BC:09:FE
NM_CONTROLLED="no"
ONBOOT=yes
TYPE=Ethernet
BOOTPROTO=static
IPADDR=172.21.21.185
PREFIX=24
BROADCAST=172.21.21.255
GATEWAY=172.21.21.3
DNS1=172.17.21.20
DNS2=172.17.21.21
DOMAIN=em.local
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
PEERDNS=yes
IPV6INIT=no
IPV6_AUTOCONF=no
USERCTL=no
NAME=PD
# UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
$ cat /etc/sysconfig/network-scripts/ifcfg-RSPAN
DEVICE="eth4"
NM_CONTROLLED="no"
ONBOOT="yes"
HWADDR="00:15:17:BC:09:FF"
TYPE=Ethernet
BOOTPROTO=none
IPADDR=1.1.1.1
PREFIX=32
DEFROUTE=no
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=RSPAN
IPV6_AUTOCONF=no
# UUID=d9ced338-a402-60eb-c131-0fd3ab4b5ab7
$ cat /etc/networks
default 0.0.0.0
loopback 127.0.0.0
link-local 169.254.0.0
$ cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=bigbox.em.local
NTPSERVERARGS=iburst
答案1
您需要route-ethX
在目录中创建一个名为(其中 X 是您想要附加路由的接口)的文件/etc/sysconfig/network-scripts
。
例如,我需要将我们的公共办公室路由到互联网而不是 VPN,因为聊天会检查您的身份。所以我有一个名为“route-eth0
办公室路由器”的文件,如下所示:
64.34.119.10 via 74.101.14.1 dev eth0
您可以阅读 RHEL 网络配置这里
答案2
169.254/16 地址来自 zeroconf。您应该能够通过以下步骤禁用它们:
基本上,将 NOZEROCONF=yes 添加到 /etc/sysconfig/network 文件中。