ubuntu20.04 set static ip address (including different versions)

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

ubuntu20.04 set static ip address (including different versions)
ubuntu16.04 set static ip
ubuntu 18.04 set static ip method
How to set static IP in ubuntu14.04
How to set static IP on Ubuntu 18.04 Server
ubuntu 17.10 set solid IP
ubuntu16.0.4 method to set a fixed IP address
How to set static IP on Ubuntu 18.04 Server
Explain how to set static IP on ubuntu14.04
[Quick Start with Ubuntu] Two, Ubuntu set static IP
Ubuntu18.04, Centos7 static IP
Set static IP under Centos
ubuntu modify and configure ip address
Set static IP for CentOS in VMware
Summary of CentOS method to set static IP
Complete steps to configure IP address in Ubuntu 18.04 LTS
Example of how to modify ip address in Ubuntu20.04
How to set a fixed IP based on Ubuntu 16.04