同台机器2个网卡配置同段IP
2016-03-09 15:30
441 查看
看个例子:
1.on server
ifconfig eth4 192.168.1.10/24 up
ifconfig eth5 192.168.1.11/24 up
2.on client
ifconfig eth4 192.168.1.20/24 up
3.on client
ping 192.168.1.10 -c 3
ping 192.168.1.11 -c 3
Actual results:
[root@client ~]# arp
Address HWtype HWaddress Flags Mask Iface
192.168.1.11 ether 00:1B:21:4A:FE:98 C eth4 <===== 错了吧?
192.168.1.10 ether 00:1B:21:4A:FE:98 C eth4
Expected results:
[root@client ~]# arp
Address HWtype HWaddress Flags Mask Iface
192.168.1.11 ether 00:1B:21:4A:FE:99 C eth4
192.168.1.10 ether 00:1B:21:4A:FE:98 C eth4
Additional info:
23:28:23.272726 arp reply 192.168.1.10 is-at 00:1b:21:4a:fe:99 (oui Unknown)
23:28:23.272783 arp reply 192.168.1.10 is-at 00:1b:21:4a:fe:98 (oui Unknown)
23:28:46.750823 arp reply 192.168.1.11 is-at 00:1b:21:4a:fe:99 (oui Unknown)
23:28:46.750850 arp reply 192.168.1.11 is-at 00:1b:21:4a:fe:98 (oui Unknown)
这个问题是是由Linux的路由和arp机制造成的,主要是路由。
在Linux中,IP地址是主机的属性,而不是接口的属性。
这就造成在反向路由查找时,可以考虑包进入的接口,也可以不考虑。
此时arp请求包会有两个应答,client会选择后一个。
关键是server会接着发一个arp请求,并且始终从eth4发出来(因为eth4的路由在前边),
这样client在应该该arp请求时,又会更新arp表。
所以我们在client上看到arp表中始终是eth4的mac。
解决方法:
1 echo 1 > /proc/sys/net/ipv4/conf/all/arp_filter
2 ip route add 192.168.1.20/32 nexthop via 192.168.1.10 weight 1 nexthop via 192.168.1.11 weight 1
这里,添加的新路由的作用是以192.168.1.20作为目标地址进行反向路由检查时,依次循环选择eth4和eth5。
而arp_filter的作用是,只有通过了反向路由检查的包才会发出去。
1.on server
ifconfig eth4 192.168.1.10/24 up
ifconfig eth5 192.168.1.11/24 up
2.on client
ifconfig eth4 192.168.1.20/24 up
3.on client
ping 192.168.1.10 -c 3
ping 192.168.1.11 -c 3
Actual results:
[root@client ~]# arp
Address HWtype HWaddress Flags Mask Iface
192.168.1.11 ether 00:1B:21:4A:FE:98 C eth4 <===== 错了吧?
192.168.1.10 ether 00:1B:21:4A:FE:98 C eth4
Expected results:
[root@client ~]# arp
Address HWtype HWaddress Flags Mask Iface
192.168.1.11 ether 00:1B:21:4A:FE:99 C eth4
192.168.1.10 ether 00:1B:21:4A:FE:98 C eth4
Additional info:
23:28:23.272726 arp reply 192.168.1.10 is-at 00:1b:21:4a:fe:99 (oui Unknown)
23:28:23.272783 arp reply 192.168.1.10 is-at 00:1b:21:4a:fe:98 (oui Unknown)
23:28:46.750823 arp reply 192.168.1.11 is-at 00:1b:21:4a:fe:99 (oui Unknown)
23:28:46.750850 arp reply 192.168.1.11 is-at 00:1b:21:4a:fe:98 (oui Unknown)
这个问题是是由Linux的路由和arp机制造成的,主要是路由。
在Linux中,IP地址是主机的属性,而不是接口的属性。
这就造成在反向路由查找时,可以考虑包进入的接口,也可以不考虑。
此时arp请求包会有两个应答,client会选择后一个。
关键是server会接着发一个arp请求,并且始终从eth4发出来(因为eth4的路由在前边),
这样client在应该该arp请求时,又会更新arp表。
所以我们在client上看到arp表中始终是eth4的mac。
解决方法:
1 echo 1 > /proc/sys/net/ipv4/conf/all/arp_filter
2 ip route add 192.168.1.20/32 nexthop via 192.168.1.10 weight 1 nexthop via 192.168.1.11 weight 1
这里,添加的新路由的作用是以192.168.1.20作为目标地址进行反向路由检查时,依次循环选择eth4和eth5。
而arp_filter的作用是,只有通过了反向路由检查的包才会发出去。
相关文章推荐
- map到bean的双向转换
- css-before 和 after的妙用
- 网卡回归传统的命名方式
- git 和 phabricator arc 常用 命令解析
- 表格中显示数据
- 批量更新zabbix中的主机名
- mybatis-generator 代码自动生成工具
- memcache和redis区别
- List、Map、Set三个接口,存取元素时,各有什么特点?
- Unable to resolve target 'android-XX'解决办法
- TCP (上)
- Android Studio导入eclipse项目乱码问题
- 分布式数据库
- 安装Xcode插件包管理器Alcatraz报错解决办法
- 组合控件1—— 设置框
- 组合控件2——海贼王选项菜单
- 8.Smack类库
- 作业一
- 【JavaScript】ReactJS&NodeJS了解资料
- “内存对界”原理——数据是如何对齐的