ubuntu 16.04 設定固定IP




14.04版以前設定是將固定IP設定於/etc/network/interface,然後於/etc/resolv.conf 設定DNS。

16.04後發現是要這樣設定

source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto enp0s3
#iface enp0s3 inet dhcp
iface enp0s3 inet static
address 192.168.0.2
netmask 255.255.255.0
gateway 192.168.0.1
dns-nameservers 8.8.8.8
dns-nameservers 8.8.4.4