乐趣区

关于centos7:centos-修改静态-IP

设置 Centos 为应用动态 IP

1 批改网络配置

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

批改后的内容如下

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
# 这里能够应用 static 或者 no
BOOTPROTO=none
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=ens192
UUID=cd93f1df-d2d5-4c63-a64c-761e9ee23aae
DEVICE=ens192
# 开机启用此配置
ONBOOT=yes
# 动态 IP
IPADDR=192.168.1.12
# 默认网关
GATEWAY=192.168.1.1

2 重启网络服务

systemctl restart network

3 查看地址

[isproot@192 ~]$ 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: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:51:63:21 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.12/24 brd 192.168.1.255 scope global noprefixroute ens192
       valid_lft forever preferred_lft forever
    inet6 2408:8256:a80:313:6ba6:7ad0:edd0:defe/64 scope global noprefixroute dynamic
       valid_lft 183241sec preferred_lft 96841sec
    inet6 fe80::b6f3:1daa:4b7b:6994/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

参考起源:https://blog.csdn.net/johnnyc…

退出移动版