Linux networking encompasses a broad range of network configuration tasks, including managing network interfaces, securing communications with firewalls, and ensuring privacy with Virtual Private Networks (VPNs). This page provides an overview of different networking components on Linux, including network interfaces, firewalls, and VPN types.
A Virtual Private Network (VPN) is a secure connection between your computer and a remote server, typically used for privacy and security over public networks. There are several types of VPNs available for Linux:
In Linux, a network interface represents the connection between your system and a network. The most common types of network interfaces are:
eth0, this is the standard wired network connection for desktops, servers, and workstations.wlan0 or similar and are used to connect to wireless networks (Wi-Fi).tun0 (for OpenVPN), wg0 (for WireGuard), or docker0 (for Docker containers).lo, this interface is used for internal communications within the system itself (localhost).A firewall is a crucial component in Linux networking that controls incoming and outgoing network traffic based on predefined security rules. The most common types of firewalls on Linux are:
Linux supports a wide variety of network services that are essential for communication, remote access, and managing network configurations. Common network services include:
Linux networking provides flexibility and control over how systems interact with one another. Whether you're configuring simple static IPs or setting up complex VPNs and firewalls, understanding the different types of network interfaces, services, and protocols will help you maintain secure and efficient network connections. With tools like UFW, iptables, and NetworkManager, Linux offers a variety of options for managing networking tasks at both basic and advanced levels.
Linux offers a variety of firewall solutions depending on scale, use case and user experience — from low-level packet filters to user-friendly managers and dedicated firewall distributions.
A firewall is a security control system that monitors, filters, and regulates network traffic between systems or networks based on predefined rules. Its primary purpose is to prevent unauthorized access while allowing legitimate communication to pass unhindered. Firewalls act as a gatekeeper between trusted and untrusted networks, most commonly between a private system and the public Internet.
At a technical level, a firewall evaluates network traffic by inspecting packet metadata such as source and destination IP addresses, ports, protocols (TCP, UDP, ICMP), and connection state. More advanced firewalls can also inspect packet payloads, track connection states, and apply rules based on application behavior rather than raw network parameters.
Firewalls can be implemented in several forms:
On Linux systems, firewall functionality is most commonly provided by the kernel itself through Netfilter, with user-space tools such as iptables, nftables, and higher-level managers like UFW or firewalld used to define and manage rule sets. Dedicated firewall distributions extend this concept by turning a Linux system into a hardened, purpose-built network security device.
Properly configured firewalls reduce attack surface, limit lateral movement in the event of a breach, enforce network segmentation, and form a foundational layer of any defense-in-depth security strategy. While not a complete security solution on their own, firewalls are a critical first line of control in protecting systems and networks from external and internal threats.
Traditional, powerful packet filter for fine-grained control. Best for experienced administrators and complex rule sets.
Use case: Low-level firewalling, custom networks.
Modern replacement for iptables providing a unified framework and cleaner syntax.
Use case: New deployments seeking better performance and maintainability.
Dynamic zone-based firewall manager that supports both iptables and nftables backends.
Use case: Desktop and server environments requiring runtime changes without restarts.
Ubuntu's simple frontend to iptables, great for quick host-based rule configuration.
Use case: Home systems and beginners.
High-level configurator for iptables/nftables using configuration files rather than raw commands.
Use case: Complex multi-zone firewall setups.
A feature-rich firewall script commonly used on web hosting control panels for additional security features.
Use case: Shared hosting servers and cPanel environments.
Turnkey firewall distribution with a web UI and integrated features like IDS and VPN.
Use case: Small businesses and home networks wanting an appliance-like solution.
Custom router firmware with package management and full configuration control.
Use case: Embedded routers, custom home network setups.
Quick reference cards for common networking tasks on Linux: interface testing, IP configuration, DHCP, DNS, routing and legacy SLIP support.
# List interfaces
ip a
# Ethernet link status
ethtool eth0
# Wi‑Fi scan
iw dev
sudo iwlist wlan0 scan# Temporary static IP
sudo ip addr add 192.168.1.100/24 dev eth0
sudo ip route add default via 192.168.1.1
# DNS
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.confUse dhclient for client; isc-dhcp-server for server with static leases configured in /etc/dhcp/dhcpd.conf.
# Temporary
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf
# Netplan example
sudo nano /etc/netplan/01-netcfg.yaml
sudo netplan apply# Enable forwarding
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
# NAT example
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADEsudo apt install slattach
sudo slattach -L -s 9600 -p slip /dev/ttyS0 &
sudo ip addr add 192.168.2.1 peer 192.168.2.2 dev sl0
sudo ip link set sl0 upThe Network Time Protocol (NTP) client is used to synchronize the system time with an NTP server. It allows systems to get the correct time based on time servers across the network.
sudo apt install ntpdate
sudo ntpdate time.google.com
sudo apt install ntpdatesudo ntpdate time.google.comThe NTP server provides the correct time to clients on the network. It is essential for maintaining time synchronization across devices.
sudo apt install ntp
sudo systemctl start ntp
sudo systemctl status ntp
sudo apt install ntpsudo systemctl start ntpsudo systemctl status ntpA DNS server resolves domain names to IP addresses for network communications.
sudo apt install bind9
sudo systemctl start bind9
dig @localhost example.com
sudo apt install bind9sudo systemctl start bind9dig @localhost example.comDynamic DNS (DYNDNS) servers allow DNS records to be updated dynamically when an IP address changes.
sudo apt install ddclient
sudo systemctl start ddclient
ddclient): sudo apt install ddclientsudo systemctl start ddclientSecure Telnet (SSH) is used to securely log into a remote system over the network.
sudo apt install openssh-server
sudo systemctl start ssh
sudo systemctl status ssh
sudo apt install openssh-serversudo systemctl start sshsudo systemctl status sshBootstrap Protocol (BOOTP) is used to assign IP addresses to client machines when they boot up, often used in embedded systems or networks.
sudo apt install isc-dhcp-server
sudo systemctl start isc-dhcp-server
dchp-server): sudo apt install isc-dhcp-serversudo systemctl start isc-dhcp-serverTrivial File Transfer Protocol (TFTP) is used for simple file transfers, often used in network booting and device firmware updates.
sudo apt install tftpd-hpa
sudo systemctl start tftpd-hpa
tftp localhost
sudo apt install tftpd-hpasudo systemctl start tftpd-hpatftp localhostThis guide details how to configure a WireGuard VPN server on an Ubuntu Server or Raspberry Pi. This setup enables remote access to the file system, terminal, and MariaDB as if on a local network.
Run the following commands to install WireGuard:
sudo apt update && sudo apt install wireguard -y
Generate a private and public key for WireGuard:
wg genkey | tee privatekey | wg pubkey > publickey
Save the private key securely and note the public key.
Create and edit the WireGuard server configuration file:
sudo nano /etc/wireguard/wg0.conf
Add the following content:
[Interface]
Address = 10.8.0.1/24
PrivateKey = <server_private_key>
ListenPort = 51820
# Enable IP forwarding
PostUp = sysctl -w net.ipv4.ip_forward=1
PostDown = sysctl -w net.ipv4.ip_forward=0
Replace <server_private_key> with the actual private key.
Enable packet forwarding to allow VPN traffic:
echo "net.ipv4.ip_forward=1" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
Run the following commands to start WireGuard:
sudo systemctl enable wg-quick@wg0
sudo systemctl start wg-quick@wg0
If using ufw (Uncomplicated Firewall), allow WireGuard traffic:
sudo ufw allow 51820/udp
sudo ufw enable
For each client, generate keys and add them to the server.
Edit the WireGuard server configuration:
sudo nano /etc/wireguard/wg0.conf
Add a client under [Peer]:
[Peer]
PublicKey = <client_public_key>
AllowedIPs = 10.8.0.2/32
Apply the new settings:
sudo systemctl restart wg-quick@wg0
Ensure SSH is accessible:
sudo systemctl enable ssh
sudo systemctl start ssh
Edit the MariaDB configuration file:
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
Modify the bind address:
bind-address = 10.8.0.1
Restart MariaDB:
sudo systemctl restart mariadb
Install SSHFS on the client:
sudo apt install sshfs -y
Mount the remote filesystem:
sshfs user@10.8.0.1:/home/user /mnt/server
Proceed to Client Configuration to connect Linux and Windows clients.
First, install the WireGuard client package on Linux Mint:
sudo apt update
sudo apt install wireguard
Set up the WireGuard configuration file:
sudo nano /etc/wireguard/wg0.conf
Example configuration:
[Interface]
PrivateKey = <Your_Private_Key>
Address = 10.0.0.2/24
[Peer]
PublicKey = <Server_Public_Key>
Endpoint = <Server_IP>:51820
AllowedIPs = 0.0.0.0/0
sudo systemctl enable wg-quick@wg0
sudo systemctl start wg-quick@wg0
To mount remote server disks:
sudo mount -t nfs <server_ip>:/remote/path /mnt
Open a terminal and run:
gnome-terminal
Use the following command to install WireGuard on Raspberry Pi:
sudo apt update
sudo apt install wireguard
sudo nano /etc/wireguard/wg0.conf
Example configuration:
[Interface]
PrivateKey = <Your_Private_Key>
Address = 10.0.0.3/24
[Peer]
PublicKey = <Server_Public_Key>
Endpoint = <Server_IP>:51820
AllowedIPs = 0.0.0.0/0
sudo systemctl enable wg-quick@wg0
sudo systemctl start wg-quick@wg0
sudo mount -t nfs <server_ip>:/remote/path /mnt
lxterminal
Download and install the WireGuard client from the official website:
After installation, open the WireGuard client and create a new tunnel. Input the following configuration:
[Interface]
PrivateKey = <Your_Private_Key>
Address = 10.0.0.4/24
[Peer]
PublicKey = <Server_Public_Key>
Endpoint = <Server_IP>:51820
AllowedIPs = 0.0.0.0/0
Click the "Activate" button in the WireGuard client to start the VPN connection.
To mount server disks on Windows, use the following method:
net use X: \\<server_ip>\share
Open the command prompt by pressing Win + R, typing cmd, and pressing Enter.
OpenVPN is a popular, open-source VPN solution that allows for secure communication between clients and servers over a network. Here’s how to install and configure the OpenVPN server on Linux:
sudo apt update
sudo apt install openvpn easy-rsa
sudo make-cadir /etc/openvpn/easy-rsa
cd /etc/openvpn/easy-rsa
source vars
./clean-all
./build-ca
./build-key-server server
./build-dh
./build-key client
cp keys/{server.crt,server.key,ca.crt,dh2048.pem} /etc/openvpn
sudo nano /etc/openvpn/server.conf
sudo systemctl start openvpn@server
sudo systemctl enable openvpn@server
sudo apt install openvpn easy-rsa./build-ca, ./build-key-server serversudo systemctl start openvpn@serversudo systemctl enable openvpn@serverTo connect to the OpenVPN server from a Linux machine, you need to install OpenVPN and configure the client with the server's certificates.
sudo apt install openvpn
sudo cp /path/to/server/ca.crt /etc/openvpn/
sudo cp /path/to/server/client.crt /etc/openvpn/
sudo cp /path/to/server/client.key /etc/openvpn/
sudo nano /etc/openvpn/client.conf
sudo systemctl start openvpn@client
sudo systemctl enable openvpn@client
sudo apt install openvpnsudo cp /path/to/server/ca.crt /etc/openvpn/sudo nano /etc/openvpn/client.confsudo systemctl start openvpn@clientsudo systemctl enable openvpn@clientTo connect to the OpenVPN server from an Android device, you need to install the OpenVPN Connect app and import the server’s configuration file.
1. Install the OpenVPN Connect app from the Google Play Store.
2. Transfer the OpenVPN configuration file and certificates (ca.crt, client.crt, client.key) to your Android device.
3. Open the OpenVPN Connect app and import the configuration file (client.ovpn).
4. Tap "Connect" to establish the VPN connection.
To connect to the OpenVPN server from a Windows machine, you need to install the OpenVPN client and configure it with the necessary certificates.
1. Download and install OpenVPN from https://openvpn.net/community-downloads/.
2. Copy the server's configuration file (client.ovpn), ca.crt, client.crt, and client.key to the OpenVPN config folder (usually C:\Program Files\OpenVPN\config).
3. Right-click the OpenVPN GUI icon in the system tray and click "Connect" to establish the VPN connection.