是的,可以遵循David Schwartz的建议:
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/eth3/rp_filter
//为了获得适当的功能,即当eth0和eth1都在同一个子网中时,ARP从eth1答复生成
echo -ne 0 > /proc/sys/net/ipv4/conf/all/arp_filter
echo -ne 2 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo -ne 0 > /proc/sys/net/ipv4/conf/eth0/arp_filter
echo -ne 2 > /proc/sys/net/ipv4/conf/eth0/arp_ignore
echo -ne 0 > /proc/sys/net/ipv4/conf/eth1/arp_filter
echo -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
//设置“ new_rt_table”表以通过eth1路由数据包
ip route add default dev eth1 table new_rt_table
ip route show table new_rt_table
//标记数据包,以便“ ip route”可以将其路由到eth1
iptables -F -t mangle
iptables -t mangle -I OUTPUT -s <ip addr of eth1> -o eth0 -j MARK --set-mark 1
//在内核配置中启用对多个路由表的支持。
内核配置
→网络支持→网络选项
[*] IP:高级路由器
[*] IP:策略路由
CONFIG_IP_ADVANCED_ROUTER
CONFIG_IP_MULTIPLE_TABLES
//以上步骤将要从eth0输出的数据包重定向到从eth1正确退出的位置。
如果有人可以使用,请提出其他建议。