Home>Article>Operation and Maintenance> How to set ip in centos7

How to set ip in centos7

下次还敢
下次还敢 Original
2024-04-07 21:06:24 605browse

How to configure the IP address in CentOS 7: 1. Edit the network configuration file; 2. Set the IP address and network mask; 3. Set the gateway (optional); 4. Enable network services; 5. Verify IP address.

How to set ip in centos7

How to configure an IP address in CentOS 7

To configure an IP address in CentOS 7, follow these steps:

1. Edit the network configuration file

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

2. Set the IP address and network mask

IPADDR=192.168.0.20 NETMASK=255.255.255.0

3. Set the gateway (optional)

If you need to access through the gateway For other networks, please set up the gateway:

GATEWAY=192.168.0.1

4. Enable network services

systemctl start network

5. Verify IP address

To verify that the IP address has been configured correctly, run the following command :

ifconfig eth0

You should see the following output:

eth0: flags=4163 mtu 1500 inet 192.168.0.20 netmask 255.255.255.0 broadcast 192.168.0.255 inet6 fe80::20c:29ff:fe4f:f2b2 prefixlen 64 scopeid 0x20 ether 00:0c:29:4f:f2:b2 txqueuelen 1000 (Ethernet) RX packets 321 bytes 31134 (30.2 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 292 bytes 31329 (30.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

whereinet 192.168.0.20represents the assigned IP address.

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

Statement:
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