Brief Environment Description: Server A has dual NICs, and the operating system RHEL6.3 ------------------------------------------------------ Nic display name IP address gateway ---------------
Environment Description:
Server A has dual NICs and installs the operating system RHEL6.3
----------------------------------------------------------
Nic display name IP address Gateway
----------------------------------------------------------
Eth0 192.168.153.4 192.168.153.1
Eth1 192.168.152.4 192.168.152.1
-----------------------------------------------------------
Nic configuration file:
[Root @ clovem ~] # Cat/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE = eth0
ONBOOT = yes
BOOTPROTO = static
TYPE = Ethernet
IPADDR = 192.168.153.4
NETMASK = 255.255.255.0
GATEWAY = 192.168.153.1
[Root @ clovem ~] # Cat/etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE = eth1
ONBOOT = yes
BOOTPROTO = static
TYPE = Ethernet
IPADDR = 192.168.152.4
NETMASK = 255.255.255.0
GATEWAY = 192.168.152.1
Restart NETWORK SERVICE
[Root @ clovem ~] # Service network restart
View its route information:
[Root @ clovem ~] # Route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.153.0*255.255.255.0 U 0 0 0 eth0
192.168.152.0*255.255.255.0 U 0 0 0 eth1
Link-local * 255.255.0.0 U 1015 0 0 eth0
Link-local * 255.255.0.0 U 1016 0 0 eth1
Default 192.168.152.1 255.255.255.0 UG 1017 0 0 eth1
We can find that the default gateway of the dual-nic is 192.168.152.1.
A test machine from another network segment 192.168.151.0/24: 192.168.150.252
Access to 192.168.153.4 and 192.168.152.4 can only be connected through 192.168.152.4, but 192.168.153.4 cannot. From the preceding routing table, we can see that the gateway parameter in the two Nic configuration files takes effect only for 192.168.152.1, and is set as the default gateway.
Solution:
1. Delete All GATEWAY parameters in the two Nic configuration files, that is
[Root @ clovem ~] # Cat/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE = eth0
ONBOOT = yes
BOOTPROTO = static
TYPE = Ethernet
IPADDR = 192.168.153.4
NETMASK = 255.255.255.0
[Root @ clovem ~] # Cat/etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE = eth1
ONBOOT = yes
BOOTPROTO = static
TYPE = Ethernet
IPADDR = 192.168.152.4
NETMASK = 255.255.255.0
2. Restart the network
[Root @ clovem ~] # Service network restart
3. view the route table
[Root @ clovem ~] # Route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.153.0*255.255.255.0 U 0 0 0 eth0
192.168.152.0*255.255.255.0 U 0 0 0 eth1
Link-local * 255.255.0.0 U 1015 0 0 eth0
Link-local * 255.255.0.0 U 1016 0 0 eth1
No Default Gateway is set
4. Add a static route table
[Root @ clovem ~] # Echo "153 net_153">/etc/iproute2/rt_tables
[Root @ clovem ~] # Echo "152 net_152">/etc/iproute2/rt_tables
[Root @ clovem ~] # Ip route flush table net_153
[Root @ clovem ~] # Ip route add default via 192.168.153.1 dev eth0 src 192.168.153.4 table net_153
[Root @ clovem ~] # Ip rule add from 192.168.153.4 table net_153 // ignore
[Root @ clovem ~] # Ip route flush table net_152
[Root @ clovem ~] # Ip route add default via 192.168.152.1 dev eth0 src 192.168.153.4 table net_152
[Root @ clovem ~] # Ip rule add from 192.168.152.4 table net_152 // ignore
5. Access via external test machine again
[Root @ storage252 ~] # Ifconfig eth0
Eth0 Link encap: Ethernet HWaddr 00: 50: 56: 82: 56: 55
Inet addr: 192.168.150.252 Bcast: 192.168.150.255 Mask: 255.255.255.0
Inet6 addr: fe80: 250: 56ff: fe82: 5655/64 Scope: Link
Up broadcast running multicast mtu: 1500 Metric: 1
RX packets: 25910143 errors: 0 dropped: 0 overruns: 0 frame: 0
TX packets: 19888495 errors: 0 dropped: 0 overruns: 0 carrier: 0
Collisions: 0 FIG: 1000
RX bytes: 26258149440 (24.4 GiB) TX bytes: 16323278977 (15.2 GiB)
1234567891011121314 [root @ storage252 ~] # Ping-W1-c2 192.168.152.4
PING 192.168.152.4 (192.168.152.4) 56 (84) bytes of data.
64 bytes from 192.168.152.4: icmp_seq = 1 ttl = 63 time = 0.324 MS
64 bytes from 192.168.152.4: icmp_seq = 2 ttl = 63 time = 0.349 MS
--- 192.168.152.4 ping statistics ---
2 packets transmitted, 2 bytes ed, 0% packet loss, time 1000 ms
Rtt min/avg/max/mdev = 0.324/0.336/0.349/0.022 MS
[Root @ storage252 ~] # Ping-W1-c2 192.168.153.4
PING 192.168.153.4 (192.168.153.4) 56 (84) bytes of data.
64 bytes from 192.168.153.4: icmp_seq = 1 ttl = 63 time = 0.342 MS
64 bytes from 192.168.153.4: icmp_seq = 2 ttl = 63 time = 0.271 MS
--- 192.168.153.4 ping statistics ---
2 packets transmitted, 2 bytes ed, 0% packet loss, time 999 ms
Rtt min/avg/max/mdev = 0.271/0.306/0.342/0.039 MS
You can add the Static Routing command to the relevant configuration file as needed, and it will still take effect after restart.
Recommended reading:
Linux dual Nic binding a single IP Address [CentOS] http://www.linuxidc.com/Linux/2013-03/81493.htm
RedHat 6.2 dual Nic binding http://www.linuxidc.com/Linux/2013-03/80832.htm
RHEL5 System Configuration dual Nic binding http://www.linuxidc.com/Linux/2013-01/78485.htm
Dual Nic binding http://www.linuxidc.com/Linux/2012-11/73977.htm under RHEL6.1
Http://www.linuxidc.com/Linux/2012-11/73976.htm bound to dual Nic under RHEL5.5
For more information about RedHat, see RedHat topic page http://www.linuxidc.com/topicnews.aspx? Tid = 10