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 for CentOS

2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces the relevant knowledge of "how to set static IP in CentOS". The editor shows you the operation process through an actual case. The method of operation is simple and fast, and it is practical. I hope this article "how to set static IP in CentOS" can help you solve the problem.

1. Modify the configuration of network card

Vi / etc/sysconfig/network-scripts/ifcfg-eth0

Device=eth0 # describes the device alias corresponding to the network card. For example, in the ifcfg-eth0 file, it sets the way for the network card to obtain the ip address for eth0bootproto=static #. The possible options are static,dhcp or bootp, corresponding to the statically specified ip address, respectively, and the ip address obtained through the dhcp protocol. The ip address obtained through the bootp protocol broadcast=192.168.0.255 # corresponds to the subnet broadcast address hwaddr=00:07:e9:05:e8:b4 # the physical address of the network card ipaddr=12.168.0.33 # if the network card is set to obtain the ip address, it is statically specified This field specifies the ip address of the network card, the network address of the netmask=255.255.255.0 # network card, the network mask of the network=192.168.0.0 # network card, and the network address of the network card.

2. Modify the gateway configuration

Vi / etc/sysconfig/network

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 servers will not be able to start) hostname=centos # (set the host name of this machine, which corresponds to the host name set in / etc/hosts) gateway=192.168.0.1 # (set the ip address of the gateway connected to this machine.)

Typically, the last line is added.

3. Modify dns configuration

Vi / etc/resolv.conf

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

4. Restart the network

Service network restart

Or

/ etc/init.d/network restart on "how to set up static IP in CentOS" ends here. Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

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