All Products
Search
Document Center

Alibaba Cloud Linux:Create a dummy interface

Last Updated:Aug 15, 2024

In Alibaba Cloud Linux, a dummy interface is a virtual interface that behaves like a real network interface for testing purposes. A dummy interface provides a device to route packets through without actually transmitting the packets. This topic describes how to create a dummy interface in Alibaba Cloud Linux 2 and 3 and configure a maximum transmission unit (MTU) for the interface.

Create a dummy interface in Alibaba Cloud Linux 3

Warning

In Alibaba Cloud Linux 3, NetworkManager works as the network service and does not allow you to create dummy interfaces by using ifcfg-* files. To create dummy interfaces in Alibaba Cloud Linux 3, run nmcli commands or modify configuration files.

  • Create a dummy interface by running an nmcli command

    dummy0: the name of the dummy interface. Specify a name for the dummy interface based on your business requirements.

    sudo nmcli connection add con-name dummy0 type dummy ifname dummy0
  • Configure an MTU for the dummy interface

    Run an nmcli command to configure an MTU

    1. Run the following command to configure an MTU.

      Replace [$mtu] with a desired MTU value. The valid MTU values vary based on the network interface type and the driver. The default MTU value is 1500.

      sudo nmcli c modify dummy0 802-3-ethernet.mtu [$mtu]
    2. Run the following command to restart NetworkManager:

      sudo systemctl restart NetworkManager
    3. Run the following commands to reconnect to the dummy0 interface to make the configurations take effect:

      sudo nmcli c down dummy0
      sudo nmcli c up dummy0
    4. Run the following command to view the MTU value of the dummy interface:

      ip link show dummy0

    Modify the dummy0.nmconnection configuration file to configure an MTU

    1. Run the following command to create the dummy0 device and the dummy0 connection:

      sudo nmcli connection add con-name dummy0 type dummy ifname dummy0
    2. Run the following commands to view the created dummy0 connection and dummy0 device:

      nmcli c
      nmcli d
    3. Run the following command to open the dummy0.nmconnection file:

      sudo vim /etc/NetworkManager/system-connections/dummy0.nmconnection
    4. Press the I key to enter Insert mode and add the mtu parameter or change the value of the parameter.

      Replace [$mtu] with a desired MTU value. The valid MTU values vary based on the network interface type and the driver. The default MTU value is 1500.

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

    6. Run the following command to restart NetworkManager:

      sudo systemctl restart NetworkManager
    7. Run the following commands to reconnect to the dummy0 interface to make the configurations take effect:

      sudo nmcli c down dummy0
      sudo nmcli c up dummy0
    8. Run the following command to view the MTU value of the dummy interface:

      ip link show dummy0

Create a dummy interface in Alibaba Cloud Linux 2

  • Create a dummy interface

    dummy0: the name of the dummy interface. Specify a name for the dummy interface based on your business requirements.

    sudo ip link add dummy0 type dummy

    After you create the dummy interface, the following message appears. Ignore the message.

    image

  • Configure an MTU for the dummy interface

    1. Run the following command to create and open the ifcfg-dummy0 file:

      sudo vim /etc/sysconfig/network-scripts/ifcfg-dummy0
    2. Press the I key to enter Insert mode and copy the following content to the ifcfg-dummy0 file:

      Replace [$mtu] with a desired MTU value. The valid MTU values vary based on the network interface type and the driver. The default MTU value is 1500.

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

    4. Run the following command to restart the network service to make the configurations take effect:

      sudo systemctl restart network
    5. Run the following command to view the dummy0 device and the MTU value of the device:

      ip link show dummy0