我有基于debian wheezy实例与2个networking接口(主,辅助)。 我的设置stream程:
vim / etc / network / interfaces
auto eth0 iface eth0 inet dhcp auto eth1 iface eth1 inet dhcp
ifup eth1 ifconfig -a
eth0 Link encap:Ethernet HWaddr 0a:1e:17:4a:dc:0a inet addr:172.31.7.189 Bcast:172.31.15.255 Mask:255.255.240.0 inet6 addr: fe80::81e:17ff:fe4a:dc0a/64 Scope:Link eth1 Link encap:Ethernet HWaddr 0a:74:e6:54:ba:c9 inet addr:172.31.10.172 Bcast:172.31.15.255 Mask:255.255.240.0 inet6 addr: fe80::874:e6ff:fe54:bac9/64 Scope:Link inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host
好的,这一点都很好,两个私人ips(172.31.7.189,172.31.10.172)都可以ping通。
echo“200 out”>> / etc / iproute2 / rt_tables
# reserved values # 255 local 254 main 253 default 0 unspec # # local # #1 inr.ruhep 200 out
路线-n
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 172.31.0.1 0.0.0.0 UG 0 0 0 eth0 169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0 172.31.0.0 0.0.0.0 255.255.240.0 U 0 0 0 eth0 172.31.0.0 0.0.0.0 255.255.240.0 U 0 0 0 eth1
ip route添加默认通过172.31.0.1 dev eth1表出来
ip规则从172.31.0.0/20表中添加出来
Write failed: Broken pipe
现在实例不能通过SSH访问。 请帮助,我做错了什么?
我的工作stream程基于教程https://www.lisenet.com/2014/create-and-attach-a-second-elastic-network-interface-with-eip-to-ec2-vpc-instance/comment-page- 1 /#评论-105
问题解决了。
我试图为整个networking172.31.0.0/20定义ip规则,这是错误的。
当我使用私人IP从辅助networking接口都工作正常。
ip route add default via 172.31.10.172 dev eth1 table out ip rule add from 172.31.10.172 table out
其中172.31.10.172是来自networking接口eth1的私有IP
而不是“ip规则从172.31.0.0/20表添加…”
PS非常感谢Tomas Nevar