We can configure IP Addresses on Ubuntu 18.04 using Netplan while adding an IP Address in the older versions is a different method.
Ubuntu 18.04 uses Netplan to configure IP Addresses. Therefore, we will use a YAML file instead of the /etc/sysconfig/network-interface to add IP Addresses.
You will find the default configuration in the /etc/netplan/ directory.
1. Find the default network configuration file using this command -
$ ls /etc/netplan/
2. It is a default network configuration YAML file.
Open it using this command –
$ cat /etc/netplan/50-cloud-init.yaml
3. You will see the ethernet card (enp0s1); you must configure the IP Address here.
4. Take the backup of the 50-cloud-init.yaml file before making any changes.
$ sudo cp /etc/netplan/50-cloud-init.yaml /etc/netplan/50-cloud-init.yaml.bak
5. Configure IP Address on ethernet card (enp0s1) using the below details –
- IP address for enp0s1: 192.168.0.1 (your IP Address)
- Gateway: 192.168.0.0
- Netmask: 255.255.255.0
- DNS servers: 8.8.8.8 and 8.8.4.4.
6. You can use space to make the alignment as per the shown image -
7. Save the file using Ctrl + x.
8. Apply the network configuration using this command –
$ sudo netplan apply
9. Check your IP Address with this command –
$ ip addr