RH 5.6 上的多个网络接口

RH 5.6 上的多个网络接口

我有一台 Redhat 5.6 服务器,该服务器有多个网络接口,插入不同的网络交换机端口,大多数接口位于不同的 VLAN/子网上。我如何知道哪个接口位于哪个子网上?

例如,eth0 是主接口,工作正常。我在 eth1 上从不同的 vlan 连接了另一个 IP,但无法 ping 通网关(无法 ping 通)。我被告知 eth1 插入了另一个 vlan 上的端口(它实际上是用于集群的心跳 vlan)。如何测试哪个控制器位于特定 vlan 上?

eth1(IP 已改变):

[root@tsgxd3900 ~]# ifup eth1
Error: an inet prefix is expected rather than "GATEWAY<N>=10.56.35.1".
Error: an inet prefix is expected rather than "NETMASK<N>=255.255.255.0".
Error: an inet prefix is expected rather than "ADDRESS<N>=10.56.36.122".
Error: an inet prefix is expected rather than "GATEWAY<N>=10.56.35.1".
Error: an inet prefix is expected rather than "NETMASK<N>=255.255.255.0".
Error: an inet prefix is expected rather than "ADDRESS<N>=10.56.38.35".

[root@tsgxd3900 ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.56.36.0       0.0.0.0         255.255.255.0   U     0      0        0 eth1
10.56.7.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 eth1
0.0.0.0         10.56.7.1        0.0.0.0         UG    0      0        0 eth0

[root@tsgxd3900 ~]# ping 10.56.7.1
PING 10.56.7.1 (10.56.7.1) 56(84) bytes of data.
64 bytes from 10.56.7.1: icmp_seq=1 ttl=255 time=0.450 ms
^C
--- 10.56.7.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.450/0.480/0.510/0.030 ms

[root@tsgxd3900 ~]# ping 10.56.36.1
PING 10.56.36.1 (10.56.36.1) 56(84) bytes of data.
From 10.56.36.122 icmp_seq=2 Destination Host Unreachable

[root@tsgxd3900 ~]# ifconfig eth1
eth1      Link encap:Ethernet  HWaddr B8:E3:B6:AB:1C:6D
          inet addr:10.56.36.122  Bcast:10.56.36.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:65 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 b)  TX bytes:8435 (8.2 KiB)
          Interrupt:77

添加更多信息:

[root@tsgxd3900 ~]# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=tsgxd3900
GATEWAY=10.56.7.1
[root@tsgxd3900 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# NetXen Incorporated NX3031 Multifunction 1/10-Gigabit Server Adapter
DEVICE=eth0
BOOTPROTO=static
DHCPCLASS=
HWADDR=78:E3:B5:0B:7C:6C
IPADDR=10.56.7.243
NETMASK=255.255.255.0
ONBOOT=yes
[root@tsgxd3900 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth1
# NetXen Incorporated NX3031 Multifunction 1/10-Gigabit Server Adapter
DEVICE=eth1
HWADDR=78:E3:B5:0B:7C:6D
ONBOOT=yes
BOOTPROTO=static
IPADDR=10.56.36.122
NETMASK=255.255.255.0
HOTPLUG=no
[root@tsgxd3900 ~]# cat /etc/sysconfig/network-scripts/route-eth1
GATEWAY<N>=10.56.35.1
NETMASK<N>=255.255.255.0
ADDRESS<N>=10.56.36.122

GATEWAY<N>=10.56.35.1
NETMASK<N>=255.255.255.0
ADDRESS<N>=10.56.38.35
[root@tsgxd3900 ~]#

答案1

看起来您定义了两个默认网关。您可以发布以下文件的输出吗:

/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-eth1 

您的 eth1 接口中可能不需要网关语句。您应该在文件中定义辅助接口所需的任何路由/etc/sysconfig/network-scripts/route-eth1,格式如下:

10.56.36.0/24 via 10.56.36.1 dev eth1

答案2

在 Red Hat 上,IP 配置(如果通过 RH 的工具配置接口)将位于 ifcfg-INTERFACE 文件中。以下是示例。

[root@server network-scripts]# cat ifcfg-eth0:1
# Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller
DEVICE=eth0:1
BOOTPROTO=none
BROADCAST=192.168.16.255
IPADDR=192.168.16.201
NETMASK=255.255.255.0
NETWORK=192.168.16.0
GATEWAY=192.168.15.7
TYPE=Ethernet
ONPARENT=yes

在某些情况下,路由也将位于具有接口名称的单独文件中:

[root@servername network-scripts]# cat route-eth0 
ADDRESS0=192.168.16.0
NETMASK0=255.255.255.0
GATEWAY0=192.168.15.1

ADDRESS1=192.168.17.0
NETMASK1=255.255.255.0
GATEWAY1=192.168.15.1

ADDRESS2=192.168.18.0
NETMASK2=255.255.255.0
GATEWAY2=192.168.15.1

从命令行,您也可以运行 ip addr 或 ip route:

[root@servername network-scripts]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether f4:6d:04:03:b4:18 brd ff:ff:ff:ff:ff:ff
    inet 192.168.15.200/24 brd 192.168.10.255 scope global eth0
    inet 192.168.16.201/24 brd 192.168.16.255 scope global eth0:1
    inet 192.168.17.201/24 brd 192.168.17.255 scope global eth0:2
    inet 192.168.18.202/24 brd 192.168.18.255 scope global eth0:5
    inet 192.168.15.201/24 brd 192.168.15.255 scope global secondary eth0:3
    inet 192.168.16.202/24 brd 192.168.16.255 scope global secondary eth0:4
3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000
    link/ether e0:b9:a5:00:ea:14 brd ff:ff:ff:ff:ff:ff



[root@servername network-scripts]# ip route
255.255.255.255 dev eth1  scope link 
192.168.15.0/24 dev virbr0  proto kernel  scope link  src 192.168.15.100 
172.16.15.0/24 dev eth1  proto kernel  scope link  src 172.16.15.1 
192.168.122.0/24 via 192.168.15.100 dev virbr0 
169.254.0.0/16 dev eth1  scope link  metric 1003 
169.254.0.0/16 dev virbr0  scope link  metric 1004 
default via 192.168.15.1 dev virbr0 

或者:

[root@servername network-scripts]# ip route
192.168.18.0/24 dev eth0  proto kernel  scope link  src 192.168.18.202 
192.168.17.0/24 dev eth0  proto kernel  scope link  src 192.168.17.201 
192.168.16.0/24 dev eth0  proto kernel  scope link  src 192.168.16.201 
192.168.15.0/24 dev eth0  proto kernel  scope link  src 192.168.15.200 
169.254.0.0/16 dev eth0  scope link 
default via 192.168.15.7 dev eth0

(最后一个输出来自RH5型机器)

相关内容