Centos Linux7设置静态IP的实例
## 先进入配置文件的放置位置:
1
|
cd /etc/sysconfig/network-scripts/
|
## 查看当前网卡使用的是哪个文件
1
|
ip add
|
## 过滤出配置文件列表
1
|
ll | grep ifcfg
|
## 编辑配置文件
1
|
vi ifcfg - ens160
|
## 配置文件内容 主要:BOOTPROTO IPADDR NETMASK NM_CONTROLLED ONBOOT 这几个字段,其他的不变
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
TYPE = Ethernet
BOOTPROTO = static
IPADDR = 192.168 . 1.251
NETMASK = 255.255 . 255.0
DNS1 = 8.8 . 8.8
DNS2 = 8.8 . 4.4
NM_CONTROLLED = no
DEFROUTE = yes
PEERDNS = yes
PEERROUTES = yes
IPV4_FAILURE_FATAL = no
IPV6INIT = yes
IPV6_AUTOCONF = yes
IPV6_DEFROUTE = yes
IPV6_PEERDNS = yes
IPV6_PEERROUTES = yes
IPV6_FAILURE_FATAL = no
IPV6_ADDR_GEN_MODE = stable - privacy
NAME = ens160
UUID = 23a77b70 - a6e3 - 4399 - a5bd - 4ca312a0f123
DEVICE = ens160
ONBOOT = yes
|
## 修改网关配置文件:
1
2
3
4
5
6
|
vi / etc / sysconfig / network
NETWORKING = yes
NETWORKING_IPV6 = no
HOSTNAME = localhost.localdomain
GATEWAY = 192.168 . 1.1
|
## 重启网络服务
1
|
systemctl restart network.service
|
感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!
原文链接:https://my.oschina.net/Kxvz/blog/856506