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