ps: This method is invalid on ubuntu 18.04, see method two
1、 Modify the configuration file /etc/network/interfaces
Add the following content:
auto eth0 #Set to automatically start the eth0 interface
iface eth0 inet static #Configure static IP
address 192.168.11.88 #IP address
netmask 255.255.255.0 #Subnet mask
gateway 192.168.11.1 #Default gateway
2、 Modify DNS
$ sudo vi /etc/resolve.conf**
Add the following content:
nameserver 127.0.0.1 #Remember to add
nameserver 8.8.8.8 #Local dns server(Use ipconfig/all view local dns, the first dns is the default, there are 2 dns in total)
3、 Restart the network for the configuration to take effect
$ sudo /etc/init.d/networking restart
4、 Check whether the ip configuration is successful
$ ifconfig
1 Modify the /etc/netplan/50-cloud-init.yaml
file, the desktop version is /etc/netplan/01-network-manager-all.yaml
will
network:
ethernets:
ens33:
dhcp4:true
version:2
change into
network:
ethernets:
ens33:
addresses:[192.168.42.205/24]
gateway4:192.168.42.255
dhcp4: yes
version:2
2 Make the configuration file effective
$ netplan apply
Recommended Posts