CaffeineAddict
Well-Known Member
Linux terminal command
It's is relatively new command that deprecates the following commands:
We'll examine output of the following commands
What does the output print and what does it mean?
Sample output:
The network interface name as a string
The network interface is loopback interface.
Definition: A telecommunications carrier network is the collection of devices and underlying infrastructure
used to transmit data from one location to another.
NO-CARRIER means NIC is not connected to gateway.
This interface supports broadcasting
This interface supports multicasting
Enabled when
When this option is enabled, the network interface will receive all multicast packets, not just those it is subscribed to.
This can be useful in promiscuous or monitor mode.
It's operational and connected, e.g. has IP address assigned and is connected to gateway
The hardware layer of the network (layer one) is UP
NIC is in promiscuous mode
Promiscuous mode is a network interface controller setting that allows it to receive all traffic,
not just the frames addressed to it.
It is used for packet sniffing, network monitoring etc.
Enabled when
The network interface avoids using trailer encapsulations, which is a method of encapsulating layer 2 network packets.
The Maximum Transfer Unit this interface supports
Queuing discipline
It schedules the transmission of packets.
There are different queuing techniques called disciplines, we'll name 2:
Example usage:
Possible states are:
Possible modes are:
What does mean DORMANT mode in ip link show wlan0?
Interfaces can be grouped logically
The default is to place them all in a group called "default"
Queue length.
The maximum length of the transmission queue of the NIC (not kernel backlog)
Example usage:
link columns are:
It indicates the MAC address that is assigned to the interface and does not change, even if the interface is temporarily assigned a different address.
Sample usage of the
The next command output we examine is
Sample output:
The IPv4 address and prefix length representing the subnet mask
The broadcast address for this subnet
The IP address scopes are
The routing protocol identifier, possible values are:
The IP address is lost when the interface goes down
Do not create a route in the route table when this IP address is added.
Someone has to add a route manually if they want to use one with this IP address.
Likewise, if this IP address is deleted, don't look for a route to delete.
The interface with which this IP address is associated
Valid lifetime.
For an IP address allocated by DHCP, this is the length of time the IP address is considered valid
and able to make and accept connection requests
Possible value is:
-
Preferred lifetime
For an IP address allocated by DHCP, this is the amount of time the IP address can be used with no restrictions.
This should never be larger than the
Possible value is:
-
Alternative name for a network interface, allowing the interface to have multiple names simultaneously.
This feature helps overcome naming limitations and can be used as a handle for commands.
The IPv6
The next command output we examine is
Sample output:
The default route
This route is used if none of the other rules match what's being sent
Routes the packets via the device at x.x.x.x
This is the IP address of the default router on this network
Use this network interface to send the packets to the router.
The routing protocol identifier, possible values are:
One of the scopes are:
The IP address from which packets sent by this route originate
An indication of the preference of the route compared to others.
Routes with lower metrics are preferentially used over those with higher metrics.
You can use this to give preference to a wired network interface over a Wi-Fi one.
Sample usage explains including the
ip is a Swiss knife command that lets you manage many aspects of your NIC's (Network Interface Card).It's is relatively new command that deprecates the following commands:
- arp (replacement:
ip n) - ifconfig (replacement:
ip) - nameif (replacement:
ip link) - route (replacement:
ip r)
ip command when run alone without any arguments (actually called objects) will print its usage.We'll examine output of the following commands
ip link, ip addr and ip route, these 3 are most common however there are many other usages and arguments:ip link outputWhat does the output print and what does it mean?
Sample output:
Bash:
ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether 6d:c1:6c:f9:f8:5d brd ff:ff:ff:ff:ff:ff
altname enx525400630940
NIC name (link)The network interface name as a string
LOOPBACKThe network interface is loopback interface.
NO-CARRIERDefinition: A telecommunications carrier network is the collection of devices and underlying infrastructure
used to transmit data from one location to another.
NO-CARRIER means NIC is not connected to gateway.
BROADCASTThis interface supports broadcasting
MULTICASTThis interface supports multicasting
ALLMULTIEnabled when
ip link set wlan0 allmulticast on is run.When this option is enabled, the network interface will receive all multicast packets, not just those it is subscribed to.
This can be useful in promiscuous or monitor mode.
UPIt's operational and connected, e.g. has IP address assigned and is connected to gateway
LOWER_UPThe hardware layer of the network (layer one) is UP
PROMISCNIC is in promiscuous mode
Promiscuous mode is a network interface controller setting that allows it to receive all traffic,
not just the frames addressed to it.
It is used for packet sniffing, network monitoring etc.
NOTRAILERSEnabled when
ip link set wlan0 trailers on is run.The network interface avoids using trailer encapsulations, which is a method of encapsulating layer 2 network packets.
mtuThe Maximum Transfer Unit this interface supports
qdiscQueuing discipline
It schedules the transmission of packets.
There are different queuing techniques called disciplines, we'll name 2:
noqueuediscipline means "send instantly, don't queue"fq_codeldiscipline means "Fair Queuing, Controlled Delay"
Example usage:
Bash:
# Show current qdisc (2 methods)
sudo tc qdisc show dev eth0
ip link
# Change qdisc temporarily
sudo tc qdisc add dev eth0 root fq_codel
# Change qdisc in NetworkManager (replace <CONN_NAME> with connection name from output)
nmcli connection show
nmcli connection modify <CONN_NAME> tc.qdiscs 'root fq_codel'
sudo systemctl restart NetworkManager
statePossible states are:
UPThe network interface operational and connectedDOWNThe network interface is not operationalUNKNOWNThe network interface is operational but nothing is connected
modePossible modes are:
DORMANTDEFAULT
What does mean DORMANT mode in ip link show wlan0?
groupInterfaces can be grouped logically
The default is to place them all in a group called "default"
qlenQueue length.
The maximum length of the transmission queue of the NIC (not kernel backlog)
Example usage:
Bash:
# Get txqueuelen of NIC
ip link show dev eth0
# Set txqueuelen
sudo ip link set txqueuelen 2000 dev eth0
# Get kernel backlog queue
sudo sysctl net.core.netdev_max_backlog
# Set kernel backlog queue and load config
echo "net.core.netdev_max_backlog = 2000" > /etc/sysctl.d/10-netdev_max_backlog.conf
sudo sysctl -p /etc/sysctl.d/10-netdev_max_backlog.conf
linklink columns are:
loopback(The NIC is loopback NIC,etheris00:00:00:00:00:00andbrdis00:00:00:00:00:00)ether(The media access control (MAC) address of the interface)brd (link)(Broadcast MAC address)permaddr
It indicates the MAC address that is assigned to the interface and does not change, even if the interface is temporarily assigned a different address.
Sample usage of the
ip link command:
Bash:
# Bring interface down (prior NIC configuration)
sudo ip link set eth0 down
# Bring interface up (after NIC configuration)
ip link set eth0 up
# Show details about interface
ip -details link show dev eth0
# Show details about interface in JSON and formatted output
ip -details -json -pretty link show dev ovsbr0
The next command output we examine is
ip addr, here's what the output means:Sample output:
Bash:
ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host noprefixroute
valid_lft forever preferred_lft forever
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 6d:c1:6c:f9:f8:5d brd ff:ff:ff:ff:ff:ff
altname enx525400630940
inet 172.31.44.100/24 brd 172.31.44.255 scope global enp1s0
valid_lft forever preferred_lft forever
inet6 fe80::5054:ff:fe63:940/64 scope link proto kernel_ll
valid_lft forever preferred_lft forever
inetThe IPv4 address and prefix length representing the subnet mask
brd (inet)The broadcast address for this subnet
scope (inet)The IP address scopes are
hostThe IP address is only valid inside the computer (the "host")linkThe IP address is limited to the network to which this computer is directly connectedglobalThe IP address is valid everywhere on this network
protoThe routing protocol identifier, possible values are:
dhcpMeans the routes will be determined dynamically (by DHCP)staticMeans the routes will be determined statically (by Administrator)kernelThe route created by the kernel during auto-configurationkernel_llLink-local addresses have this protocol value
dynamicThe IP address is lost when the interface goes down
noprefixrouteDo not create a route in the route table when this IP address is added.
Someone has to add a route manually if they want to use one with this IP address.
Likewise, if this IP address is deleted, don't look for a route to delete.
NIC name (inet)The interface with which this IP address is associated
valid_lftValid lifetime.
For an IP address allocated by DHCP, this is the length of time the IP address is considered valid
and able to make and accept connection requests
Possible value is:
-
foreverpreferred_lftPreferred lifetime
For an IP address allocated by DHCP, this is the amount of time the IP address can be used with no restrictions.
This should never be larger than the
valid_lft value.Possible value is:
-
foreveraltnameAlternative name for a network interface, allowing the interface to have multiple names simultaneously.
This feature helps overcome naming limitations and can be used as a handle for commands.
inet6The IPv6
address, scope , valid_lft, and preferred_lftip addr sample usage:
Bash:
# Delete single IP from interface
sudo ip addr del 10.10.10.20/24 dev eth0
# Delete all IP's from interface
sudo ip addr flush dev eth0
# Assign IP to interface
sudo ip addr add 10.10.10.1/24 brd 10.10.10.10 dev eth0
# Show IP configuration of a NIC
ip link addr show dev eth0
ip link addr show eth0
The next command output we examine is
ip route, here's what the output means:Sample output:
Bash:
ip route
default via 172.41.33.1 dev enp1s0 onlink
172.41.33.0/24 dev enp1s0 proto kernel scope link src 172.41.33.22
defaultThe default route
This route is used if none of the other rules match what's being sent
viaRoutes the packets via the device at x.x.x.x
This is the IP address of the default router on this network
devUse this network interface to send the packets to the router.
protoThe routing protocol identifier, possible values are:
dhcpMeans the routes will be determined dynamically (by DHCP)staticMeans the routes will be determined statically (by Administrator)kernelThe route created by the kernel during auto-configurationkernel_llLink-local addresses have this protocol value
scope (route)One of the scopes are:
link The scope is limited to the immediate network to which this computer is connectedsrcThe IP address from which packets sent by this route originate
metricAn indication of the preference of the route compared to others.
Routes with lower metrics are preferentially used over those with higher metrics.
You can use this to give preference to a wired network interface over a Wi-Fi one.
onlinkSample usage explains including the
onlink usage is better than words:
Bash:
# Show routing tables
ip route show
ip route
ip r
# Add route
ip route add {NETWORK/MASK} via {GATEWAYIP}
ip route add {NETWORK/MASK} dev {DEVICE}
ip route add default {NETWORK/MASK} dev {DEVICE}
ip route add default {NETWORK/MASK} via {GATEWAYIP}
# When adding route for disconnected but configured interface
ip route add default via {GATEWAYIP} dev {DEVICENAME} onlink
ip route add default via {GATEWAYIP} dev {DEVICENAME} proto dhcp src {DEVICEIP} metric {METRIC} onlink
# Flush routing table
ip route flush table main
Last edited:

