Networking is a core part of Linux system administration. Whether you are setting up a server, connecting to the internet, or troubleshooting issues, knowing how to configure and test network settings is essential. Linux provides powerful command-line tools to help you manage IP addresses, test connectivity, and control how your system interacts with the network.
In this guide, you will learn how to configure IP addresses, view and manage network interfaces, test connections using ping
and traceroute
, set up DNS, and understand the differences between older tools like ifconfig
and modern alternatives like ip
.
If you are new to Linux, be sure to review our previous article on Shell Scripting and Automation, where we introduced basic terminal commands, variables, and automation tools. A strong terminal foundation makes networking tasks easier to understand and perform.
Linux IP Configuration
To assign or view an IP address in Linux, you can use either the older ifconfi
g
command or the newer ip
command. Most modern distributions prefer ip
because it offers more flexibility and is actively maintained.
Before running commands, it is useful to check your current IP configuration.
To check the current IP address using ip
:
ip address show

This displays all network interfaces, their assigned IP addresses, and status (UP or DOWN).
To assign a new IP address to a network interface, you must first know the interface name. Common names include eth0
, enp0s3
, or wlan0
.
To assign an IP address temporarily (will reset after reboot):
sudo ip addr add 192.168.1.100/24 dev enp0s3
To bring the interface up or down:
sudo ip link set enp0s3 up
sudo ip link set enp0s3 down
To remove an assigned IP address:
sudo ip addr del 192.168.1.100/24 dev enp0s3
If you prefer using the traditional method, you can still use ifconfig
if it is installed:
ifconfig enp0s3 192.168.1.100 netmask 255.255.255.0 up
However, many systems do not include ifconfig
by default. You can install it with:
sudo apt install net-tools
Network Interfaces in Linux
Network interfaces are the bridge between your Linux system and the outside world. These include physical ports (Ethernet or Wi-Fi) and virtual interfaces like loopback (lo
).
To list all available network interfaces:
ip link show

Each interface will have a unique name and status. You can see if an interface is active or disconnected.
To rename or configure a persistent interface name, you typically edit network configuration files depending on your Linux distribution. On Debian-based systems, interface settings are often located in /etc/network/interfaces
or managed by netplan
.
For example, to view the current connection information using nmcli
, the NetworkManager command-line tool:
nmcli device show

If you use a minimal system or a server, you may not have NetworkManager running. In that case, use ip
, ifconfig
, or configuration files under /etc
.
Using Ping and Traceroute to Test Network Connections
To test if a network is reachable, use the ping
command. It sends small packets to a remote host and checks if they are returned.
To ping a website:
ping google.com

To limit the number of packets sent:
ping -c 4 google.com
This sends four pings and then stops. You can use this to check basic connectivity to a remote server or IP address.
If ping
fails, it could indicate a DNS issue, unreachable gateway, or firewall restriction.
To trace the path packets take to a destination, use traceroute
:
traceroute google.com

This command shows each hop (router or server) your data passes through before reaching its destination. If you get stuck or delayed at one hop, that may be the point of failure.
If traceroute
is not installed:
sudo apt install traceroute
These tools help diagnose slow connections, unreachable networks, or misconfigured routes.
DNS Configuration in Linux
DNS (Domain Name System) translates domain names like example.com
into IP addresses. If DNS is not working, you will not be able to browse websites or reach servers using domain names.
To check your current DNS configuration:
cat /etc/resolv.conf
This file usually lists one or more nameservers:
nameserver 8.8.8.8
nameserver 1.1.1.1
These IP addresses belong to public DNS providers like Google and Cloudflare. If this file is empty or incorrect, you may not be able to resolve domain names.
To temporarily change DNS, you can edit this file directly:
sudo nano /etc/resolv.conf
Then add:
nameserver 8.8.8.8
nameserver 1.1.1.1
Save and exit out of the editor. These changes may be overwritten by network managers on reboot, so for permanent changes, update your network configuration files (like netplan
or NetworkManager
profiles) depending on your distribution.
ifconfig vs ip: Which One to Use?
The ifconfig
tool was used for decades to configure network interfaces. However, it is no longer maintained and is being replaced by the ip
command from the iproute2
package.
Here are some equivalent commands:
- View all interfaces:
ifconfig
ip addr show
- Assign IP address:
ifconfig eth0 192.168.1.100
ip addr add 192.168.1.100/24 dev eth0
- Bring interface up:
ifconfig eth0 up
ip link set eth0 up
Because ip
is more powerful and better supported, it is recommended for all new scripts and tools. However, ifconfig
is still useful for quick checks on older systems.
Summary
Networking in Linux is built on a set of powerful tools that let you configure, test, and troubleshoot connections from the command line. You now know how to:
- Assign and view IP addresses using
ip
andifconfig
- Identify and manage network interfaces
- Use
ping
andtraceroute
to test connectivity - Configure DNS through
/etc/resolv.conf
- Understand why
ip
is preferred overifconfig
These skills are essential whether you are running a home server, managing remote machines, or setting up services that depend on a reliable network.
If you want to automate your network tests or generate reports, combine these commands with the scripting knowledge from our earlier article on Shell Scripting & Automation in Linux.
In the next article, we will see more about networking with the help of netstat and ss commands.