当前位置: 移动技术网 > 网络运营>服务器>Linux > Centos Linux7设置静态IP的实例

Centos Linux7设置静态IP的实例

2019年04月23日  | 移动技术网网络运营  | 我要评论

centos linux7设置静态ip的实例

## 先进入配置文件的放置位置:

cd /etc/sysconfig/network-scripts/

## 查看当前网卡使用的是哪个文件

ip add

## 过滤出配置文件列表

ll | grep ifcfg

## 编辑配置文件

vi ifcfg-ens160

## 配置文件内容 主要:bootproto   ipaddr   netmask   nm_controlled  onboot 这几个字段,其他的不变

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

## 修改网关配置文件:

vi /etc/sysconfig/network

networking=yes
networking_ipv6=no
hostname=localhost.localdomain
gateway=192.168.1.1

## 重启网络服务

systemctl restart network.service

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网