【Linux operation 21】 - How to enable and disable IPv4 in Centos7.9

How to enable and disable IPv4 in Centos7.9

You can just disable some ipv4 functions with if-cfg command for disable complete ipv4 you need recompile kernel beacuse system use 127.0.0.1 loop back interface;

Tip 1 Restart the network card and IPv4 will not be restored

1.1、Modify network card configuration

[root@localhost network-scripts]# cat ifcfg-ens33 
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=7f12b2bd-20c0-4421-b222-341cfea94bfd
DEVICE=ens33
ONBOOT=yes
IPV6ADDR=2001:da8:2004:1000:202:116:160:90/64
BOOTPROTO=static
HWADDR=00:0C:29:5F:E6:11
#IPADDR=192.168.100.208
#NETMASK=255.255.254.0
#GATEWAY=192.168.100.1

1.2 、then restart network.service

systemctl restart network.service

Tip 2:temporary-Restart the network card and restore IPv4

2.1、disable ipv4

ip address delete ip.ad.dr.ess dev ethx 
or
ip addr del IP_add_ress/mask dev eth0
[root@localhost ~]# ip add  del 192.168.100.208 dev ens33
Warning: Executing wildcard deletion to stay compatible with old scripts.
         Explicitly specify the prefix length (192.168.100.208/32) to avoid this warning.
         This special behaviour is likely to disappear in further releases,
         fix your scripts!
RTNETLINK answers: Cannot assign requested address

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 2001:da8:2004:1000:202:116:160:90  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::9d13:e7a1:7679:6c53  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:5f:e6:11  txqueuelen 1000  (Ethernet)
        RX packets 5477  bytes 481661 (470.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5500  bytes 426927 (416.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

2.2、enable ipv4

ip address add ip.ad.dr.ess dev ethx
[root@localhost ~]# ip address add 192.168.100.208 dev ens33

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.100.208  netmask 255.255.255.255  broadcast 0.0.0.0
        inet6 2001:da8:2004:1000:202:116:160:90  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::9d13:e7a1:7679:6c53  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:5f:e6:11  txqueuelen 1000  (Ethernet)
        RX packets 6925  bytes 608731 (594.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6903  bytes 539352 (526.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值