Computer Data NetworkThis section of Linux network configuration commands deals with the most common methods of configuring a system’s network interfaces from the command line.

It is not a complete list of commands, nor are all possible details and options discussed.

This way you have a little space to do some exploring on your own, and can enjoy the thrill that comes with successfully completing a configuration all on your own.

The ifup Command

The ifup command brings a network interface up if it is down.

Example: ifup enp3s0

The -a option will bring all network interfaces up.

The ifdown Command

The ifdown takes a network interface down if it is up.

Example: ifdown enp3s0

The -a option will take all network interfaces down.

The ifconfig Command

The ifconfig command is used to configure a network interface. It stands for “interface configuration”.

The command itself will show details about each network interface in operation. Example: ifconfig

Use the -a option to show all network interfaces, whether or not they are currently in operation. Example: ifconfig -a

Use a specific interface name, to view only its own configuration. Example: ifconfig enp3s0

Use up and down to activate and/or deactivate a network interface. Example: ifconfig enp3s0 up or ifconfig enp3s0 down

To configure a network interface, use ifconfig, together with the interface to configure, the field to configure, and the new/updated configuration.

To configure an IP Address: ifconfig enp3s0

To configure the Network Mask: ifconfig enp3s0 netmask

To configure the Broadcast Address: ifconfig enp3s0 broadcast

All Together Now: sudo ifconfig enp3s0 netmask broadcast

Note: While static IPs can be assigned with ifconfig, dhclient should be used to obtain a dynamic IP address.

Note: The ifconfig command is obsolete, although it still works on most distributions. It is suggested that the ip command, or the ifcfg command, should be used in place of ifconfig.

The iwconfig Command

The iwconfig command is similar to ifconfig, but differs in that it configures only wireless network interfaces.

It is used to set parameters specific to wireless operation, such as frequency and modulation.

The ifcfg Command

The ifcfg command is a simplistic script which replaces ifconfig IP management.

The basic options are to add, delete (del), or stop an IP address.

The syntax is the command, the interface name, the option, and then the IP.

Examples: ifcfg enp3s0 del and ifcfg enp3s0 add

The ip Command

The ip command displays and manipulates “routing, devices, policy routing and tunnels”.

It replaces the ifconfig command, so it should be used to configure network interfaces.

The syntax of the command is: ip [ OPTIONS ] OBJECT { COMMAND | help }

The available objects are:
address – protocol (IP or IPv6) address on a device.
addrlabel – label configuration for protocol address selection.
l2tp – tunnel ethernet over IP (L2TPv3).
link – network device.
maddress – multicast address.
monitor – watch for netlink messages.
mroute – multicast routing cache entry.
mrule – rule in multicast routing policy database.
neighbour – manage ARP or NDISC cache entries.
netns – manage network namespaces.
ntable – manage the neighbor cache’s operation.
route – routing table entry.
rule – rule in routing policy database.
tcp_metrics/tcpmetrics – manage TCP Metrics
tunnel – tunnel over IP.
tuntap – manage TUN/TAP devices.
xfrm – manage IPSec policies.

Most objects allow the commands add, delete, show, or list.

The dhclient Command

The dhclient command is a “Dynamic Host Configuration Protocol Client”, meaning that it calls on the DHCP server for a dynamic IP address.

Use dhclient -r to release a current/existing IP address “lease”, and dhclient to request a new “lease”.

In some cases, it is necessary to specify which interface (which network card, etc.) should be renewed: dhclient -r enp3s0 and dhclient enp3s0

The nmcli Command

The nmcli command is a command-line tool for controlling NetworkManager and reporting on the network status. The command stands for Network Manager Command Line Interface.

It can be used to create, display, edit, delete, activate, and deactivate network connections, as well as control and display network device statuses.

Entering nmcli into the command line on its own will display a summary of usage options.

Alternatively, to see a variety of actions that can be performed with this command, type nmcli into the command line, but do not execute (press Enter) right away… instead, hit the Tab key once or twice.

When the list of available actions appears, type one in, then hit the Tab key again for further actions based on the action that you selected.

Repeat until no further actions/arguments are available. The argument choices are either self-explanatory or available for experimentation.

Use the -p option to pretty up the output so that it is easily readable.

Some examples of how the command can be put together are:

nmcli general status

nmcli connection show

nmcli device status

nmcli -p device show enp3s0

The details required to actually configure network devices with the nmcli command are more involved. Try the man command for details.

The nc Command

The nc — or netcat — command “concatenates and redirects sockets”.

It is used to debug and investigate a network, usually through TCP/UDP connections.

The netstat Command

The netstat command is used to print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships.

Typing in the netstat command on its own will display statistics about network activity on the system.

The netstat command is mostly obsolete, replaced with the ss and/or ip commands.

The ss Command

The ss command is another utility to investigate sockets. It is used to dump socket statistics, allowing the display of information similar to netstat. It can display more TCP and state information than any other tool.

The iptables Command

Iptables are an “administration tool for IPv4/IPv6 packet filtering and NAT”… so basically it’s a flexible, customizable firewall utility built into Linux.

It’s a large topic, beyond the scope of today’s attention-span. We may get back to this later, but feel free to do some research in the meantime.

The route Command

The route command is used to show and/or manipulate the IP routing table.

Typing in route -n will display the kernel IP routing table.

This command, while it may still work, is obsolete, and the ip command should be used instead.

The arp Command

The arp command manipulates the system ARP cache.

ARP stands for Address Resolution Protocol, which is used to find the media access control address of a network neighbour for a given IPv4 Address.

The arp command is obsolete, replaced with the ip neigh command.

The ethtool Command

The ethtool command queries or controls network drivers and hardware settings.

Use the command along with a device name, to display the settings for that device: ethtool enp3s0

The command can be used to change device settings until the next reboot; files have to be edited for changes to become permanent.


These commands may help you to set up your network interfaces with the proper settings and configurations, but how do you know if it worked?

Next week, we’ll discuss various management commands that will enable testing — and various other tasks — to be performed.