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 are as follows:
-
Assign additional IP addresses to the
lo
interface - Define DNS addresses
-
Change the Maximum Transmission Unit (MTU) size of the
lo
interface
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 loopback
Copy 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/24
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteNetworkManager manages the
lo
interface by always assigning the IP addresses127.0.0.1
and::1
that are persistent across the reboots. You cannot override127.0.0.1
and::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 16384
Copy 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.0
Copy 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.conf
file. 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-loopback
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Display the settings of the
lo
interface: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