Introduction
One of the most fundamental topics is to understand networking basics.
It is a very crucial aspect to understand the way networking works in Linux,
whether you are configuring servers, troubleshooting a network that is not
connecting, or even just setting up a local network. This guide will help beginners and system
administrators to understand how to configure, manage and troubleshoot
networking issues in Linux systems and covers some basic settings, such as how
to assign IP address, gateway, DNS, configure a hostname and how to add or
delete routes.
In this Linux Basic Networking for Beginners - 2025 Complete Guide, you
have a step-by-step guide on how to view network configurations, manage network
configurations and troubleshoot the network configurations using simple but
powerful Linux commands. We will go through all the operations of checking the
current network settings to assigning IPs, routes, and troubleshooting
connectivity. At the end of this guide as a system administrator, you will be in a better
position to implement networking basics and troubleshooting.
1. What
Networking Means in Linux
Networking is the process of connecting systems to other computers or
devices so they can exchange data. This connection can be local within the same
network or globally connected through the internet. Linux has powerful built-in
tools that allow users to configure, manage and monitor these network
connections efficiently. Networking in Linux is to understand how your system communicates using
the network interface, IP address and routing table. Every piece plays an important role in
sending and receiving data packets across networks.
Network
interfaces
A network interface serves as a point of connection between a device or
computer and a network. Linux includes physical interfaces such as eth0 or
wlan0, and virtual interfaces such as loopback (lo) and br0 (bridge). You can
view the available interfaces using:
1. Using ifconfig
#ifconfig

2. Using the ip
command
#ip a

IP
Addresses
An IP address is fundamental for network connectivity, and every device
connected to a network needs a unique one. It is used to identify and route
data to the correct system on the network. Linux supports both IPv4 and IPv6
addressing. You can view your system’s IP address details using the ifconfig,
ip a, or ip addr show command.
#ip addr show
Routing
In Linux, routing is a process of determining the path that a network
packet takes to reach its destination. The Linux kernel maintains a routing
table to decide where to send outgoing packets. You can display the routing
table details using the following command.
#route
Or
#route -n

Linux
Network Configuration Files and Tools
Linux network settings can be managed both by command-line utilities and
configuration files. Common files and tools are:
|
Tool/File
|
Purpose
|
|
/etc/network/interfaces
|
Stores
static network configurations (Debian/Ubuntu old version)
|
|
/etc/netplan
|
Stores
static network configurations (Debian/Ubuntu new version)
|
|
/etc/sysconfig/network-scripts/ifcfg-*
|
Network
interface configs (RHEL/CentOS)
|
|
/etc/resolv.conf
|
DNS
configuration
|
|
/etc/hostname
|
System
hostname
|
|
ip
/ ifconfig
|
Manage
interfaces and IPs
|
|
Nmcli
/ nmtui
|
Network
Manager command-line and text UI tools
|
|
Ping,
traceroute, netstat
|
Troubleshooting
and monitoring tools
|
3.
Key Networking Concepts in Linux
Before configuring and troubleshooting a Linux network, one should be
familiar with the fundamental concepts that form the basis of system
communication with one another. These are IP address, subnet mask, gateway,
DNS, and hostname, which are common terminologies used in the network setup and
also key to any Linux user.
IP
Address (IPv4 / IPv6)
An IP address (Internet Protocol) is a unique identifier assigned to
every device on the network. It tells the systems where to send data.
- IPv4 uses a 32-bit format (e.g., 192.168.1.8)
- IPv6 uses a 128-bit format (e.g., fe08::2ff::fe23::4567::890b)
You can check your IP address in Linux using commands like ifconifg or
ip addr show.
Subnet
Mask
A subnet mask differentiates between the host portion and network
portion in an IP address. It helps Linux
to understand which systems are on the local network and which systems need
routing through the gateway.
Common examples include:
- 255.255.255.0 (For small local networks)
- CIDR notation: /24 (equivalent to 255.255.255.0)
For example:
Your IP is 192.168.1.7 and subnet mask 255.255.255.0, it means your
device can directly communicate with any system in the range 192.168.1.1 –
192.168.1.254.
Gateway
A gateway is a device or router that connects your local network to
other networks or the internet. It acts as an exit door for packets that need
to travel outside your network.
You can view your current gateway using ip route show or route -n
command.
DNS
(Domain Name System)
DNS translates human-readable domains into IP addresses that computers
understand, like seeklinux.net to IP address. DNS configuration is stored in /etc/resolv.conf
in Linux. 
When you ping google.com DNS first resolves it to an IP address (e.g.,
142.250.183.110).
Hostname
A hostname is the name you assigned to your Linux system to uniquely identify
it on the network. It's like a label that makes your device recognizable,
rather than its IP address.
To view
the hostname
Sudo hostnamectl set-hostname your hostname to set or change hostname
4.
Viewing Network Information in LinuxBefore making any changes to network configuration, it is important to
understand the current network setup. Linux provides several commands that
allow you to view interface details, assigned IP addresses and routing
information. These tools help you to verify connectivity, troubleshoot issues
and confirm changes in configurations.
1.
Check Current Network Configuration using ip addr show
The ip command is more reliable for viewing and managing network details
in Linux.
To display all available network interfaces and their assigned IP
address, run:
#ip addr show
Explanation:
- Ens33 – interface name
- Inet 192.168.1.7/24 – Ipv4 address with subnet
- State UP – Interface is active and running
2.
Check Network Configuration Using ipconfig (Legacy Command)The ifconfig command was traditionally used to view the network
interface configuration. It is now replaced by ip. It’s still available on many
systems for compatibility.
#ifconfig

If ifconfig is not installed by default, you can install it by:
#sudo apt install net-tools
3.
Display Interface Names using ip link show
To show all network interfaces both active and inactive use:
#ip link show

- Lo – loopback interface used for internal communication
- Ens33 or eth0 – Physical or virtual network interface connected to the
network
Interface names may vary by distribution, for example
- Older systems – eth1, eth0
- New systems – ens33, enp0s3
4. Check
the Default Gateway Using ip route show
To see your routing table and find the default gateway (the device that
connects your system to external networks), use:
#ip route show
- Gateway IP Address – 192.168.1.1
- Ens33 – Interface used to reach that gateway
Note: Always verify your
network information before and after making configuration changes. This helps
ensure that your system is connected using the expected interfaces, IPs and
routes.
5. Assigning
an IP Address in Linux
You
can assign an IP address to a network interface temporarily using commands or permanently
by editing configuration files in Linux. Knowing both methods is important: a
temporary assignment is useful for quick testing, while permanent
configurations ensure network settings persist after reboot.
1.
Temporary IP Assignment (Using Commands)
To assign a new IP address to a specific interface, like eth0 or ens33,
use the ip command:
#sudo ip addr add 192.168.1.10/24 dev ens33
- 192.168.1.10 – IP address you want to assign
- /24 – subnet mask (equivalent to 255.255.255.0)
- Dev ens33 – Network interface name
After running this command, you can verify the assigned IP using:
#ip addr show ens33
This method does not persist after a reboot; it is best for temporary
testing.
2.
Removing an Assigned IP Address
If you want to remove a temporarily assigned IP address, use the
following command:
#sudo ip addr del 192.168.1.10/24 dev ens33
3.
Permanent Assignment (via Configuration File)
To make your IP configuration permanent edit the network configuration
file. The location and syntax may slightly vary depending on your Linux
distribution.
For Ubuntu use (/etc/netplan/filename.yaml)
Open the configuration file with a text editor
#sudo nano /etc/netplan/50-cloud-init.yaml
- ens33 – Automatically enable the interface at boot
- Addresses – Assigned IP address
- Name server – DNS IP address
- Gateway – 192.168.1.1
After saving the file, restart the networking services for the changes to
take effect.
#sudo service NetworkManager restart
If your system uses NetworkManager, you can use nmcli or nmtui tools to
set static IPs more easily.
6.
Setting the Default Gateway in Linux
A default gateway is the device, usually a router
that allows your Linux system to communicate with other devices outside its
local network, including the internet. When your system needs to send data to
an address that is not in the same subnet, it forwards the traffic to the
default gateway.
1.
View Current routes
To view the existing routing table and find your
current default gateway run:
#ip route show
- Default via 192.168.1.1 – your current default
gateway
- 192.168.1.0/24 – your local network range
2.
Add a New Default Gateway
If you want to manually set or change the
gateway, use the following command:
#sudo ip route add default via 192.168.1.1
- Default – Specifies a route for all traffic not
otherwise matched
- Via 192.168.1.1 – IP address of your router or
Gateway
After adding the route, verify that it’s active:
#ip route show
3.
Delete an Existing Default Route
To remove the current default gateway, use this
command.
#sudo ip route del default
You can confirm it's removed with the command:
#ip route
This is useful when switching to a new gateway
or troubleshooting routing issues.
4.
Verifying the Configuration
After adding your gateway, verify network
connectivity by pinging an external host.
#ping

If the ping is successful, it means your gateway
and routing are configured correctly.
5.
Make Gateway Persistent
If you want the gateway settings to remain after
reboot, add it to your network configuration file.
For Ubuntu

Then restart the networking service.
7.
Configuring DNS in Linux
The Domain Name System (DNS) translates
human-friendly names like seeklinux.net into IP addresses that computers use to
communicate. A perfect configuration of DNS ensures your Linux system can
resolve domain names and access website or network resources smoothly.
1.
Edit the /etc/resolv.conf File
The simplest way to configure DNS servers in
Linux is by editing the /etc/resolv.conf file.
Open the file with a text editor:
#sudo nano /etc/resolv.conf
Each nameserver line specifies a DNS server your
system will use to resolve domain names. 8.8.8.8 is Google’s public DNS and
1.1.1.1 is Cloudflare’s DNS.
2. Verify
DNS Configuration
You can test whether DNS resolution is working
or not with these commands
#ping google.com
Or
use DNS lookup tools:
#dig google.com
If you get valid IP address responses, your DNS
configuration is working correctly. Always test DNS resolution after modifying
configurations. A misconfigured DNS can prevent your system from accessing
websites and repositories.
8.
Setting the Hostname in Linux
The hostname is the unique name that identifies
your Linux system on the network. It helps other devices and users to recognize
your machine, making it easier to manage and communicate between systems.
You can view, temporarily change or permanently
set the hostname using simple Linux commands or configuration files.
1.
Check the Current Hostname
To display your system’s current hostname, use
this command:
#hostname
2. Temporarily
Change Hostname
If you want to change the hostname temporarily,
use this command, it will revert back after reboot.
#sudo hostname new-hostname
3.
Permanently Change the Hostname
To make the hostname persistent, you need to
edit the config file (/etc/hosts).
#sudo nano /etc/hosts
4. Apply
Changes Using hostnamectl
The hostnamectl command is used to manage
hostnames (works on most new Linux systems).
#sudo hostnamectl set-hostname seeklinux
You can confirm the change using this command:
#hostnamectl status
After changing the hostname, it’s good to reboot
the system or restart the network service to ensure all applications recognize
the new hostname.
9.
Managing Network Routes in Linux
Routing determines how data packets travel from
your Linux system to other networks. The routing table contains all the routes
your system uses to decide where to send network traffic. Managing routes
manually is useful for configuring advanced networking setups or
troubleshooting network issues.
1.
View All Routes
To display the current routing table, use this
command:
#ip route show
2.
Add a Specific Route
To manually add a route to a specific network
use:
#sudo route add 192.168.2.1/24 via 192.168.2.1
dev ens33
3. Delete
a Route
To remove a specific route command is
#sudo ip route del 192.168.2.0/24
You can confirm removal by checking the routing
table using the ip route command. Routes added using ip route add are
temporary, they disappear after a reboot. To make them permanent, you can add
the route in the network configuration file.
10.
Testing and Troubleshooting Network Issues in Linux
After configuration of network settings, it’s
important to troubleshoot and test to make sure everything is working as
expected. Linux provides several tools to check connectivity, DNS resolution,
open ports and network service logs.
1.
Check Network Connectivity
The simplest and easiest way to test if your
system is reaching to other devices or websites by using the ping command.
#ping 8.8.8.8
2.
Test DNS Resolution
To verify DNS configuration and ensure name
resolution is working correctly, use the nslookup and dig commands. These
commands query DNS servers and return IP address associated with the domain. If
no address is returned, then check your /etc/resolv.conf or DNS settings.
3.
Check Open Ports and Active Connections
To check the open network ports and services,
use netstat or ss:
#netstat –ltun
Or
#ss –ltun

- -t - TCP connections
- -u - UPD connections
- -l - Listening sockets
- -n - Show numeric addresses
4. Restart
Networking Service
If your network changes don’t take effect or
connectivity drops, try restarting the network service.
#sudo service NetworkManager restart
5.
View Network Logs
Logs help you diagnose persistent network
problems. View detailed logs for the network manager using:
#journalctl –u NetworkManager
If you are troubleshooting a connection issue:
- Check IP configuration (ip addr show)
- Verify Gateway (ip route show)
- Test DNS (dig, nslookup)
- Restart the network service and check the logs
Quick
Reference Table
|
Command
|
Description
|
|
ip addr
|
Show or assign IP addresses
|
|
ip route
|
Display or modify routing table
|
|
hostnamectl
|
Manage system hostname
|
|
ping
|
Test connectivity
|
|
dig
|
Check DNS resolution
|
|
ss
|
View network sockets
|
|
netstat
|
Display active connections
|
|
ifconfig
|
Legacy network interface tool
|
11.
FAQ: Linux Basic Networking for Beginners
1.
How do I assign a static IP in Linux?
Temporary:
#sudo ip addr add 192.168.1.10/24 dev ens33
This sets the IP until reboot.
Permanent:
Edit your network configuration file
(/etc/netplan) to assign an IP address permanently, then restart the networking
service with the command:
#sudo service NetworkManager restart
2.
How can I permanently set DNS in Linux?
To permanently configure DNS servers, you can
modify your system config file (/etc/resolv.conf) and insert your DNS IP
address then restart the network service to take effect.
3.
What is the command to view my gateway?
To view your default gateway and routing table
use ip route show command.
4.
How do I change the hostname in Linux?
You can change your hostname temporarily or
permanently.
Temporary:
#sudo hostname new-hostname
Permanently:
#sudo hostnamectl set-hostname new-hostname
Then verify with:
#hostnamectl status
Conclusion
Basic networking knowledge in Linux is a skill
one must have in server administration, troubleshooting connectivity, or mastering
system management. These base commands and files allow you to adjust your system
network settings to communicate over a network, whether it is by assigning IP
addresses and configuring DNS, or by assigning hostnames and routes.
You will quickly gain confidence in configuring
and managing Linux networks effectively by practicing tools such as ip, ping,
traceroute and hostnamectl. Whether you are a beginner or an experienced system
admin, these networking basics form the backbone of advanced concepts like firewall,
DHCP and network security.
Keep visiting SeekLinux for more updates and
tutorials.
Post a Comment