How to set static IP in centos?

coldplay.xixi
Release: 2020-07-29 14:10:19
Original
9266 people have browsed it

How to set static IP in centos: First use the vi editor and press the insert key to insert; then enter the editing mode, move the cursor to the IPADDR setting part, and change it to the IP address that needs to be set; finally set it After that, just restart the network service.

How to set static IP in centos?

How to set a static IP in centos:

1. Temporarily set the IP address

1. Take this machine as an example. The IP query above is 1.117. Enter ifconfig eth0 (the default is the first network card) followed by the IP address, network mask and gateway. If not set, use the default mask. Code

2. Check the IP again and it will become a new IP address

Note that this modification is only a temporary modification and will be restored after restarting the network card or server

2. Set [\] to modify the IP address

1. If you want the IP address to be permanent, you need to edit the network card configuration file

Use VI EditorSettings, such as

vi /etc/sysconfig/network-scripts/ifcfg-eth0
Copy after login

Describe this file;

  • DEVICE=eth0 The device alias corresponding to the network card, such as ifcfg-eth0 The first network card BOOTPROTO=static network card How to obtain the ip address,

  • Static (static ip address)

  • dhcp (obtain ip through dhcp protocol)

  • bootip The ip address obtained through the bootp protocol BROADCAST=192.168.0.255 Subnet broadcast address HWADDR=00:50:56:8E:47:EE Network card physical address IPADDR=12.168.1.117

  • IPV6INIT=no Whether to enable IPV6IPV6_AUTOCONF=no NETMASK=255.255.255.0 The network mask corresponding to the network card NETWORK=192.168.1.0 The network address corresponding to the network card ONBOOT=yes Whether to set this network interface when the system starts, when set to yes , activate this device when the system starts. The default setting is yes

As for the following TYPE and UUID, you don’t need to worry about it. The class of this network card is

2. Use the vi editor and press the insert key to insert. Enter the editing mode

3. Move the cursor to the IPADDR setting part and change it to the IP address that needs to be set,

For example, change it to 1.118 in this example. Press the esc key.

Enter colon:wq Save and exit

will prompt

"/etc/sysconfig/network-scripts/ifcfg-eth0" 14L, 302C written
Copy after login

4. After setting up, restart the network service, service network restart

Recommended related tutorials: centos tutorial

The above is the detailed content of How to set static IP in centos?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!