linux下多网卡配置同网段IP的问题以及解决方法

本文解决了一台Linux服务器上配置双网卡同网段IP所遇到的问题,包括ARP响应单一MAC地址及非默认路由网卡的外部IP不通等问题。通过将两块网卡分配到不同的路由表中实现了有效解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

linux下多网卡配置同网段IP的问题以及解决方法


在一台linux上安装了双网卡,并分别配置了同网段的两个IP, 两块网卡分别连接了网线接到同一个交换机上.


问题:
1. 从其他内网机器ping两个IP都通,但是arp -a两个IP都是eth0的mac 
2. 默认路由是走其中某一块网卡,如果两个内网IP分别做1to1 NAT, 则不是默认路由的那块网卡外网IP不通。




解决方法: 把2块网卡分到2个不同的路由表中如下。  或者把两块网卡集束为一块网卡使用。


My MC:
eth0: 10.110.6.79
eth1: 10.110.6.81
Netmask: 255.255.255.0
gateway: 10.110.6.1




Please run the following four commands to adjust the route table of MC:
[root@Controller ~]# echo "210    eth0table" >> /etc/iproute2/rt_tables
[root@Controller ~]# echo "220    eth1table" >> /etc/iproute2/rt_tables
[root@Controller ~]# cat <<EOL >> /etc/rc.local 
ip route add 10.110.6.0/24 dev eth0 src 10.110.6.79 table eth0table
ip route add 10.110.6.0/24 dev eth1 src 10.110.6.81 table eth1table
ip route add default dev eth0 via 10.110.6.1 table eth0table
ip route add default dev eth1 via 10.110.6.1 table eth1table
ip rule add from 10.110.6.79 table eth0table
ip rule add from 10.110.6.81 table eth1table
EOL
[root@Controller ~]# reboot






Ref:
http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=1622182&page=1
http://bbs.chinaunix.net/thread-2128565-1-1.html
http://www.cnblogs.com/zelos/archive/2012/02/12/2348023.html
http://blog.chinaunix.net/uid-21977330-id-3745750.html
http://www.jb51.net/LINUXjishu/34042.html
http://blog.sina.com.cn/s/blog_602f87700102uzpb.html
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值