使用 nmcli 设置的路由似乎无法正常工作

使用 nmcli 设置的路由似乎无法正常工作

我有一个 ec2 实例,其中连接了 2 个接口(ens5 和 ens6),它们都使用同一个子网。ens6 分配了一个私有 IP 以及 eip。我正在尝试路由出这个接口,但似乎一切都通过 ens5 路由。以下是各个部分的片段。如能得到任何帮助,我将不胜感激。

ifconfig
ens5: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9001
        inet 10.242.41.36  netmask 255.255.255.192  broadcast 10.242.41.63
        inet6 fe80::4626:2ea:517d:fed5  prefixlen 64  scopeid 0x20<link>
        ether 02:aa:30:b3:3d:2d  txqueuelen 1000  (Ethernet)
        RX packets 171307  bytes 58509075 (55.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 167725  bytes 39447817 (37.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens6: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9001
        inet 10.242.41.34  netmask 255.255.255.255  broadcast 10.242.41.34
        inet6 fe80::2243:8d6d:2bae:6767  prefixlen 64  scopeid 0x20<link>
        ether 02:34:ed:01:70:e3  txqueuelen 1000  (Ethernet)
        RX packets 3398  bytes 239349 (233.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1255  bytes 69227 (67.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 67  bytes 15823 (15.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 67  bytes 15823 (15.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
nmcli d show
GENERAL.DEVICE:                         ens5
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         02:AA:30:B3:3D:2D
GENERAL.MTU:                            9001
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     Wired connection 1
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/1
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS[1]:                         10.242.41.36/26
IP4.GATEWAY:                            10.242.41.1
IP4.ROUTE[1]:                           dst = 0.0.0.0/0, nh = 10.242.41.1, mt = 100
IP4.ROUTE[2]:                           dst = 10.242.41.0/26, nh = 0.0.0.0, mt = 100
IP4.DNS[1]:                             10.242.0.2
IP4.DOMAIN[1]:                          ec2.internal
IP6.ADDRESS[1]:                         fe80::4626:2ea:517d:fed5/64
IP6.GATEWAY:                            --
IP6.ROUTE[1]:                           dst = fe80::/64, nh = ::, mt = 100
IP6.ROUTE[2]:                           dst = ff00::/8, nh = ::, mt = 256, table=255

GENERAL.DEVICE:                         ens6
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         02:34:ED:01:70:E3
GENERAL.MTU:                            9001
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     Wired connection 2
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/3
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS[1]:                         10.242.41.34/32
IP4.ADDRESS[2]:                         10.242.41.34/26
IP4.GATEWAY:                            --
IP4.ROUTE[1]:                           dst = 0.0.0.0/0, nh = 10.242.41.1, mt = 101, table=6
IP4.ROUTE[2]:                           dst = 10.242.41.34/32, nh = 0.0.0.0, mt = 101, table=6
IP4.ROUTE[3]:                           dst = 10.242.41.1/32, nh = 0.0.0.0, mt = 101, table=6
IP4.ROUTE[4]:                           dst = 10.242.41.0/26, nh = 0.0.0.0, mt = 101, table=6
IP4.ROUTE[5]:                           dst = 10.242.41.34/32, nh = 10.242.41.1, mt = 101, table=6
IP4.DNS[1]:                             10.242.0.2
IP4.DOMAIN[1]:                          ec2.internal
IP6.ADDRESS[1]:                         fe80::2243:8d6d:2bae:6767/64
IP6.GATEWAY:                            --
IP6.ROUTE[1]:                           dst = fe80::/64, nh = ::, mt = 101
IP6.ROUTE[2]:                           dst = ff00::/8, nh = ::, mt = 256, table=255
 ip route
default via 10.242.41.1 dev ens5 proto dhcp metric 100 
10.242.41.0/26 dev ens5 proto kernel scope link src 10.242.41.36 metric 100 

When i try curl

curl -sm 1 --interface 10.242.41.34 ifconfig.me

It should route through ens6 but tcpdump shows its hitting the ifconfig.me IP on ens5

 tcpdump -i ens5 | grep 34.117.118.44
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ens5, link-type EN10MB (Ethernet), capture size 262144 bytes
16:45:18.606346 IP ip-10-242-0-2.ec2.internal.domain > 10.242.41.36.51122: 49697 1/0/0 A 34.117.118.44 (45)
16:45:19.225099 IP ip-10-242-0-2.ec2.internal.domain > 10.242.41.36.60908: 49910 1/0/0 A 34.117.118.44 (45)
16:45:28.655622 IP ip-10-242-0-2.ec2.internal.domain > 10.242.41.36.49994: 23561 1/0/0 A 34.117.118.44 (45)
16:45:29.982263 IP ip-10-242-0-2.ec2.internal.domain > 10.242.41.36.53613: 38412 1/0/0 A 34.117.118.44 (45)

相关内容