我有一个 ec2 AmazonLinux2 实例。它在 eth0 上有一个主网卡。我继续并附加了另一个eni(带有关联的公共IP)eth1。我想确保我也可以通过 eth1 发送流量,但不能。
curl --interface eth0 ifconfig.me --> Works, returns the public ip of the instance
curl --interface eth1 ifconfig.me --> Does not work, the call just hangs
这是我的界面
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc pfifo_fast state UP group default qlen 1000
link/ether 02:82:39:f5:b2:61 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.156/23 brd 192.168.1.255 scope global dynamic eth0
valid_lft 2293sec preferred_lft 2293sec
inet6 fe80::82:39ff:fef5:b261/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc pfifo_fast state UP group default qlen 1000
link/ether 02:85:86:84:a8:1b brd ff:ff:ff:ff:ff:ff
inet 192.168.0.8/23 brd 192.168.1.255 scope global eth1
valid_lft forever preferred_lft forever
inet6 fe80::85:86ff:fe84:a81b/64 scope link
valid_lft forever preferred_lft forever
路由表
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
169.254.169.254 0.0.0.0 255.255.255.255 UH 0 0 0 eth0
192.168.0.0 0.0.0.0 255.255.254.0 U 0 0 0 eth0
这是我添加静态路由的步骤
- echo 2 mytable >> /etc/iproute2/rt_tables
- sudo ip route add default via 192.168.0.1 dev eth1 table mytable
- sudo ip rule add from 192.168.0.8 lookup mytable prio 1000
- ip route 刷新表缓存
我在这里看到了各种帖子,其中强调了做同样事情的不同方法,但我尝试过它们都是徒劳的。有人可以帮我解决这里发生的事情吗
这些步骤的灵感来自帖子http://www.rjsystems.nl/en/2100-adv-routing.php。
谢谢凯