Ubuntu 20.04 sets a static IP address (including different versions)

Ubuntu 20.04 sets a static IP address (including different versions)

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:
  • How to set static IP for Ubuntu 18.04 Server
  • How to set static IP address in Ubuntu 14.04 under VMware
  • Detailed explanation of how to set static IP in Ubuntu 14.04
  • Ubuntu16.04 static IP address setting (NAT method)
  • How to set static IP in ubuntu

<<:  Introduction to MySql table, database, sharding and partitioning knowledge points

>>:  MySQL DML language operation example

Recommend

Solution to forgetting the administrator password of mysql database

1. Enter the command mysqld --skip-grant-tables (...

Summary of MySQL5 green version installation under Windows (recommended)

1 Download MySQL Download address: http://downloa...

Solve MySQL login error: 'Access denied for user 'root'@'localhost'

First of all, I don't know why I can't lo...

Tutorial on installing Tomcat server under Windows

1 Download and prepare First, we need to download...

Sitemesh tutorial - page decoration technology principles and applications

1. Basic Concepts 1. Sitemesh is a page decoratio...

Detailed explanation of three methods of JS interception string

JS provides three methods for intercepting string...

How to find out uncommitted transaction information in MySQL

A while ago, I wrote a blog post titled "Can...

Network management and network isolation implementation of Docker containers

1. Docker network management 1. Docker container ...

How to implement a single file component in JS

Table of contents Overview Single file components...

MySQL subqueries and grouped queries

Table of contents Overview Subqueries Subquery Cl...

mysql5.7 remote access settings

Setting up remote access in mysql5.7 is not like ...