Skip to content

Latest commit

 

History

History
52 lines (38 loc) · 926 Bytes

set_static_ip_ubuntu18.md

File metadata and controls

52 lines (38 loc) · 926 Bytes

1. Check ethenets.

$ ls /sys/class/net
enp0s31f6  lo

enp0s31f6 is the ethernet to be set.

2. Change /etc/netplan/50-cloud-init.yaml

sudo vim /etc/netplan/50-cloud-init.yaml

Then, change /etc/netplan/50-cloud-init.yaml like the followings:

network:
    ethernets:
        enp0s31f6:
            addresses: [<static-ip>/24]
            gateway4: <gateway-ip>
            nameservers:
              addresses: [8.8.8.8,8.8.4.4]
            dhcp4: no
    version: 2

The most important things to be set are ethenet names and dhcp4: no.

3. Apply the setting.

sudo netplan apply

4. Check whether the settings are applied.

ip addr
ip route

5. Check whether the network works

nslookup google.com

Referenes