Networking 无法使用netplan和cloud init复制ECMP设置

Networking 无法使用netplan和cloud init复制ECMP设置,networking,cloud-init,netplan,Networking,Cloud Init,Netplan,我有两个接口(eth0和eth1),它们位于各自的子网(11.0.0.0/24和11.0.1.0/24)和网关(11.0.0.1和11.0.1.1)中。我希望以这样一种方式配置ECMP:来自主机的所有通信量在两个接口之间平均分布。我使用以下ip命令使其工作: # Setting up default gateways for the two interfaces ip route add 11.0.0.0/24 dev eth0 src 11.0.0.4 table rt1 ip route

我有两个接口(eth0和eth1),它们位于各自的子网(11.0.0.0/24和11.0.1.0/24)和网关(11.0.0.1和11.0.1.1)中。我希望以这样一种方式配置ECMP:来自主机的所有通信量在两个接口之间平均分布。我使用以下ip命令使其工作:

# Setting up default gateways for the two interfaces
ip route add 11.0.0.0/24 dev eth0 src 11.0.0.4 table rt1 
ip route add default via 11.0.0.1 table rt1 

ip route add 11.0.1.0/24 dev eth1 src 11.0.1.4 table rt2 
ip route add default via 11.0.1.1 table rt2 

# Adding routes to the main table
ip route add 11.0.0.0/24 dev eth0 src 11.0.0.4 
ip route add 11.0.1.0/24 dev eth1 src 11.0.1.4 

# Setting default route
ip route add default via 11.0.0.1 

# Adding routes
ip rule add from 11.0.0.4 table rt1 
ip rule add from 11.0.1.4 table rt2 

# Adding ECMP route
ip route add default scope global nexthop via 11.0.0.1 dev eth0 weight 1 nexthop via 11.0.1.1 dev eth1 weight 1 
我正在尝试使用cloud init和netplan for Ubuntu18.04 LTS复制此设置。这是我正在使用的配置:

#cloud-config
network:
    version: 2
    ethernets:
        eth0:
            dhcp4: true
            dhcp4-overrides:
                route-metric: 100
            dhcp6: false
            match:
                driver: hv_netvsc
                macaddress: 00:22:48:20:af:fa
            set-name: eth0
            gateway4: 11.0.0.1
            routes:
                - to: 11.0.0.4/32
                  via: 11.0.0.1
                  table: 101
            routing-policy:
                - from: 11.0.0.4/32
                  table: 101
        eth1:
            dhcp4: true
            dhcp4-overrides:
                route-metric: 200
            dhcp6: false
            match:
                driver: hv_netvsc
                macaddress: 00:22:48:20:ab:1c
            set-name: eth1
            gateway4: 11.0.1.1
            routes:
                - to: 11.0.1.4/32
                  via: 11.0.1.1
                  table: 102
            routing-policy:
                - from: 11.0.1.4/32
                  table: 102
runcmd:
    - [sh, -c, 'echo "Adding route tables"']
    - [sh, -c, 'echo "101 rt1" >> /etc/iproute2/rt_tables']
    - [sh, -c, 'echo "102 rt2" >> /etc/iproute2/rt_tables']
    - [sh, -c, 'ip route add default scope global nexthop via 11.0.0.1 dev eth0 weight 1 nexthop via 11.0.1.1 dev eth1 weight 1']

我可能做错了一些非常简单和基本的事情,但这是我第一次使用网络和cloud init,所以我无法找出我做错了什么。谢谢你的帮助

在尝试使用cloud init之前,让netplan配置单独工作可能是值得的。这样就更容易确定问题是出在netplan配置上还是出在cloud init上。