Ubuntu 20.04 how to modify the IP address example

Ubuntu 20.04 how to modify the IP address example

illustrate:

Today, when continuing the last office collaboration platform experiment, I found that the virtual machine had obtained an IP address through DHCP before, and the address obtained by DHCP changed after the virtual machine was turned on. Because the website has been configured with a fixed IP address access, it cannot access the webpage, so it is necessary to change the IP address to the IP address obtained last time to access it. I checked how to change the IP address in Ubuntu and found that "Starting from 17.10, Ubuntu has abandoned the configuration of fixed IP in /etc/network/interfaces. Even if it is configured, it will not take effect. Instead, it has been changed to netplan mode, and the configuration is written in /etc/netplan/01-netcfg.yaml or a yaml file with a similar name."
Without further ado, let's talk about how to modify the IP address with Netplan

0x00


Use the ifconfig command to view the network card

ifconfig

0x01 Modify the YAML configuration file

sudo vi /etc/netplan/00-installer-config.yaml

network:
 ethernets:
  ens33: #Name of the configured network card addresses: [192.168.31.215/24] #Static IP address and mask dhcp4: no #Turn off DHCP. If you need to turn on DHCP, write yes
   optional: true
   gateway4: 192.168.31.1 #Gateway address nameservers:
     addresses: [192.168.31.1,114.114.114.114] #DNS server address. Multiple DNS server addresses need to be separated by commas. version: 2
 renderer: networkd #Specify the backend to use systemd-networkd or Network Manager. If left blank, systemd-workd will be used by default.

After configuring according to your needs, save the file

0x02 Make the configured IP address effective

sudo netplan apply

OK, use the ifconfig command to check whether the configured new IP address is effective.

0x03 Notes:

1. The IP address and DNS server address need to be enclosed in [], but the gateway address does not need to be enclosed in [].
2. Note that a space must be added after each colon.
3. Pay attention to the indentation in front of each layer, at least two spaces more than the previous layer

This is the end of this article about the example of how to change the IP address of Ubuntu 20.04. For more information about how to change the IP address of 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 install WSL2 Ubuntu20.04 on Windows 10 and set up the docker environment
  • How to install docker on ubuntu20.04 LTS
  • Tutorial on installing Ubuntu 20.04 and NVIDIA drivers
  • Detailed steps to install Sogou input method on Ubuntu 20.04

<<:  Summary of the differences between MySQL and Oracle (comparison of functional performance, selection, SQL when using them, etc.)

>>:  Detailed explanation of BOM and DOM in JavaScript

Recommend

Native js custom right-click menu

This article example shares the specific code of ...

Detailed explanation of JS browser storage

Table of contents introduction Cookie What are Co...

7 native JS error types you should know

Table of contents Overview 1. RangeError 2. Refer...

Installation, activation and configuration of ModSecurity under Apache

ModSecurity is a powerful packet filtering tool t...

Use of Linux telnet command

1. Introduction The telnet command is used to log...

Docker Compose practice and summary

Docker Compose can realize the orchestration of D...

Intellij IDEA quick implementation of Docker image deployment method steps

Table of contents 1. Docker enables remote access...

Import backup between mysql database and oracle database

Import the data exported from the Oracle database...

HTML table tag tutorial (35): cross-column attribute COLSPAN

In a complex table structure, some cells span mul...

Linux kernel device driver memory management notes

/********************** * Linux memory management...

React implements infinite loop scrolling information

This article shares the specific code of react to...

Comparing Document Locations

<br />A great blog post by PPK two years ago...

Some notes on mysql create routine permissions

1. If the user has the create routine permission,...

A complete guide to the Docker command line (18 things you have to know)

Preface A Docker image consists of a Dockerfile a...