Create a dummy interface

Updated at:

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 dummy0

Replace dummy0 with a name that matches your requirements.

Configure an MTU

Choose one of the following methods.

Option 1: Use an nmcli command

  1. Set the MTU value. Replace [$mtu] with the desired value. Valid values depend on the network interface type and driver. The default is 1500.

    sudo nmcli c modify dummy0 802-3-ethernet.mtu [$mtu]
  2. Restart NetworkManager:

    sudo systemctl restart NetworkManager
  3. Reconnect to the dummy0 interface to apply the changes:

    sudo nmcli c down dummy0
    sudo nmcli c up dummy0

Option 2: Edit the configuration file

  1. Create the dummy0 device and connection:

    sudo nmcli connection add con-name dummy0 type dummy ifname dummy0
  2. Verify that the connection and device were created:

    nmcli c
    nmcli d
  3. Open the dummy0.nmconnection file:

    sudo vim /etc/NetworkManager/system-connections/dummy0.nmconnection
  4. Press I to enter Insert mode. Add or update the mtu parameter in the [ethernet] section. Replace [$mtu] with the desired value. Valid values depend on the network interface type and driver. The default is 1500.

    [ethernet]
    mtu=[$mtu]
  5. Press Esc, type :wq, and press Enter to save and close the file.

  6. Restart NetworkManager:

    sudo systemctl restart NetworkManager
  7. Reconnect to the dummy0 interface 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 dummy0

Create 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 dummy

Replace dummy0 with a name that matches your requirements.

After the command runs, a message may appear. Ignore it.

image

Configure an MTU

  1. Create and open the ifcfg-dummy0 file:

    sudo vim /etc/sysconfig/network-scripts/ifcfg-dummy0
  2. Press I to 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 is 1500.

    DEVICE="dummy0"
    BOOTPROTO="static"
    TYPE="Ethernet"
    ONBOOT="yes"
    PEERDNS="no"
    MTU=[$mtu]
  3. Press Esc, type :wq, and press Enter to save and close the file.

  4. Restart the network service to apply the changes:

    sudo systemctl restart network

Verify the configuration

Check the interface state and MTU value:

ip link show dummy0

Confirm that the mtu field in the output matches the value you set.