CentOS IP地址设置

基于 CentOS Linux release 7.6.1810 (Core)

获取物理信息

ip addr
1: lo:  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: enp2s0:  mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 90:2b:34:67:2b:1a brd ff:ff:ff:ff:ff:ff
3: enp3s2:  mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether 38:83:45:f2:36:9c brd ff:ff:ff:ff:ff:ff

修改配置文件

vi /etc/sysconfig/network-scripts/ifcfg-enp2s0
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
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=enp2s0
UUID=c8fd7be2-0b21-45f3-a22e-1517c3e2b461
DEVICE=enp2s0
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=192.168.1.1

重启网络服务

service network restart

你可能感兴趣的:(CentOS IP地址设置)