欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

CentOS7联网初始化步骤教程

程序员文章站 2022-12-10 22:34:48
1. 显示网络设备的运行状态 [root@ruijie ~]$ ip link 2. 显示网络接口的网络参数 [root@ruijie ~]$ ip addr 3. 修改网卡信...

1. 显示网络设备的运行状态

[root@ruijie ~]$ ip link

2. 显示网络接口的网络参数

[root@ruijie ~]$ ip addr

3. 修改网卡信息–ONBOOT

[root@ruijie ~]$ vi /etc/sysconfig/network-scripts/ifcfg-eth0

ONBOOT=yes

4. 重启网络服务

[root@ruijie ~]$ systemctl restart network

5. 检测网络连通性

[root@ruijie ~]$ ping 114.114.114.114 -c 3
PING 114.114.114.114 (114.114.114.114) 56(84) bytes of data.
64 bytes from 114.114.114.114: icmp_seq=1 ttl=67 time=1.55 ms
64 bytes from 114.114.114.114: icmp_seq=2 ttl=70 time=1.47 ms
64 bytes from 114.114.114.114: icmp_seq=3 ttl=65 time=1.54 ms

--- 114.114.114.114 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 1.472/1.522/1.554/0.057 ms

6. 显示网络接口的网络参数-查看当前IP

[root@ruijie ~]$ ip addr

7. 修改网卡信息–IP

[root@ruijie ~]$ vi /etc/sysconfig/network-scripts/ifcfg-eth0

IPADDR=XXX.XXX.XXX.XXX
NETMASK=255.255.255.0
GATEWAY=XXX.XXX.XXX.1

8. 重启网络服务

[root@ruijie ~]$ systemctl restart network

9. 再次检测网络连通性

[root@ruijie ~]$ ping 114.114.114.114 -c 3

PING 114.114.114.114 (114.114.114.114) 56(84) bytes of data.
64 bytes from 114.114.114.114: icmp_seq=1 ttl=67 time=1.55 ms
64 bytes from 114.114.114.114: icmp_seq=2 ttl=70 time=1.47 ms
64 bytes from 114.114.114.114: icmp_seq=3 ttl=65 time=1.54 ms

--- 114.114.114.114 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 1.472/1.522/1.554/0.057 ms

10. 检测域名解析

[root@ruijie ~]$ ping baidu.com

ping: unknown host baidu.com

11. 配置域名解析

[root@ruijie ~]$ vi /etc/resolv.conf

nameserver 114.114.114.114
nameserver 8.8.8.8

12. 再次检测域名解析

[root@ruijie ~]$ ping baidu.com -c 3

PING 114.114.114.114 (114.114.114.114) 56(84) bytes of data.
64 bytes from 114.114.114.114: icmp_seq=1 ttl=67 time=1.55 ms
64 bytes from 114.114.114.114: icmp_seq=2 ttl=70 time=1.47 ms
64 bytes from 114.114.114.114: icmp_seq=3 ttl=65 time=1.54 ms

--- 114.114.114.114 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 1.472/1.522/1.554/0.057 ms

13. OK!!!