When you install Ubuntu server, its network setting defaults to dynamic IP addressing, that is, the network management daemon in Ubuntu searches for a DHCP server on the connected network and configures the network with the IP address assigned by DHCP. Even when you start an instance in the cloud, the network is configured with dynamic addressing using the DHCP server setup by the cloud service provider. In this chapter, you will learn how to configure the network interface with static IP assignment.
Follow these steps to connect to the network with a static IP:
Step 1 : Open /etc/netplan/50-cloud-init.yaml and find the following lines:
Step 2 : Change the preceding lines to add an IP address, net mask, and default gateway (replace samples with the respective values):
addresses: [192.168.1.80/24] gateway4: 192.168.1.1 nameservers: addresses: [126.96.36.199,188.8.131.52] dhcp4: no
Step 3 : Then run sudo netplan apply
sudo netplan apply
Step 4 : Try to ping a remote host to test the network connection