Provided: the server has four cards, information shown as follows:
[Root @ redo LE-23 ~] # IPaddr | grep net
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
inet 192.168.1.150/24 brd 192.168.1.255scope global dynamic enP3p9s0f0
inet6 fd00:1:1:1:42f2:e9ff:fe5c:b5bc/64scope global dynamic
inet6 fe80 :: 42f2: e9ff: fe5c: b5bc / 64 scopelink
inet 192.168.1.104/24 brd 192.168.1.255scope global dynamic enP3p9s0f1
inet6 fd00:1:1:1:42f2:e9ff:fe5c:b5bd/64scope global dynamic
inet6 fe80 :: 42f2: e9ff: fe5c: b5bd / 64 scopelink
inet 192.168.1.118/24 brd 192.168.1.255scope global dynamic enP3p9s0f2
inet6 fd00:1:1:1:42f2:e9ff:fe5c:b5be/64scope global dynamic
inet6 fe80 :: 42f2: e9ff: fe5c: b5be / 64 scopelink
inet 192.168.1.23/24 brd 192.168.1.255scope global br0
inet6 fe80 :: 42f2: e9ff: fe5c: b5bf / 64 scopelink
inet 192.168.122.1/24 brd 192.168.122.255scope global virbr0
9:vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast masterbr0 state UNKNOWN qlen 500
inet6fe80::fc54:ff:fe87:d8a/64 scope link
The purpose of writing this article: 23 server has four network cards are inserted cable and connect the switch to assign addresses automatically restart. But I found .23ping nowhere. The reason is that the routing table main table, multiple routes by the rules, 23 of this IP is br0 IP, Article IV, is not a priority matched in the rules table. How routing table with route network but nowhere export article, will give priority to the first match. 23 so unreasonable. The routing table as follows:
[Root @ REDOS-LE-23 cjxlvdir] # route -n
KernelIP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 100 0 0 enP3p9s0f0
0.0.0.0 192.168.1.1 0.0.0.0 UG 101 0 0 enP3p9s0f2
0.0.0.0 192.168.1.1 0.0.0.0 UG 102 0 0 enP3p9s0f1
0.0.0.0 192.168.1.1 0.0.0.0 UG 425 0 0 br0
169.254.0.0 0.0.0.0 255.255.0.0 In 1006 0 0 br0
169.254.0.0 0.0.0.0 255.255.0.0 In 1008 0 0 br0
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 enP3p9s0f2
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0enP3p9s0f1
192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 enP3p9s0f0
0.0.0.0 192.168.1.0 255.255.255.0 In 425 0 0 br0
192.168.122.0 255.255.255.0 0.0.0.0 U 0 0 0 virbr0
Detailed output routing table:
The first line: 0.0.0.0 192.168.1.1 0.0.0.0 UG 100 0 0 enP3p9s0f0
Description: The purpose is to indicate data transfer access Internet, by the interface enP3p9s0f0, will send packets to the gateway 192.168.1.1
The fifth line: 169.254.0.0 0.0.0.0 255.255.0.0 U 1006 0 0 br0
Description: indicates the network address of 169.254.0.0 the machine is located, if the data transfer destination is a communication within the LAN, the packet may be forwarded directly through br0
Seventh line: 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 enP3p9s0f2
Description: indicates the network address of 192.168.1.0 the machine is located, if the data transfer destination is a communication within the LAN, the packet may be forwarded directly through enP3p9s0f2
Eleventh row: 192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
Description: indicates the network where the host address 192.168.122.0, if the data transfer destination is a communication within the LAN, the packet may be forwarded directly through virbr0;
Reflection 2: This route -n command is not on the table to check this information ip route list table main? Yes
The solution is: the four card assigned to four different routing table, and four tables before main table, the specific methods are as follows
Step 1: NIC f0, f1, f2, br0 new routing table rules
[root@RedOS-23 all]# echo"210 f0table" >> /etc/iproute2/rt_tables
[root@RedOS-23 all]# echo"220 f1table" >>/etc/iproute2/rt_tables
[root@RedOS-23 all]# echo"230 f2table" >>/etc/iproute2/rt_tables
[root@RedOS-23 all]# echo"240 br0table" >>/etc/iproute2/rt_tables
After the success of the new check rule table
[root@RedOS-23 all]# cat /etc/iproute2/rt_tables
#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
# 1 inr.ruhep
210 f0table
220 f1table
230 f2table
240 br0table
View the list of rules, there is no new rule table Oh!
# ip rule list
0: from all lookup local
32766: from all lookup main
32767: from all lookup default
Step 2: add rules to different routing tables, to take effect after the restart of the rc.local.
[root@RedOS-LE-23all]# cat <<EOL >> /etc/rc.local
> ip routeadd 192.168.1.0/24 dev enP3p9s0f0 src 192.168.1.150 table f0table
> ip route add 192.168.1.0/24 dev enP3p9s0f1 src 192.168.1.104 table f1table
> ip route add 192.168.1.0/24 dev enP3p9s0f2 src 192.168.1.118table f2table
> ip routeadd 192.168.1.0/24 dev br0 src 192.168.1.23 table br0table
>
> ip routeadd default dev enP3p9s0f0 via 192.168.1.1 table f0table
> ip routeadd default dev enP3p9s0f1 via192.168.1.1 table f1table
> ip routeadd default dev enP3p9s0f2 via192.168.1.1 table f2table
> ip routeadd default dev br0 via 192.168.1.1 table br0table
>
> ip ruleadd from 192.168.1.150 table f0table
> ip ruleadd from 192.168.1.104 table f1table
> ip ruleadd from 192.168.1.118 table f2table
> ip ruleadd from 192.168.1.23 table br0table
> EOL
After executing the above command, and then view the rule table
# ip rule list
0: from all lookup local
32762: from 192.168.1.23 lookup br0table
32763: from 192.168.1.118 lookup f2table
32764: from 192.168.1.104 lookup f1table
32765: from 192.168.1.150 lookup f0table
32766: from all lookup main
32767: from all lookup default
Step 3: Run the following commands
echo 1 > /proc/sys/net/ipv4/conf/all/arp_filter
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
Or write to boot from the startup file:
# cat <<EOL>> /etc/rc.local
> echo 1 >/proc/sys/net/ipv4/conf/all/arp_filter
> echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
> echo 1 >/proc/sys/net/ipv4/conf/all/arp_ignore
> EOL
Step 4: restart the server reboot
Step 5: ping118 \ 23 \ 104 \ 150 can pass.
Another problem is the phenomenon after the restart the server, f0 \ f1 \ f2 address can ping all of, br0 IP is 192.168.1.23,23 of life and death do not pass, you must do what ping192.168.1.1 -I br0, before it can pass. what is the reason?