Because Ubuntu 20.04 manages the network through netplan, which is slightly different from previous versions, Ubuntu 18.04 seems to need to edit /network/interfaces to set up a static network Because it is a virtual machine, I first change it to bridge mode Next edit the file: sudo vim /etc/netplan/01-network-manager-all.yaml Modify the file content to: I have always wondered whether I need to make modifications for different IP addresses? But since I haven't reached that level yet, I'm not very clear about it. It should be modifiable. But there is no problem typing the following code directly into the file Enter: wq to save and exit, then enter sudo netplan --debug apply You can Now the static IP is set up, and you can view 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 and change its name $ sudo cp /etc/netplan/*.yaml /etc/netplan/network card name.yaml 3. Modify the contents of the yaml file as follows: # Let NetworkManager manage all devices on this system network: version: 2 renderer: NetworkManager ethernets: Network card name: dhcp4: no addresses: [ip/prefix] gateway4: gateway nameservers: addresses: [dns] 4. Start $ sudo netplan apply 5. Verification $ ip a /ifconfig This is the end of this article about setting a static IP address for Ubuntu 20.04 (including different versions). For more information about setting a static IP address for Ubuntu 20.04, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Introduction to MySql table, database, sharding and partitioning knowledge points
>>: MySQL DML language operation example
Reinventing the wheel, here we use repackaging to...
Table of contents background Problem Analysis 1. ...
We all know that the underlying data structure of...
This question is very strange, so I will go strai...
** Install mysql-8.0.20 under Linux ** Environmen...
This article shares the specific code of Vue to i...
Start a new project This article mainly records t...
I have recently been following the CSS Animation ...
1》Be good at web design 2》Know how to design web p...
Copy code The code is as follows: <object id=&...
This article describes how to add or expand a dis...
In this post, we’ll use the :placeholder-shown ps...
Recently, when I was modifying the intranet porta...
* address - address * blockquote - block quote * c...
First create a specific project directory for you...