mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
As shown in the following example, ifupdown1 sets the default route with the onlink attribute. This patch will add this capability to ifupdown2 controlled by a policy variable in the address module: "l3_intf_default_gateway_set_onlink" default to on [19:16:07] root:~ # cat /etc/network/interfaces auto lo iface lo inet loopback auto enp0s3 iface enp0s3 inet static address 78.46.193.234/32 gateway 172.31.1.1 [19:16:19] root:~ # ifup -a -v ifup: configuring interface enp0s3=enp0s3 (inet) ... /bin/ip addr add 78.46.193.234/255.255.255.255 broadcast 78.46.193.234 dev enp0s3 label enp0s3 /bin/ip link set dev enp0s3 up /bin/ip route add default via 172.31.1.1 dev enp0s3 onlink ... [19:16:21] root:~ # ip route show default via 172.31.1.1 dev enp0s3 onlink 10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15 169.254.0.0/16 dev enp0s3 scope link metric 1000 [19:16:21] root:~ # $ cat /etc/network/ifupdown2/policy.d/address.json { "address": { "module_globals": { "l3_intf_default_gateway_set_onlink": "yes" } } } $ ifquery swp1 auto swp1 iface swp1 inet static address 78.46.193.234/32 gateway 172.31.1.1 $ ifreload -av |& grep "route add default" info: executing /bin/ip route add default via 172.31.1.1 proto kernel dev swp1 onlink $ $ $ emacs -nw /etc/network/ifupdown2/policy.d/address.json $ cat /etc/network/ifupdown2/policy.d/address.json { "address": { "module_globals": { "l3_intf_default_gateway_set_onlink": "no" } } } $ ifdown -a -X eth0 $ ifreload -av |& grep "route add default" info: executing /bin/ip route add default via 172.31.1.1 proto kernel dev swp1 $ Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>