How to Add Network Interface in Linux

How to Add Network Interface in Linux

If you want to know how to add network interface in linux, the short answer is that you usually create it with the ip command for a temporary change, or configure it through your network manager for a persistent one. In Linux, “adding” a network interface can mean creating a virtual interface, bringing up an existing one, or assigning an address to it, so the right method depends on what you actually need.

What adding a network interface means in Linux

What adding a network interface means in Linux

A Linux network interface is any device or virtual endpoint the system can use to send and receive network traffic. That can include physical adapters such as eth0 or enp3s0, but also virtual interfaces such as bridges, VLANs, dummy interfaces, tunnels, and loopback-related configurations.

People often use “add a network interface” to mean one of three different tasks:

  • Create a new virtual interface, such as a bridge, VLAN, or dummy interface.
  • Bring an existing interface up so it becomes active.
  • Assign an IP address to an interface that already exists.

If you are not sure which one applies, the safest approach is to inspect your current interfaces first and then choose the appropriate command.

Check existing interfaces first

Before you create anything new, list the current interfaces so you can see what already exists:

ip link show

To see IP addresses as well:

ip addr show

These commands help you confirm whether you need to create a new interface, enable an existing one, or only add an address.

How to add a network interface with ip

How to add a network interface with ip

The ip command from iproute2 is the standard tool for managing interfaces on modern Linux systems. It is the best starting point when you want to create a temporary interface or test a configuration.

Create a dummy interface

A dummy interface is a virtual interface that does not connect to hardware. It is useful for testing, routing experiments, or services that expect a network device to exist.

sudo ip link add dummy0 type dummy

Then bring it up:

sudo ip link set dummy0 up

Optionally assign an IP address:

sudo ip addr add 192.0.2.10/24 dev dummy0

Create a VLAN interface

If you need a tagged VLAN subinterface, create it on top of a parent device. Replace eth0 with your real interface and 100 with your VLAN ID:

sudo ip link add link eth0 name eth0.100 type vlan id 100

Bring it up and add an address:

sudo ip link set eth0.100 up
sudo ip addr add 192.0.2.20/24 dev eth0.100

Create a bridge interface

Bridges are common in virtualization and container setups. They allow multiple interfaces or guests to share a Layer 2 network segment.

sudo ip link add name br0 type bridge
sudo ip link set br0 up

If you want to attach a physical interface to the bridge, add the port after creating the bridge:

sudo ip link set eth0 master br0
sudo ip link set eth0 up

Then assign the IP address to the bridge, not to the enslaved physical port:

sudo ip addr add 192.0.2.30/24 dev br0

Create a macvlan interface

A macvlan interface gives a system or container its own MAC address on the same physical network. This is sometimes used for advanced lab or container networking.

sudo ip link add link eth0 name macvlan0 type macvlan mode bridge
sudo ip link set macvlan0 up
sudo ip addr add 192.0.2.40/24 dev macvlan0

Bring an existing interface up

If the interface already exists but is down, you do not need to create a new one. Just enable it:

sudo ip link set eth0 up

After that, check whether it received an address automatically, or assign one manually if needed.

Assign an IP address to an interface

Assign an IP address to an interface

Adding a network interface is not the same as giving it an IP address. If the interface already exists, you may only need to add the address:

sudo ip addr add 192.0.2.50/24 dev eth0

If you need a default route too, add that separately:

sudo ip route add default via 192.0.2.1

This distinction matters because many setup problems come from creating the interface correctly but forgetting the address or route.

How to make the interface persistent

Commands such as ip link add and ip addr add are often temporary. In many cases, the interface disappears after reboot unless you configure persistence through your network management system.

Using NetworkManager

If your system uses NetworkManager, you can create persistent connections with nmcli. The exact command depends on the interface type.

Example for a VLAN:

sudo nmcli connection add type vlan con-name vlan100 dev eth0 id 100 ip4 192.0.2.20/24 gw4 192.0.2.1

Example for a bridge:

sudo nmcli connection add type bridge con-name br0 ifname br0
sudo nmcli connection add type ethernet con-name br0-port ifname eth0 master br0

NetworkManager is often the easiest option on desktop distributions and many server installations that use it by default.

Using systemd-networkd

On systems that use systemd-networkd, persistence is usually handled with configuration files in /etc/systemd/network/. The exact files depend on the interface type. For example, a bridge requires a .netdev file for the bridge itself and a .network file to attach addresses or ports.

Because the configuration varies by interface type and distribution policy, it is best to follow your distro’s networkd format carefully rather than copying a one-size-fits-all file. The key point is that systemd-networkd can recreate the interface automatically at boot.

Using netplan on Ubuntu-based systems

On Ubuntu and some related systems, netplan may sit on top of NetworkManager or systemd-networkd. In that case, you define the interface in a YAML file and apply it with:

sudo netplan apply

Netplan is especially useful when you want settings to survive reboot without manually re-running ip commands.

How to verify the interface is working

How to verify the interface is working

After creating or enabling the interface, verify three things: that it exists, that it is up, and that it has the right address or link state.

  1. Check the interface name
ip link show
  1. Check the IP configuration
ip addr show dev dummy0
  1. Check routing, if relevant
ip route show
  1. Test connectivity
ping -c 3 192.0.2.1

If the interface is for local-only testing, you may not need internet access, but you should still confirm the interface has the expected address and is administratively up.

When to use ip, NetworkManager, or systemd-networkd

The best tool depends on your goal and environment.

ToolBest forPersistenceNotes
ipQuick tests, temporary interfaces, debuggingNo, usually temporaryFast and standard on all modern Linux systems
NetworkManagerDesktop and many server installsYesUse nmcli or a graphical tool
systemd-networkdLean server setups and controlled environmentsYesConfigured with files under /etc/systemd/network/
netplanUbuntu-based systems using YAML configYesApplies settings to NetworkManager or networkd

Common problems and fixes

Permission denied

Most interface changes require root privileges. Run the command with sudo or switch to a root shell.

Cannot find device

This usually means the parent interface name is wrong, or the physical adapter is not present. Double-check the name with ip link show.

Operation not supported

Some interface types require kernel support or specific modules. If a command fails, check whether the relevant kernel feature is available and whether the interface type is supported on your system.

Interface disappears after reboot

That usually means you used ip commands only. Recreate the interface with NetworkManager, systemd-networkd, netplan, or your distro’s persistent network configuration method.

No connectivity after creating the interface

Creating the interface is only part of the job. Make sure the interface is up, has an IP address, and has the correct route or bridge attachment if needed.

Practical examples of what people usually mean

If someone asks how to add a network interface in Linux, they are often trying to do one of these things:

  • Add a temporary dummy interface for testing.
  • Create a VLAN subinterface for a tagged network.
  • Set up a bridge for a VM host.
  • Bring a disabled physical NIC online.
  • Add an IP address to an existing interface.

Knowing which case applies saves time and prevents configuration mistakes.

Best practices

  • Use ip link show and ip addr show before making changes.
  • Prefer ip for temporary changes and troubleshooting.
  • Use your system’s persistent network manager for long-term settings.
  • Assign IP addresses to the correct interface type, especially when bridges are involved.
  • Verify routes and DNS if the interface is meant for real network access.

Frequently Asked Questions About how to add network interface in linux

How do I add a network interface in Linux?

Use ip link add for a new virtual interface, then bring it up with ip link set up. If the interface already exists, you may only need to enable it or assign an IP address.

How do I create a virtual network interface in Linux?

Common examples include dummy, bridge, VLAN, and macvlan interfaces. The exact ip link add syntax depends on the type you want to create.

How do I make a network interface persistent in Linux?

Use a persistent configuration system such as NetworkManager, systemd-networkd, or netplan. Commands entered with ip usually do not survive a reboot.

What is the difference between ip link add and ip addr add?

ip link add creates an interface, while ip addr add assigns an IP address to an existing interface. They solve different parts of the setup process.

How do I check if a Linux network interface was created successfully?

Run ip link show to confirm the interface exists, then ip addr show dev to verify it has the right status and address.

Why does my new interface disappear after reboot?

Because it was created only with temporary ip commands. Save the configuration in NetworkManager, systemd-networkd, netplan, or your distro’s persistent network files.

Conclusion

To add a network interface in Linux, first decide whether you need a new virtual interface, a disabled interface brought online, or just an IP address on an existing device. For temporary work, ip is the fastest tool. For a setup that should persist, use NetworkManager, systemd-networkd, or netplan depending on your distribution. The key is to verify the interface name, status, address, and route after making the change.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *