Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.



more /etc/netplan/50-cloud-init.yaml
default config


Code Block
titlecode
collapsetrue
ubuntu@ip-10-0-11-132:~$ more /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# 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:
    version: 2
    ethernets:
        eth0:
            dhcp4: true
            match:
                macaddress: 0a:0a:b0:22:e4:a8
            set-name: eth0



Image Added

netplan try

netplan apply

changes


Code Block
titlechange 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


Code Block
titlenetplan try
collapsetrue
ubuntu@ip-10-0-11-132:~$ sudo netplan try
Warning: Stopping systemd-networkd.service, but it can still be activated by:
  systemd-networkd.socket
Do you want to keep these settings?


Press ENTER before the timeout to accept the new configuration


Changes will revert in 113 seconds
Configuration accepted.



ubuntu@ip-10-0-11-132:~$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc fq_codel state UP group default qlen 1000
    link/ether 0a:0a:b0:22:e4:a8 brd ff:ff:ff:ff:ff:ff
    inet 10.0.11.132/24 brd 10.0.11.255 scope global dynamic eth0
       valid_lft 3588sec preferred_lft 3588sec
    inet6 fe80::80a:b0ff:fe22:e4a8/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc fq_codel state UP group default qlen 1000
    link/ether 0a:fe:87:e3:4c:de brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.31/24 brd 10.0.2.255 scope global dynamic eth1
       valid_lft 3588sec preferred_lft 3588sec
    inet6 fe80::8fe:87ff:fee3:4cde/64 scope link
       valid_lft forever preferred_lft forever


apply changes
sudo netplan try


static route
add another file ( > 50.xxx)   routes:
   - to: 10.0.0.0/8
   via: 10.0.10.4


Code Block
titlestatic 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# 




Code Block
titlestatic 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#