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
I have seen some dynamic routing settings on the ...
This article uses examples to illustrate the usag...
1. Problem Forgot password for mysql5.7 under lin...
background: As a DBA, most of the DDL changes of ...
We usually use float layout to solve the compatib...
Preface When the system space usage is too large ...
In the process of learning CSS3, I found that man...
The first tutorial for installing MySQL-5.7.19 ve...
This article example shares the specific code of ...
Problem Description After installing Qt5.15.0, an...
HTML is the abbreviation of Hypertext Markup Langu...
1.device-width Definition: Defines the screen vis...
Directly code: select 'bigint unsigned' a...
Table of contents How to create a Pod? kubectl to...
1. Application of multimedia in HTML_falsh animat...