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 configure dynamic IP and static IP in Linux system

2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article will explain in detail how to configure dynamic IP and static IP in Linux system. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

1. Configure dynamic IP (dhcp) the operating system for this example is Centos 7.

\ 1. Enter the network script configuration directory:

Cd / etc/sysconfig/network-scripts/\ 2. Locate the file corresponding to the network device:

The network device in this example is ens32, so the network profile is ifcfg-ens32.

\ 3. Modify the network configuration file (ifcfg-ens32 in this example) as follows:

TYPE= "Ethernet" PROXY_METHOD= "none" BROWSER_ONLY= "no" BOOTPROTO= "dhcp" NM_CONTROLLED= "no" DEFROUTE= "yes" IPV4_FAILURE_FATAL= "no" IPV6INIT= "yes" IPV6_AUTOCONF= "yes" IPV6_DEFROUTE= "yes" IPV6_FAILURE_FATAL= "no" IPV6_ADDR_GEN_MODE= "stable-privacy" NAME= "ens32" UUID= 0d683ed8-ffc5-4609-b05c-e7e1cc65a17e "DEVICE=" ens32 "ONBOOT=" yes: the key points in this document are as follows:

BOOTPROTO= "dhcp" (indicates that the IP acquisition mode is automatic IP acquisition)

ONBOOT= "yes" (indicates that this network device starts with the system)

\ 4. Restart the network by running the following command, as follows:

Systemctl restart network2. Configure static IP (static) the operating system for this example is Centos 7.

\ 1. Enter the network script configuration directory:

Cd / etc/sysconfig/network-scripts/\ 2. Locate the file corresponding to the network device:

The network device in this example is ens32, so the network profile is ifcfg-ens32.

\ 3. Modify the network configuration file (ifcfg-ens32 in this example) as follows:

HWADDR= "00:0C:29:E3:68:90" TYPE= "Ethernet" BOOTPROTO= "static" IPADDR=192.168.213.128 NETMASK=255.255.255.0 GATEWAY=192.168.213.2 DNS1=8.8.8.8 DNS2=233.5.5.5 DEFROUTE= "yes" yes "PEERROUTES=" yes "IPV4_FAILURE_FATAL=" no "IPV6INIT=" yes "IPV6_AUTOCONF=" yes "IPV6_DEFROUTE=" yes "IPV6_PEERDNS=" yes "IPV6_PEERROUTES=" yes "IPV6_FAILURE_FATAL=" no "IPV6_ADDR_GEN_MODE= "stable-privacy" NAME= "ens32" UUID= "5dbbd6a6-251b-4e0e-b0af-9fac91b6b79a" DEVICE= "ens32" ONBOOT= "yes" note: the key points in this file need to pay attention to the following:

HWADDR= "00:0C:29:E3:68:90" (the MAC address of the network device)

BOOTPROTO= "static" (indicates that the IP acquisition mode is to get static IP)

IPADDR=192.168.213.128 (set static IP address)

NETMASK=255.255.255.0 (set subnet mask)

GATEWAY=192.168.213.2 (set Gateway)

DNS1=8.8.8.8 and DNS2=233.5.5.5 (set DNS address)

ONBOOT= "yes" (indicates that this network device starts with the system)

\ 4. Edit the DNS parsing file / etc/resolv.conf and add the DNS information set above, as follows:

Nameserver 8.8.8 nameserver 233.5.5.5\ 5. Restart the network by running the following command, as follows:

This is the end of systemctl restart network's article on "how to configure dynamic IP and static IP in Linux system". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.

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

Development

Wechat

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

12
Report