ip-link
Manage network interfaces
TLDR
Show information about all network interfaces
Show information about a specific network interface
Bring a network interface up or down
Give a meaningful name to a network interface
Change the MAC address of a network interface
Change the MTU size for a network interface to use jumbo frames
Set the promisc mode status of a device
SYNOPSIS
ip link show [DEV] [OPTIONS]
ip link set DEV { up | down | mtu NUMBER | name NEWNAME | alias NAME | qlen NUMBER | address LLADDR | master DEV | nomaster | netns { PID | NAME } | promisc { on | off } | ... }
ip link add NAME type TYPE [OPTIONS]
ip link delete DEV [OPTIONS]
PARAMETERS
show DEV
Display information for a specific network device. If DEV is omitted, all network devices are shown.
show up
Only display interfaces that are currently in an 'up' state.
show -s, -stats
Display detailed statistics for each interface, including byte counts, packet counts, and error rates.
set DEV up
Administratively bring the specified network interface to an 'up' (active) state.
set DEV down
Administratively bring the specified network interface to a 'down' (inactive) state.
set DEV mtu NUMBER
Set the Maximum Transmission Unit (MTU) for the specified interface to NUMBER bytes.
set DEV name NEWNAME
Rename the network interface DEV to NEWNAME.
set DEV address LLADDR
Set the link-layer (MAC) address of the interface DEV to LLADDR.
set DEV master MASTER_DEV
Enslave the interface DEV to a master device like a bridge or bond interface.
set DEV netns {PID | NAME}
Move the interface DEV into a different network namespace identified by its process ID (PID) or name (NAME).
set DEV promisc {on | off}
Enable or disable promiscuous mode for the interface, allowing it to receive all network traffic, regardless of destination MAC address.
add NAME type TYPE
Create a new network link named NAME of a specified TYPE (e.g., `vlan`, `bridge`, `veth`, `dummy`).
add type vlan link DEV id VLAN_ID
Create a new VLAN interface on parent device DEV with the specified VLAN tag VLAN_ID.
add type veth name DEV1 peer name DEV2
Create a new virtual Ethernet (veth) pair, with one end named DEV1 and the other DEV2.
delete DEV
Delete the specified network device DEV.
DESCRIPTION
The `ip link` command is a fundamental subcommand of the `ip` utility in Linux, part of the `iproute2` suite, designed for comprehensive management of network interfaces, also known as network links or devices. It supersedes older tools like `ifconfig` by offering a more robust, flexible, and feature-rich interface to the kernel's networking subsystem via Netlink sockets. This command allows administrators to inspect the status of network devices, bring them up or down, set their Maximum Transmission Unit (MTU), change their MAC address, rename them, and assign them to specific network namespaces. Beyond basic configuration, `ip link` is pivotal for creating and configuring various virtual network devices, including VLANs, bridges, bonding interfaces, virtual Ethernet (veth) pairs, and different types of tunnels. Its object-oriented design and deep integration with the Linux kernel make it an indispensable tool for modern network administration, troubleshooting, and for building complex network setups, especially in virtualized and containerized environments.
CAVEATS
Most `ip link` operations that modify network configuration require root privileges. Changing interface names or other critical parameters can temporarily disrupt network services. By default, changes made with `ip link` are not persistent across system reboots; system-specific configuration files (e.g., in `/etc/network/interfaces`, `/etc/sysconfig/network-scripts`, or via `systemd-networkd`) must be used to make changes permanent.
LINK TYPES
`ip link add` supports numerous link types, enabling the creation of various virtual interfaces. Some common types include:
- vlan: Creates a Virtual LAN interface with a specific ID, typically on a parent physical interface.
- bridge: Creates a software bridge, allowing multiple network segments to be connected and act as a single network.
- bond: Creates a bonding interface for link aggregation (NIC teaming), combining multiple physical interfaces for redundancy or increased throughput.
- dummy: Creates a simple loopback-like interface, useful for testing or providing a stable interface for IP addresses.
- veth: Creates a virtual Ethernet pair, commonly used to connect network namespaces or containers to the host network.
- macvlan, macvtap: Create virtual interfaces that share a single physical interface, each with its own MAC address, providing a way to isolate network traffic.
- tun, tap: Tunnel devices that provide a network interface for user-space programs, often used for VPNs.
NETWORK NAMESPACES INTEGRATION
`ip link` is crucial for managing network interfaces within different network namespaces, which provide isolated network environments. The command `ip link set DEV netns {PID | NAME}` is used to move an existing interface into a specified network namespace. This functionality is fundamental for containerization technologies like Docker and LXC, allowing each container to have its own isolated network stack and interfaces without interfering with the host or other containers.
HISTORY
The `ip` utility, including `ip link`, was developed as part of the `iproute2` suite in the late 1990s. It was designed to replace older, less capable tools like `ifconfig`, `route`, and `arp`, which were part of the `net-tools` package. `iproute2` leverages the Linux kernel's Netlink socket interface, providing a more robust, extensible, and efficient way to manage networking. `ip link` specifically addresses the limitations of `ifconfig` by offering better support for modern networking features like network namespaces, VLAN tagging, bonding, and a more consistent object-oriented approach to network configuration. It has become the standard command-line tool for network interface management in modern Linux distributions.