How-To Guides and Blog

How to Manage Networking in Linux

NBH Support
No Comments

As a Linux system administrator, you need to have a quick brush-up on your networking skills. Linux administrative task didn’t just stop at creating and managing users account. It’s far beyond that; you will need to be running a routine task on maintaining, troubleshooting, configuring, and managing networks and servers within data centres.

So, therefore, if you are aspiring to become a system administrator, you will need to enroll for a networking class and at least have either bash scripting or python programming language. You will need all these to kick-off your career as a system administrator.

Meanwhile, I won’t be going through the OSI model or how IP addresses a created; rather, we will be focusing on how networks can be managed in the Linux environment.

In this article, we will be looking at the network interface names in Linux, how to troubleshoot routing, port and services and some basic networking commands used for network management in Linux.

BASIC NETWORKING COMMANDS IN LINUX

For proper follow-up on what we will be doing in this article, we need to understand some basic networking commands and their functions.

ifconfig: It is used to configure kernel network interfaces. It is usually used at boot time to set up interfaces; after that, it is only needed for debugging. The ifconfig command with no argument displays the currently active interfaces. If an interface is specified, it displays the information about that interface. If the –a option is specified, it displays the status of all interfaces, including those that are down.

The ip command: The ip command is another command-line tool used for manipulating routing and network interface devices

The ping command: The ping command is used to test connectivity between two networks on the same system. it could be a Local Area Network or Wide Area Network. It uses ICMP (Internet Control Message Protocol) for communication

The traceroute command: This is another command-line tool for tracing the path to a network. It prints the numbers of routers IP it traverses to reach the destination server. It is a useful tool after the ping command.

The route command: The route command is a command-line helpful tool for manipulating routing tables in Linux systems.

The netstat command: The netstat command is used to print routing tables, network connection, interface statistic, and much more. It is useful when troubleshooting networks and also to check which port a program is listening to**.**

nslookup command: The nslookup command is used to query the Domain Name server both interactively and non-interactively

These are a few basic commands in Linux networking. Throughout this article, we will be making use of some of these commands. If you also need more explicit information on how these commands are used, you can look-up to your manual page of the commands

NETWORK INTERFACE NAMES IN LINUX

The network naming scheme was traditionally enumerated as eth0, eth1, eth2 and so on. However, these naming schemes are not fixed anymore as the interface names might change after boot.

To fix this unpredictable naming scheme, Linux decided to implement udev to support assigning permanent ethX based on the hardware MAC address. Meanwhile, this turns out to be a bad idea because it requires root directory which is not possible among all Linux distros and also considering loading a new OS image on a system changes the state and configuration of the system image. Moreover, this is a hindrance as MAC addresses are not fixed in most systems

So later, Linux decided to introduce a new scheme called biosdevname, which tries to bridge the gap in udev by assigning fix names based on device topology, firmware, and device type. With this, biosdevname departed from the low-level device identification used by udev and introduces its naming scheme

There are several commands such as ifconfig and netstat which are used to display network names in Linux, but we will be looking at the ip command to display network interface names

HOW TO DISPLAY IP ADDRESSES

To display the network information and network devices, you use the ip command with address or just an ‘a’ as an option

You can also choose to narrow down your command to a specific network device by running the command below

Our active device is ens33. The second line of the output shows the hardware MAC address. The third line shows the IPv4 address. The same line where we have the brd is the broadcast address, and the fourth line is the IPv6 address.

HOW TO TROUBLESHOOT ROUTING

In a situation where your traffic is forwarded to the wrong interface or the traffic not forwarded when it should have been forwarded. In any way the problem occurs, it is a problem that results from the IP table, and failure to forward could indicate that forwarding is not enabled.

For a quick investigation, you have to look at the routing table if it is not populated with routes that you intended or the table has been filled as you think but do not have any desired effect.

First, you look at the IP table by running the ip route show command

The output you see above is the list of routes. Which signifies that the traffic meant for IP address 192.168.122.0 should be forwarded to its destination through the network interface virbr0. The traffic meant for IP address 192.168.124.0 should be sent to ens33 network interface and traffic to anywhere else should be forwarded to 192.168.124.2 through ens33 network interface.

HOW TO TEST CONNECTIVITY

You can use the ping command to test the connectivity of a network between the host and the server. The ping command takes as input the IP address, domain name, or the URL to send a data packet to the specified address. By default, if the ping command is sent without specifying the number of packets to send as an option, the ping command continues to run until ctrl + z is pressed

They are several options you can use with the ping command. You can look up the manual page of ping to view the all available option and applied as suit.

HOW TO TRACE PATH WITH UDP PACKET

You can use the tracepath or traceroute to trace the path with UDP packets. Many networks block UDP and ICMP traffic, but the traceroute can trace both the UDP and ICP traffic by specifying the –I and –T option respectively.

The above command represents how the traceroute command and the tracepath command is used. Each line specifies a router the packet passes through to get to its destination.

HOW TO TROUBLESHOOT PORTS AND SERVICES

TCP services use sockets for communication and services are made of IP address, port number, and protocol. They are services listening to a standard port
whenever a client is using an available port.

The ss command can be used to view statistics of the sockets as seen below

The first circled item means the port used for ssh listening to all IPV4 address. The “*” signifies all.

The second circled item means the port used for SMTP is listening on the loopback interface of IPV4 address 127.0.0.1

The third circled item means the port used for SMTP is listening to ::1 IPV6 loopback interface

CONCLUSION

Now you can kick off your skills in using networking commands to test network connectivity or troubleshoot any issues about your server. Also, remember this is not a comprehensive article you will need to troubleshoot all networking issues.