In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
I. background
Netplan is a new command line network configuration utility introduced in Ubuntu 17.10 to easily manage and configure network settings in Ubuntu systems. It allows you to configure network interfaces using YAML abstractions. It can be used as an interface to the kernel along with NetworkManager and systemd-networkd network daemons, called renderers, which you can choose to use.
It reads the network configuration described in / etc/netplan/*.ymal and can store the configuration of all network interfaces in these files.
In this article. We will explain how to use the Netplan utility to configure network static or dynamic IP addresses for network interfaces in Ubuntu 18.04.
II. Solutions
List all active network interfaces on Ubuntu
First, you need to determine the network interface to configure. You can use the ifconfig command to list all connected network interfaces in the system, as shown in the figure.
Ifconfig-a
Check the network interface in Ubuntu
From the output of the above command, we have two interfaces connected to the Ubuntu system: an Ethernet interface and a loopback interface.
Ubuntu sets static IP address
In this example, we configure the ens33 Ethernet network interface with a static IP. Use vim to open the netplain configuration file as shown.
Important: if the YAML file was not created by the distribution installer, you can use this command to generate the required configuration for the renderer.
Sudo netplan generate
In addition, automatically generated files may have different file names on desktops, servers, cloud instances, etc. (such as 01-network-manager-all.ymal or 01-netcfg.yaml), but all files under / etc/netplan/*.yaml will be read by netplan.
Sudo vim / etc/netplan/xxxx.ymal
Then add the following configuration in the ethernet section.
Network: ethernets: ens33: addresses:-192.168.4.254 addresses 24 dhcp4: false gateway4: 192.168.4.2 nameservers: addresses:-8.8.8.8 search: [] version: 2
Description:
Ens33: network interface name
Dhcp4: receives the dhcp attribute of the IPV4 interface
Dhcp6: receives the dhcp attribute of the IPV6 interface
Addresses: the static address sequence of the interface
Gateway4: the IPV4 address of the default gateway
Nameservers:DNS server address, separated by a sign
After the addition is complete, your profile should have the following, as shown in the following screenshot.
The address attribute of the interface expects a sequence entry, such as [192.168.4.254x24, "20001: 1:: 1Unix64"] or [192.168.1.254Unix24,] (refer to the netplan man page for more information).
Configure static IP in Ubuntu
Save the file and exit. Then apply the most recent network changes using the following netplan command.
Sudo netplan apply
Now verify all available network interfaces again, and the ens33 Ethernet interface should now be connected to the local network and have an IP address, as shown in the screenshot below.
Ifconfig-a
Verify the network interface in Ubuntu
Ubuntu sets dynamic IP address
To configure the ens33 Ethernet interface to dynamically receive IP addresses through DHCP, you only need to use the configuration.
Network: ethernets: ens33: dhcp6: true dhcp4: true version: 2
Save the file and exit. Then apply the most recent network changes using the following netplan command.
Sudo netplan applyifconfig-a
From now on, your system will learn IP addresses dynamically from the router.
You can find more information and configuration options by viewing the netplan man page.
Man netplan
At this time, you have successfully configured the network static IP address to your Ubuntu server.
Summary
The above is the method of setting static IP in Ubuntu 18.04Server introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to the website!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.