Create a dummy interface
A dummy interface is a virtual network interface that routes packets without transmitting them. Use a dummy interface to:
Create additional loopback-like devices managed by NetworkManager
Test network configurations without affecting live traffic
This topic describes how to create a dummy interface in Alibaba Cloud Linux 2 and Alibaba Cloud Linux 3, and how to configure a maximum transmission unit (MTU) for the interface.
Create a dummy interface in Alibaba Cloud Linux 3
Alibaba Cloud Linux 3 uses NetworkManager as the network service. NetworkManager does not support creating dummy interfaces with ifcfg-* files. Use nmcli commands or edit the connection configuration file instead.
Create the interface
Run the following command to create a dummy interface named dummy0:
sudo nmcli connection add con-name dummy0 type dummy ifname dummy0Replace dummy0 with a name that matches your requirements.
Configure an MTU
Choose one of the following methods.
Option 1: Use an nmcli command
Set the MTU value. Replace
[$mtu]with the desired value. Valid values depend on the network interface type and driver. The default is1500.sudo nmcli c modify dummy0 802-3-ethernet.mtu [$mtu]Restart NetworkManager:
sudo systemctl restart NetworkManagerReconnect to the
dummy0interface to apply the changes:sudo nmcli c down dummy0 sudo nmcli c up dummy0
Option 2: Edit the configuration file
Create the
dummy0device and connection:sudo nmcli connection add con-name dummy0 type dummy ifname dummy0Verify that the connection and device were created:
nmcli c nmcli dOpen the
dummy0.nmconnectionfile:sudo vim /etc/NetworkManager/system-connections/dummy0.nmconnectionPress
Ito enter Insert mode. Add or update themtuparameter in the[ethernet]section. Replace[$mtu]with the desired value. Valid values depend on the network interface type and driver. The default is1500.[ethernet] mtu=[$mtu]Press
Esc, type:wq, and pressEnterto save and close the file.Restart NetworkManager:
sudo systemctl restart NetworkManagerReconnect to the
dummy0interface to apply the changes:sudo nmcli c down dummy0 sudo nmcli c up dummy0
Verify the configuration
Check the MTU value of the dummy interface:
ip link show dummy0Create a dummy interface in Alibaba Cloud Linux 2
Alibaba Cloud Linux 2 uses the network service and supports creating dummy interfaces with ifcfg-* files.
Create the interface
Run the following command to create a dummy interface named dummy0:
sudo ip link add dummy0 type dummyReplace dummy0 with a name that matches your requirements.
After the command runs, a message may appear. Ignore it.

Configure an MTU
Create and open the
ifcfg-dummy0file:sudo vim /etc/sysconfig/network-scripts/ifcfg-dummy0Press
Ito enter Insert mode. Copy the following content into the file. Replace[$mtu]with the desired value. Valid values depend on the network interface type and driver. The default is1500.DEVICE="dummy0" BOOTPROTO="static" TYPE="Ethernet" ONBOOT="yes" PEERDNS="no" MTU=[$mtu]Press
Esc, type:wq, and pressEnterto save and close the file.Restart the
networkservice to apply the changes:sudo systemctl restart network
Verify the configuration
Check the interface state and MTU value:
ip link show dummy0Confirm that the mtu field in the output matches the value you set.