Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to get dynamic and static IP addresses in CentOS 7

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

What this article shares with you is about how to obtain dynamic and static IP addresses in CentOS 7. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.

Automatic acquisition of dynamic IP addresses

1. Enter "ip addr" and press enter to confirm that you cannot get IP (CentOS 7 does not have the ifconfig command by default), and record the name of the network card (ens33 in this case).

two。 Enter "cd / etc/sysconfig/network-scripts/" press enter to confirm, continue to enter "ls" press enter to view the file.

3. Enter "vi ifcfg-ens33" and press enter to determine (the name of the network card may be different). You can also type "cd / etc/sysconfig/network-scripts/ifcfg-ens33" to edit the file directly in the second step.

4. Look at the last item (in the blue box) and find it is "ONBOOT=no".

5. Press the "I" key to enter the editing state, change the last line "no" to "yes", then press the "ESC" key to exit the editing state, and enter ": X" to save the exit.

6. Enter "service network restart" to restart the service, or enter "systemctl restart netwrok".

7. Type "ip addr" again, and you can now get the IP address automatically.

Set static IP address

8. Enter "cd / etc/sysconfig/network-scripts/" press enter key to confirm, continue to enter "ls" press enter key to view the file to determine the name of the network card.

9. Enter "vi ifcfg-ens33" and press enter to determine (the name of the network card may be different). If you know the name of the network card, you can directly enter the "cd / etc/sysconfig/network-scripts/ifcfg-ens33" editing file.

10. Press "I" to enter the editing state, set it to "BOOTPROTO='static'" (if set to none, disable DHCP,static to enable static IP address, set to dhcp to enable DHCP service), and modify the other parts to your settings, in this case, 192.168.1.1, you can configure IPV6 part according to your needs. Note: NM_CONTROLLED=no and ONBOOT=yes can be set up according to your needs.

11. After confirming that it is correct, press "ESC" to exit the editing state, and enter ": X" to save the exit, enter "service network restart" to restart the service, and enter "ifconfig" to view the network configuration.

twelve。 If you need to set up DNS (you need to set NM_CONTROLLED=no in step 9), enter "vi / etc/resolv.conf" and press enter to execute the command (this step can be omitted if DNS has been configured in step 9).

13. Enter the DNS server address in this file (in this case Guangdong Telecom as an example, you can also enter the router DNS address) and save the exit.

The above is how to obtain dynamic and static IP addresses in CentOS 7. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please 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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report