netplan ( ubuntu on AWS )
more /etc/netplan/50-cloud-init.yaml | |
---|---|
default config | |
netplan try netplan apply | |
changes | change netplan ubuntu@ip-10-0-11-132:~$ ip link 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 0a:0a:b0:22:e4:a8 brd ff:ff:ff:ff:ff:ff 3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 link/ether 0a:fe:87:e3:4c:de brd ff:ff:ff:ff:ff:ff >>>> New interface and Mac@: 0a:fe:87:e3:4c:de network: version: 2 ethernets: eth0: dhcp4: true match: macaddress: 0a:0a:b0:22:e4:a8 set-name: eth0 eth1: dhcp4: true match: macaddress: 0a:fe:87:e3:4c:de set-name: eth1 |
apply changes | sudo netplan try |
static route | |
add another file ( > 50.xxx) | Â Â routes: Â Â - to: 10.0.0.0/8 Â Â via: 10.0.10.4 |
static route root@Ubuntu-VMx5:/etc/netplan# more 50-cloud-init.yaml # This file is generated from information provided by the datasource. Changes # to it will not persist across an instance reboot. To disable cloud-init's # network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} network: ethernets: eth0: dhcp4: true dhcp4-overrides: route-metric: 100 dhcp6: false match: driver: hv_netvsc macaddress: 00:0d:3a:d6:19:e5 set-name: eth0 eth1: dhcp4: true dhcp4-overrides: route-metric: 200 dhcp6: false match: driver: hv_netvsc macaddress: 00:22:48:01:23:85 set-name: eth1 version: 2 root@Ubuntu-VMx5:/etc/netplan# | |
static route root@Ubuntu-VMx5:/etc/netplan# ls -al total 20 drwxr-xr-x 2 root root 4096 Apr 21 14:15 . drwxr-xr-x 101 root root 4096 Apr 21 08:15 .. -rw-r--r-- 1 root root 855 Apr 21 14:09 50-cloud-init.yaml -rw-r--r-- 1 root root 855 Apr 21 13:12 50-cloud-init.yaml.backup -rw-r--r-- 1 root root 451 Apr 21 14:15 80-static-route.yaml root@Ubuntu-VMx5:/etc/netplan# more 80-static-route.yaml # This file is generated from information provided by the datasource. Changes # to it will not persist across an instance reboot. To disable cloud-init's # network configuration capabilities, write a file # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following: # network: {config: disabled} network: ethernets: eth1: routes: - to : 10.0.0.0/8 via: 10.0.10.4 version: 2 root@Ubuntu-VMx5:/etc/netplan# |