Ubuntu Server VM
Original DHCP Config
/etc/netplan/50-cloud-init.yaml
1 2 3 4 5 6 7 8 9 10 | # 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 version: 2 |
Static
Find the name of your ethernet adaptor. In this case the ethernet adaptor is eth0
1 2 3 4 5 6 7 | 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 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link /ether 00:16:5e:0a:02:0c brd ff:ff:ff:ff:ff:ff 3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default link /ether 01:32:20:42:c2: dc brd ff:ff:ff:ff:ff:ff |
Move the old yaml file out of the way
1 2 3 4 5 6 7 | # as root mv /etc/netplan/50-cloud-init .yaml ~/ # create a new config file vim /etc/netplan/00-config .yaml # modify and enter the config using the example below # make sure the permissions are root only chmod 600 /etc/netplan/00-config .yaml |
Contents of 00-config.yaml
1 2 3 4 5 6 7 8 9 10 11 12 13 | network: version: 2 renderer: networkd ethernets: eth0: dhcp4: no addresses: - 10.73.73.20/24 routes: - to : default via: 10.73.73.254 nameservers: addresses: [ 10.73.73.12 , 10.73.73.9 ] |
Finally generate and apply the netplan policy
1 2 3 | # as root netplan generate netplan apply |
0 Comments