YYisak
Published on

Network Management in Linux

Authors

Introduction

Network management is an essential aspect of system administration. It involves monitoring, configuring, and troubleshooting network devices and services to ensure optimal performance and security. In this post, we'll cover some key concepts and tools for network management in Linux.

Definitions and Tools

Network Management is the process of administering, managing, and maintaining computer networks. It involves monitoring network performance, configuring network devices, and troubleshooting network issues.

Linux is an open-source operating system that is widely used in servers, desktops, and embedded systems. It provides a robust platform for network management tasks.

Network Interface is a hardware or software component that connects a device to a network. It allows the device to send and receive data over the network.

IP Address is a unique numerical label assigned to each device connected to a network. It identifies the device and enables communication between devices on the network.

Subnet Mask is a numerical value that defines the size of a network and separates the network portion from the host portion of an IP address.

Gateway is a network device that serves as an entry and exit point for data packets entering and leaving a network. It connects different networks and enables communication between them.

ifconfig is a command-line tool used to configure network interfaces in Linux. It allows users to view, configure, and manage network interfaces, IP addresses, and other network-related settings.

ip is a versatile command-line tool for configuring network interfaces, routing tables, and other network-related settings in Linux. It provides more advanced features than ifconfig and is recommended for modern Linux distributions.

Network configuration in Unix

In unix the \etc\protocol file contains a list of the IP protocol numbers used in the kernel. The file is read by the kernel when it starts up and is used to map protocol names to their corresponding numbers. The \etc\services file contains a list of well-known port numbers and their associated services. It is used by various network services and utilities to map port numbers to service names.

If not configured automatically through DHCP, DNS servers are defined manually in /etc/resolv.conf file. The file contains a list of DNS servers that the system should use to resolve domain names to IP addresses.

Tools such as ip and ifconfig do not make changes persistent, To persist those changes use Network Manager (nmtui/nmcli) iptables is kernel module (subset of the Netfilter framework) applying routing and filtering to network packets, it is managed though the iptables command line. iptables is also extensively used for VMs and containers networking.

Network tools in Linux

1. ifconfig

The ifconfig command is used to configure network interfaces in Linux. It allows users to view, configure, and manage network interfaces, IP addresses, and other network-related settings. Here are some common uses of the ifconfig command:

  • Display information about all network interfaces:
    zsh
    $ ifconfig
    
  • Configure a network interface with a specific IP address:
    zsh
    $ ifconfig eth0
    
  • Enable or disable a network interface:
    zsh
    $ ifconfig eth0 up
    $ ifconfig eth0 down
    

2. ip

The ip command is a versatile tool for configuring network interfaces, routing tables, and other network-related settings in Linux. It provides more advanced features than ifconfig and is recommended for modern Linux distributions. Here are some common uses of the ip command:

  • Display information about all network interfaces:

    zsh
    $ ip addr show
    
  • For temporarily assigning IP Address to a specific network interface (eth0), use the following command:

    zsh
    $ ip addr add 195.162.54.2 dev eth0
    
  • For removing an assigned IP address from a network interface (eth0), use the following command

    zsh
    $ ip addr del 195.162.54.15/24 dev eth0
    
  • Enable or disable a network interface:

    zsh
    $ ip link set eth0 up
    $ ip link set eth0 down
    
  • Display routing table information:

    zsh
    $ ip route show
    
  • Add or delete a route:

    zsh
    $ ip route add
    $ ip route del
    
  • Display ARP cache:

    zsh
    $ ip neigh show
    
  • Flush ARP cache:

    zsh
    $ ip neigh flush
    

3. UFW (Uncomplicated Firewall)

Uncomplicated Firewall (UFW) that manages a Netfilter firewall and is a well-known program and default firewall configuration tool on Debian and Ubuntu Linux distributions. It uses iptables for configuration.

Check UFW firewall status, type the following command:

zsh
$ sudo ufw status

Active and disable the UFW firewall using the following command:

zsh
$ sudo ufw enable
$ sudo ufw disable

You can get the Gui version, by typing the following command:

zsh
$ gufw

Other Network Tools

ToolDescription
hostnameDisplay or set the system's hostname.
hostnamectlControl the system hostname and related settings.
digDNS lookup utility.
routeDisplay or modify the IP routing table.
netstatDisplay network connections, routing tables, etc.
ssDisplay socket statistics.
tracerouteTrace the route packets take to a destination.
pingSend ICMP echo requests to a host.
mtrCombines the functionality of ping and traceroute.
  • A socket is a communication endpoint used in inter-process communication (IPC). It is a combination of an IP address and a port number that uniquely identifies a specific process or service running on a networked computer.
    • netstat -tulnp can be used to display information about The sockets on your system.
    • netstat —n I grep ESTABLISHED is used to display information about the established sockets on a system only.

Conclusion

Network management in Linux involves monitoring, configuring, and troubleshooting network devices and services. By using the tools and commands like mentioned in this post, system administrators can effectively manage and maintain their networks to ensure optimal performance and security. Understanding key concepts such as IP addressing, routing, and firewalls is essential for successful network management in Linux.