无法ping通辅助接口专用IP

时间:2018-11-14 12:33:22

标签: amazon-web-services amazon-ec2

我已将辅助接口附加到Debian EC2实例。我附加了与主接口相同的安全组,并允许对其执行ping操作。 问题是连接第二个网络接口后,我无法ping通辅助接口的专用IP。

eth0      Link encap:Ethernet  HWaddr 0a:65:1c:fd:cd:f0  
          inet addr:10.195.0.76  Bcast:10.195.0.95  Mask:255.255.255.224
          inet6 addr: fe80::865:1cff:fefd:cdf0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:9001  Metric:1
          RX packets:1494 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1158 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:164133 (160.2 KiB)  TX bytes:185670 (181.3 KiB)

eth1      Link encap:Ethernet  HWaddr 0a:2d:a1:fc:f5:d4  
          inet addr:10.195.0.82  Bcast:10.195.0.95  Mask:255.255.255.224
          inet6 addr: fe80::82d:a1ff:fefc:f5d4/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:9001  Metric:1
          RX packets:274 errors:0 dropped:0 overruns:0 frame:0
          TX packets:46 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:24474 (23.9 KiB)  TX bytes:2948 (2.8 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Ngrep结果从其他接口执行ping操作

root@ip-10-195-0-76:/home/admin# ngrep -d eth1 -Wbyline
interface: eth1 (10.195.0.64/255.255.255.224)
#
I fe80::81a:8eff:fe7b:e6a9 -> ff02::1 134:0
@.............
..{....@.............*....to.........
#
I 10.195.1.30 -> 10.195.0.82 8:0
\......[.....X
..................... !"#$%&'()*+,-./01234567
#
I 10.195.1.30 -> 10.195.0.82 8:0
\......[......
..................... !"#$%&'()*+,-./01234567

1 个答案:

答案 0 :(得分:0)

AWS中的Debian确实提供了ec2-net-utils,但EC2上的脚本未添加辅助接口的路由。为了解决这个问题,我遵循以下步骤为接口添加路由。

#echo "200 out" >>/etc/iproute2/rt_tables
# ip route add default via 10.195.0.65 dev eth1 table out
#ip route show table out
#ip rule add from 10.195.0.82/32 table out
#ip rule add to 10.195.0.82/32 table out

然后,我可以ping通网络接口。