As of 17.10, a new network configuration called netplan
has been created. It looks more concise than the existing interface configuration (/etc/network/interfaces).
The files to change are as follows.
sudo vi /etc/netplan/50-cloud-init.yaml
Basically, when installed with dhcp, the following is displayed.
network:
ethernets:
enp4s0f2:
addresses: []
dhcp4: true
version: 2
You can set the contents by entering ip and information as below.
network:
ethernets:
enp4s0f2:
dhcp4: no
addresses: [192.168.1.200/24]
gateway4: 192.168.1.1
nameservers:
addresses: [1.1.1.1,8.8.8.8,8.8.4.4]
version: 2
And the changed contents are applied as below.
sudo netplan apply
You can check the changed contents with ifconfig
.
$ifconfig
enp4s0f2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.200 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::290:f5ff:fee7:6e10 prefixlen 64 scopeid 0x20<link>
ether 00:90:f5:e7:6e:10 txqueuelen 1000 (Ethernet)
RX packets 89208 bytes 132983451 (132.9 MB)
RX errors 0 dropped 9 overruns 0 frame 0
TX packets 55318 bytes 4234704 (4.2 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 252 bytes 19812 (19.8 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 252 bytes 19812 (19.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
By the way, dhcp4 is true
, but when it is turned off, it is changed to no
.
Everyone is using it like that… Hmm…
Strange but works well. -_-;;;