Because Ubuntu20.04 manages the network through netplan, which is slightly different from the previous version, Ubuntu18.04 seems to need to edit /network/interfaces to set up a static network
Because I installed a virtual machine, first I changed it to bridge mode
Next edit the file:
sudo vim /etc/netplan/01-network-manager-all.yaml
Modify the content of the file to:
I have always wondered, should I modify it for different ip addresses?
But because I haven’t reached that level yet, it’s not very clear. It should be possible to modify.
But there is no problem directly typing the following code into the file
Enter: wq save and exit, then enter
sudo netplan --debug apply
Can
Now that the static ip is set, you can check the current ip address through ifconfig.
12. x version
$ cat /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 20.20.20.102
netmask 255.255.255.0
gateway 20.20.20.102
dns-nameservers 20.20.20.2
14. x version
$ cat /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 20.20.20.102
netmask 255.255.255.0
gateway 20.20.20.102
dns-nameservers 20.20.20.2
$ cat /etc/NetworkManager/NetworkManager.conf
[ main]
plugins=ifupdown,keyfile,ofono
dns=dnsmasq
no-auto-default=00:0C:29:D7:43:29,[ifupdown]
managed=true
16. x version
$ cat /etc/network/interfaces
auto lo
iface lo inet loopback
auto ens32
iface ens32 inet static
address 20.20.20.102
netmask 255.255.255.0
gateway 20.20.20.102
$ cat /etc/NetworkManager/NetworkManager.conf
[ main]
plugins=ifupdown,keyfile,ofono
dns=dnsmasq
no-auto-default=00:0C:29:D7:43:29,[ifupdown]
managed=true
$ cat /etc/resolv.conf
nameserver 127.0.1.1
nameserver 20.20.20.2
**18. x version: **
1、 First check the network card name
$ ip a / ifconfig
2、 cp a yaml file, change the name
$ sudo cp /etc/netplan/*.yaml /etc/netplan/NIC name.yaml
3、 Modify the content of the yaml file as follows:
# Let NetworkManager manage all devices on this system
network:
version:2
renderer: NetworkManager
ethernets:
NIC name:
dhcp4: no
addresses:[ip/prefix]
gateway4: gateway
nameservers:
addresses:[dns]
4、 start up
$ sudo netplan apply
5、 verification
$ ip a / ifconfig
So far, this article on ubuntu20.04 setting static ip address (including different versions) is introduced here. For more related ubuntu20.04 setting static ip content, please search for previous articles by ZaLou.Cn or continue to browse related articles below I hope you will support ZaLou.Cn a lot in the future!
Recommended Posts