1、查看ip地址
[root@localhost network-scripts]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:45:19:a1 brd ff:ff:ff:ff:ff:ff
inet 192.168.2.30/24 brd 192.168.2.255 scope global noprefixroute dynamic ens33
valid_lft 1641sec preferred_lft 1641sec
inet6 fe80::ccdd:22d6:8c51:11d/64 scope link noprefixroute
valid_lft forever preferred_lft forever
2、编辑网卡文件
vi /etc/sysconfig/network-scripts/ifcfg-ens32
.将BOOTPROTO=dhcp
改为BOOTPROTO=static
;ONBOOT
设为ONBOOT=yes
.再添加/更改 IPADDR
, NETMASK
, GATEWAY
, DNS
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.160
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS=8.8.8.8
3、重启网络
systemctl restart network
4、重新查看ip
[root@localhost network-scripts]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:45:19:a1 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.160/24 brd 192.168.2.255 scope global noprefixroute dynamic ens33
valid_lft 1641sec preferred_lft 1641sec
inet6 fe80::ccdd:22d6:8c51:11d/64 scope link noprefixroute
valid_lft forever preferred_lft forever
5、ping 一下其他的ip或域名
ping www.baidu.com
标签:00,centos,静态,ip,forever,preferred,lft,ff,scope
From: https://www.cnblogs.com/lanjianhua/p/18356706