How To Static IP Ubuntu 18.04 Bionic Beaver

image_pdfimage_print

Step 1: Set static IP address

1.1 List Netplan to see name of the configuration file

cd /etc/netplan/

ls
steken@srv6:~$ cd /etc/netplan/
steken@srv6:/etc/netplan$ ls
50-cloud-init.yaml
steken@srv6:/etc/netplan$

1.2.a Open the 50-cloud-init.yaml configuration file

sudo nano /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:
    ethernets:
        ens160:
            addresses: []
            dhcp4: true
    version: 2

1.2.b Edit the configuration file with your IP network parameters

# 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
    renderer: networkd
    ethernets:
        ens160:
            dhcp4: false
            addresses: [192.168.100.16/24]
            gateway4: 192.168.100.1
            nameservers:
               addresses: [192.168.100.11,8.8.8.8]

Exit and Save

Step 2: Apply Netplan configuration

2.1 Apply settings

sudo netplan apply

2.2 Optional: Debug the netplan apply command

sudo netplan --debug apply

2.3 Reconnect to the server with new IP

Step 3: Verify Connectivity

3.1 Check IP address

ifconfig

3.2 Check default route

sudo route -n

3.3 Check internet connectivity

sudo ping 8.8.8.8

3.4 Check DNS

sudo ping www.google.com
image_pdfimage_print

Donate