In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to use dhcp to get IP automatically under Linux. I believe most people don't know much about it, so share this article for your reference. I hope you can learn a lot after reading this article. Let's learn about it together.
Dhcp is a dynamic host setting protocol (Dynamic Host Configuration Protocol, DHCP), which is a network protocol of a local area network. It works with UDP protocol and has two main uses: automatically assigning IP addresses to internal network or network service providers to internal network administrators as a means of central management of all computers.
First use the ip addr command to get the ip address of the Linux server
Found that ens33 has no inet attribute
You need to configure the ip address to connect to Linux remotely.
Method 1: configure through nmtui
Enter the configuration interface
Edit a connection: set up a connection to add and delete network configuration
Activate a connection: activate a connection to enable disable network configuration
Set system hostname: setting hostname
Select Edit a connection and press enter.
Select ens33 and press enter.
Change IPv4 CONFIGURATION to Automatic, remove 192.168.1.100Accord 24 from Addresses, and then select ok
Select Back
Select ok
If you want the Nic configuration to take effect, you need to restart the network service and execute systemctl restart network.
An error occurred and the network service failed to restart
After looking up the information, it is found that the reason for the error is a conflict with the NetworkManager service, which is easy to solve, just shut down the NetworkManger service directly. Systemctl stop NetwrokManager stops the network management service and then executes systemctl restart network
In this way, dhcp is used to obtain the ip address automatically.
Execute ip addr, and the ip address has been obtained automatically.
Method 2: execute vi / etc/sysconfig/network-scripts/ifcfg-ens33
See the configuration information of the ens33 network card file
Configuration information explanation:
TYPE=Ethernet network card type: Ethernet
PROXY_METHOD=none proxy mode: closed statu
BROWSER_ONLY=no is just a browser (yes | no)
BOOTPROTO=none sets how the network card obtains the ip address (static | dhcp | none | bootp)
DEFROUTE=yes is set as the default route (yes | no)
Whether IPV4_FAILURE_FATAL=no enables IPV4 fatal error detection (yes | no)
Whether IPV6INIT=yes IPV6 initializes automatically
Whether IPV6_AUTOCONF=yes IPV6 is automatically configured
Whether IPV6_DEFROUTE=yes IPV6 can be the default route
IPV6_FAILURE_FATAL=no does not enable IPV6 fatal error detection.
IPV6_ADDR_GEN_MODE=stable-privacy IPV6 address generation model
Physical device name of NAME=ens33 Nic
UUID=6e89ea13-f919-4096-ad67-cfc24a79a7e7 UUID identification code
DEVICE=ens33 network card device name
ONBOOT=yes self-boot (yes | no)
IPV6_PRIVACY=no
IPADDR=192.168.1.100 IP address
PREFIX=24 mask
Change BOOTPROTO=none to BOOTPROTO=dhcp here
Delete IPADDR=192.168.1.100 and PREFIX=24
Then save the file.
If you want the Nic configuration to take effect, you need to restart the network service and execute systemctl restart network.
Note: if an error occurs, the network service fails to restart. There may be a conflict with the NetworkManager service. Systemctl stop NetwrokManager stops the network management service before performing systemctl restart network.
Both of the above two methods can configure the network card as dhcp. Let's test whether it can be connected with ping.
Dhcp configured successfully
The above is all the contents of the article "how to use dhcp to get IP automatically under Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.