Questo contenuto non è disponibile nella lingua selezionata.
Chapter 15. Configuring the loopback interface by using nmcli
By default, NetworkManager does not manage the loopback (lo) interface. After creating a connection profile for the lo interface, you can configure this device by using NetworkManager.
Some of the examples when users want to configure the loopback interface are as follows:
-
Assign additional IP addresses to the
lointerface - Define DNS addresses
-
Change the Maximum Transmission Unit (MTU) size of the
lointerface
Procedure
Create a new connection of type
loopback:nmcli connection add con-name example-loopback type loopback
# nmcli connection add con-name example-loopback type loopbackCopy to Clipboard Copied! Toggle word wrap Toggle overflow Configure custom connection settings, for example:
To assign an additional IP address to the interface, enter:
nmcli connection modify example-loopback +ipv4.addresses 192.0.2.1/24
# nmcli connection modify example-loopback +ipv4.addresses 192.0.2.1/24Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteNetworkManager manages the
lointerface by always assigning the IP addresses127.0.0.1and::1that are persistent across the reboots. You cannot override127.0.0.1and::1. However, you can assign additional IP addresses to the interface.To set a custom Maximum Transmission Unit (MTU), enter:
nmcli con mod example-loopback loopback.mtu 16384
# nmcli con mod example-loopback loopback.mtu 16384Copy to Clipboard Copied! Toggle word wrap Toggle overflow To set an IP address to your DNS server, enter:
nmcli connection modify example-loopback ipv4.dns 192.0.2.0
# nmcli connection modify example-loopback ipv4.dns 192.0.2.0Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you set a DNS server in the loopback connection profile, this entry is always available in the
/etc/resolv.conffile. The DNS server entry remains independent of whether or not the host roams between different networks.
Activate the connection:
nmcli connection up example-loopback
# nmcli connection up example-loopbackCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Display the settings of the
lointerface:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify the DNS address:
cat /etc/resolv.conf ... nameserver 192.0.2.0 ...
# cat /etc/resolv.conf ... nameserver 192.0.2.0 ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow