linux配置固定IP

[root@192 ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500        //确定网卡名
        inet 192.168.88.136  netmask 255.255.255.0  broadcast 192.168.88.255
        inet6 fe80::4dd8:59f8:8bb4:46  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:c6:6d:22  txqueuelen 1000  (Ethernet)
        RX packets 329  bytes 31647 (30.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 214  bytes 47754 (46.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 64  bytes 5568 (5.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 64  bytes 5568 (5.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@192 ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE="Ethernet"
BOOTPROTO="dhcp"    //改为static
                    //增加 IPADDR=192.168.88.136
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="ens33"
UUID="2bb38dbc-583c-4e0d-8fc7-88dc191754a9"
DEVICE="ens33"
ONBOOT="yes"        //on 表示开机自动连接网络

[root@192 ~]# reboot    //重启机器即可