USD ($)
$
United States Dollar
Euro Member Countries
India Rupee

Viewing and Configuring Network Interfaces

Lesson 30/49 | Study Time: 20 Min

Network interfaces are essential components in Linux systems that facilitate communication between the computer and external networks, including the internet and local area networks (LANs).

To ensure reliable connectivity and optimize performance, it is crucial to know how to view and configure these interfaces. Linux offers several commands and configuration methods—ranging from command-line utilities to editing configuration files and using network managers—that empower users to manage network settings efficiently.

Viewing Network Interfaces

Knowing the status and details of network interfaces is the first step in network configuration and troubleshooting.


1. ip addr show or ip a

Displays all network interfaces with detailed information, including IP addresses, MAC addresses, and connection states.

text
ip addr show


2. ifconfig (deprecated but still widely used)

Shows interface configurations and statistics.

text
ifconfig -a


3. nmcli device status

Shows network devices status managed by NetworkManager.


4. Listing interface names:

text
ls /sys/class/net


5. Other commands:


ethtool eth0 to show and configure physical device parameters.

ip link show to list interfaces with statuses.

Configuring Network Interfaces

The following are common methods used to configure network interfaces in Linux. They include both modern and legacy command-line tools.


1. Using ip Command (Modern Standard)


  • Assign an IP Address:
text
sudo ip addr add 192.168.1.100/24 dev eth0


  • Remove an IP Address:
text
sudo ip addr del 192.168.1.100/24 dev eth0


  • Bring Interface Up or Down:
text
sudo ip link set eth0 up
sudo ip link set eth0 down


2. Using ifconfig Command (Legacy)


  • Assign IP:
text
sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0


  • Activate/Deactivate Interface:
text
sudo ifconfig eth0 up
sudo ifconfig eth0 down

Persistent Configuration via Configuration Files

On Debian/Ubuntu: Modify /etc/network/interfaces with entries such as:

text
auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1


On Red Hat/CentOS: Configuration files reside in /etc/sysconfig/network-scripts/ifcfg-eth0.

Example static IP configuration includes:

text
DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
ONBOOT=yes


After configuration, restart the network service:

text
sudo systemctl restart NetworkManager

or

text
sudo systemctl restart network

Using Network Manager Tools

nmcli is the command-line tool for NetworkManager.


  • List devices:
text
nmcli device status


  • Connect to a network:
text
nmcli device wifi connect SSID password PASSWORD


  • Graphical tools: GNOME or KDE network settings interfaces allow easy setup.

Troubleshooting and Monitoring


1. Check interface status:

text
ip link show eth0


2. View routing table:

text
ip route show


3. Display DNS settings:

text
cat /etc/resolv.conf
Samuel Wilson

Samuel Wilson

Product Designer
Profile

Class Sessions

1- What is Linux and Operating System Concepts 2- Linux History and Evolution 3- Linux Distributions and Their Purposes 4- Open Source Software and Licensing 5- Graphical User Interface (GUI) and Desktop Environments 6- Terminal Access and Command-Line Fundamentals 7- Getting Help and Command Documentation 8- File System Hierarchy and Directory Structure 9- Navigating Directories and Listing Contents 10- Creating, Copying, and Moving Files and Directories 11- Deleting Files and Directories 12- Symbolic and Hard Links 13- Understanding File Permissions Model 14- Modifying Permissions and Ownership 15- User and Group Management 16- Sudo and Privilege Escalation 17- Text Searching and Pattern Matching 18- Text Processing and Stream Editing 19- Compressing and Archiving Files 20- Text Editing and File Creation 21- Package Management Systems Overview 22- Installing and Updating Software with APT 23- Installing and Updating Software with YUM/DNF 24- Managing Software from Non-Repository Sources 25- Understanding Processes and Process Management 26- Viewing Running Processes 27- Process Control and Termination 28- Task Scheduling with Cron 29- Networking Concepts and IP Addressing 30- Viewing and Configuring Network Interfaces 31- Basic Network Troubleshooting 32- Shell Script Basics 33- Variables and Data Types 34- Conditional Logic in Scripts 35- Loops and Iteration 36- Functions and Code Reuse 37- Input/Output and User Interaction 38- System Authentication and Access Control 39- File System Security 40- Software Updates and Patching 41- Basic Firewall Concepts 42- System Information and Monitoring 43- Service and Daemon Management 44- System Boot Process and Runlevels 45- System Backup and Disaster Recovery 46- Comprehensive File System Management 47- System Automation Workflows 48- Multi-Concept Troubleshooting Scenarios 49- Continued Learning Pathways