This article was written by Xilinx engineer Davis Zhang


This problem is determined by the way the Linux Kernel TCP/IP Stack handles the IP of the same subnet. Strictly speaking, it is a common Linux problem, not AMD-Xilinx Device, IP or Driver.


When the IP addresses of eth0 and eth1 are in the same subnet, the TCP/IP stack will select a MAC as the master, and the ping packets received by eth0 and eth1 will send return packets through this master MAC. Generally speaking, which MAC is enabled first by ifconfig, it is the main MAC. For example, eth0 is the main MAC. At this time, you can ping the IP of eth1 through the network cable of eth0, and the returned packet is also sent directly through eth0, that is to say, the ping packet to the IP of eth1 will not be received on eth1, nor will it be sent through it, the stack directly Respond and send via eth0. At this time, if a ping packet to the eth1 IP is sent through the network cable of eth1, eth1 can receive it, but the stack will still send the return packet through eth0, and the phenomenon is that the ping fails.

If the IPs of eth0 and eth1 are not in the same subnet, such as 192.168.1.10/192.168.2.10, there will be no such problems. It is generally not recommended to use the same subnet for multiple MACs in linux, and some vendors even prohibit this.

https://access.redhat.com/solutions/30564
https://www.ibm.com/support/pages/node/6466713

If you really need to use the same subnet, you can refer to the following method to reset the route.

//the below steps redirects packets meant to be output from eth0 to properly exit from eth1. 


//enable support for multiple routing tables in kernel config. 


Kernel Configuration 


 → Networking support → Networking options 


[*] IP: advanced router 


[*] IP: policy routing 

CONFIG_IP_ADVANCED_ROUTER 


CONFIG_IP_MULTIPLE_TABLES 


 //type below command in linux console 


echo -ne 0 > /proc/sys/net/ipv4/conf/all/rp_filter 

echo -ne 0 > /proc/sys/net/ipv4/conf/eth0/rp_filter echo -ne 0 > /proc/sys/net/ipv4/conf/eth1/rp_filter


//For proper functionality ie ARP replies from eth1 to get generated when both eth0 and eth1 are in same subnet

echo -ne 0 > /proc/sys/net/ipv4/conf/all/arp_filterecho -ne 2 > /proc/sys/net/ipv4/conf/all/arp_ignoreecho -ne 0 > /proc/sys/net/ipv4/ conf/eth0/arp_filterecho -ne 2 > /proc/sys/net/ipv4/conf/eth0/arp_ignoreecho -ne 0 > /proc/sys/net/ipv4/conf/eth1/arp_filterecho -ne 2 > /proc/sys/ net/ipv4/conf/eth1/arp_ignore


//Create a table called "new_rt_table" and create a routing rule that says any packet with a mark equal to '1' gets routed according to the "new_rt_table"(can name it whatever you want) table. The file /etc/iproute2 /rt_tables is the only source of table names on the system. Internally, routing tables have integer identifiers.


echo 1 new_rt_table >> /etc/iproute2/rt_tables 

ip rule add from all fwmark 1 table new_rt_table 


//setup the "new_rt_table" table to route the packets via eth1 

ip route add default dev eth1 table new_rt_table 

ip route show table new_rt_table 


//mark packets so that 'ip route' can route it through eth1 

iptables -F -t mangle 

iptables -t mangle -I OUTPUT -so eth0 -j MARK --set-mark 1

picture