0%

配置centos固定ip

a. 修改/etc/sysconfig/network配置文件:

vi /etc/sysconfig/network

1
2
# Created by anaconda
GATEWAY=192.168.243.2

b. 修改/etc/sysconfig/network-scripts/ifcfg-ens33配置文件:

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no

BOOTPROTO=static
IPADDR=192.168.243.131
GATEWAY=192.168.243.2
NETMASK=255.255.255.0

DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=193e7f5e-e25b-40ef-b292-0fe5c8970af5
DEVICE=ens33
ONBOOT=yes
ZONE=public

DNS1=8.8.8.8
DNS2=4.2.2.2

c. 重启网关:

1
service network restart