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 set static IP address for CentOs

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces CentOs how to set static IP address related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe you will have something to gain after reading this CentOs how to set static IP address article, let's take a look.

1. Modify the configuration of the network card

Edit: vi / etc/sysconfig/network-scripts/ifcfg-eth0

Device=eth0 # describes the device alias corresponding to the Nic, for example, it is eth0 in the file of ifcfg-eth0

Bootproto=static # sets the way the network card obtains the ip address. The possible options are static,dhcp or bootp, corresponding to the statically specified ip address, the ip address obtained through the dhcp protocol, and the ip address obtained through the bootp protocol.

Subnet broadcast address corresponding to broadcast=192.168.0.255 #

Physical address of the network card corresponding to hwaddr=00:07:e9:05:e8:b4 #

Ipaddr=12.168.0.33 # if you set the way for the Nic to obtain the ip address statically, this field specifies the ip address corresponding to the Nic

The network mask for the netmask=255.255.255.0 # Nic

Network=192.168.0.0 # Network address corresponding to the Nic

two。 Modify gateway configuration

Edit: vi / etc/sysconfig/network modified as follows:

Networking=yes (indicates whether the system uses a network, which is generally set to yes. If set to no, the network cannot be used, and many system services will not start)

Hostname=centos (set the hostname of this machine, which corresponds to the hostname set in / etc/hosts)

Gateway=192.168.0.1 (sets the ip address of the gateway connected locally.)

When I modify it here and open it for editing, I already have the first three items by default, so only gateway has been added.

3. Modify dns configuration

Edit: vi / etc/resolv.conf modified as follows:

Nameserver is the ip address of the dns server, the first is the preferred, and the second is the backup.

4. Restart network services

Execute the command:

Service network restart

Or

/ etc/init.d/network restart, this is the end of the article on "how to set a static IP address for CentOs". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to set static IP address in CentOs". If you want to learn more, you are 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.

Share To

Internet Technology

Wechat

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

12
Report