Disable IPv6 on network interface on CentOS Linux 8

Overview

--Disable IPv6 on network interfaces with NetworkManager's command line tool nmcli

This environment

# cat /etc/centos-release
CentOS Linux release 8.1.1911 (Core) 

Check the status before setting

IPv6 is currently enabled. If the ifconfig command shows an inet6 entry, then the device has IPv6 enabled.

# nmcli connection show
NAME  UUID                                  TYPE      DEVICE
eth0  XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX  ethernet  eth0
# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet XXX.XXX.XXX.XXX  netmask XXX.XXX.XXX.XXX  broadcast XXX.XXX.XXX.XXX
        inet6 XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX  prefixlen 64  scopeid 0x0<global>
        inet6 XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX  prefixlen 64  scopeid 0x20<link>
        ether XX:XX:XX:XX:XX:XX  txqueuelen 1000  (Ethernet)
        RX packets 1856709  bytes 121862479 (116.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 53733  bytes 8848173 (8.4 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Disable IPv6

Disable IPv6 on network interface eth0 with the nmcli connection modify command. Specify disabled for ipv6.method. Specify invalid values for ipv6.addresses and ipv6.gateway.

# nmcli connection modify eth0 ipv6.method "disabled" ipv6.addresses "" ipv6.gateway ""

Check the settings with the nmcli connection show command.

# nmcli connection show eth0 | grep ipv6
ipv6.method:                            disabled
ipv6.dns:                               --
ipv6.dns-search:                        --
ipv6.dns-options:                       --
ipv6.dns-priority:                      0
ipv6.addresses:                         --
ipv6.gateway:                           --
ipv6.routes:                            --
ipv6.route-metric:                      -1
ipv6.route-table:                       0 (unspec)
ipv6.routing-rules:                     --
ipv6.ignore-auto-routes:                no
ipv6.ignore-auto-dns:                   no
ipv6.never-default:                     no
ipv6.may-fail:                          yes
ipv6.ip6-privacy:                       0 (disabled)
ipv6.addr-gen-mode:                     stable-privacy
ipv6.dhcp-duid:                         --
ipv6.dhcp-send-hostname:                yes
ipv6.dhcp-hostname:                     --
ipv6.token:                             --

Use the nmcli connection up command to restart the network connection for the settings to take effect.

# nmcli connection up eth0
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2)

Error occurs if ipv6.addresses and ipv6.gateway are not specified

The official document of Red Hat Enterprise Linux 8 describes how to specify only ipv6.method, but in this environment, if you do not set the values of ipv6.addresses and ipv6.gateway, the following error will occur. Was there.

# nmcli connection modify eth0 ipv6.method "disabled"
Error: Failed to modify connection 'eth0': ipv6.addresses: this property is not allowed for 'method=disabled'

# nmcli connection modify eth0 ipv6.method "disabled" ipv6.addresses ""
Error: Failed to modify connection 'eth0': ipv6.gateway: gateway cannot be set if there are no addresses configured

Check the status after setting

If the ifconfig command does not show an inet6 entry, then IPv6 is disabled on this network interface.

# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet XXX.XXX.XXX.XXX  netmask XXX.XXX.XXX.XXX  broadcast XXX.XXX.XXX.XXX
        ether XX:XX:XX:XX:XX:XX  txqueuelen 1000  (Ethernet)
        RX packets 1885535  bytes 123804373 (118.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 56110  bytes 9257206 (8.8 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

If 1 is written to the disable_ipv6 file, IPv6 is disabled on this network interface.

# cat /proc/sys/net/ipv6/conf/eth0/disable_ipv6
1

Reference material

-[Chapter 19 Disabling IPv6 on Systems Using NetworkManager Red Hat Enterprise Linux 8 \ | Red Hat Customer Portal](https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/8/html/ configuring_and_managing_networking / disabling-ipv6-on-a-system-that-uses-networkmanager_configuring-and-managing-networking) -[3 \ .3 . IP network settings using nmcli Red Hat Enterprise Linux 7 \ | Red Hat Customer Portal](https://access.redhat.com/documentation/ja-jp/red_hat_enterprise_linux/7/html / networking_guide / sec-configuring_ip_networking_with_nmcli)

Recommended Posts

Disable IPv6 on network interface on CentOS Linux 8
[Linux] I installed CentOS on VirtualBox
Get the IPv4 address assigned to the network interface in code (Linux)
Install Mecab on Linux (CentOS) with brew
How to update security on CentOS Linux 8
Network Linux commands
[Linux] When "| (pipe)" cannot be hit on CentOS7
Linux (CentOS) construction
Disable CentOS 7 selinux
Linux Network Namespace
Procedure for manually installing Java (jdk1.8) on Linux (CentOS7)
Daemonizing processes on Linux
Install Faiss on CentOS 7
jblas on Arch Linux
Linux (WSL) on Windows
NAT router on Linux
Install numba on CentOS 7.2
Install Python3.4 on CentOS 6.6
Install mecab-python on CentOS
Install Python 2.7.3 on CentOS 5.4
Monitor traffic on Linux
Update vscode on linux
Try NeosVR on Linux
Installation on CentOS8 VirtualBox
Check capacity on Linux
Install awscli on centos7
Install Chainer on CentOS 6.7
Network (mainly Linux) notes
[Linux] IPv6 invalidation setting
LiveUSB creation on Linux
Torque setup on CentOS 6
Linux operation on Win10
Platform Channel VS FFI (Foreign Function Interface) on Flutter on Linux
Install Linux (CentOS) on your PC using a USB stick
CentOS 7 basic settings after network settings
network
[RHEL / CentOS 8] Network settings memo
[CentOS] Network check / change command [RHEL]
Network settings and confirmation in CentOS7
Disable IPv6 on network interface on CentOS Linux 8
Relational Network
CentOS8 server construction (network opening and package update)