IP Configuration — Configuring Network Interfaces in Linux¶
IP Configuration is the process of assigning and managing IP addresses, subnet masks, gateways, DNS servers, and network interfaces. Every Linux server, cloud virtual machine, Kubernetes node, and container requires proper IP configuration to communicate with other systems. Understanding IP configuration is a fundamental skill for Linux administrators, DevOps engineers, Cloud Architects, Network Engineers, and Site Reliability Engineers (SREs).
Learning Path¶
Course Progress
What You'll Learn¶
After completing this lesson, you'll be able to:
- Understand network interfaces
- View IP configurations
- Configure static IP addresses
- Understand DHCP
- Manage network interfaces
- Configure gateways
- Verify network connectivity
- Apply IP configuration in production
Prerequisites¶
Complete:
- Module 1 – Linux Fundamentals
- Module 2 – Linux Command Line Essentials
- Module 3 – Text Processing
- Module 4 – File Management
- Module 5 – Users and Groups
- Module 6 – Process Management
- Module 7 – Package Management
- Module 8 Lesson 1 – TCP/IP Basics
Why Learn IP Configuration?¶
Imagine:
- A new cloud server cannot reach the Internet.
- A Kubernetes node cannot join the cluster.
- SSH access stops working.
- Two servers cannot communicate.
In many cases, the root cause is an incorrect IP configuration.
What is IP Configuration?¶
IP configuration defines how a device communicates on a network.
Typical configuration includes:
- IP Address
- Subnet Mask (or Prefix Length)
- Default Gateway
- DNS Server
- Network Interface
Without proper configuration, network communication is not possible.
Network Configuration Components¶
Each component plays a specific role in network communication.
Network Interfaces¶
A network interface connects the operating system to a network.
Common interface names:
Modern Linux systems use predictable network interface names such as ens160 or enp0s3.
View Network Interfaces¶
Display all interfaces.
Example:
Loopback Interface¶
Linux includes a special interface:
Loopback address:
Purpose:
- Local communication
- Testing
- Internal services
View IP Addresses¶
Display configured IP addresses.
Example:
Show a specific interface.
Understanding CIDR Notation¶
Example:
Meaning:
- IP Address:
- Prefix Length:
Equivalent subnet mask:
Static IP Address¶
A static IP address remains the same until changed manually.
Example:
Advantages:
- Predictable
- Ideal for servers
- Required for many production workloads
Dynamic IP Address (DHCP)¶
DHCP stands for:
A DHCP server automatically assigns:
- IP Address
- Gateway
- DNS Server
- Lease Time
Commonly used for:
- Laptops
- Desktops
- Home networks
- Cloud instances (during initial provisioning)
Assign a Temporary IP Address¶
Assign an IP address to an interface.
Verify:
This change is temporary and will be lost after a reboot or interface reset.
Remove an IP Address¶
Enable a Network Interface¶
Disable a Network Interface¶
Use with caution on remote systems, as it may disconnect your session.
View Routing Information¶
Display the routing table.
Example:
Default Gateway¶
The default gateway is the router used to reach networks outside the local subnet.
Example:
View the default gateway.
Add a Temporary Default Gateway¶
Delete the default gateway.
Test Connectivity¶
Ping the gateway.
Ping an external IP.
Ping a domain.
Persistent Configuration¶
Temporary changes made with the ip command are not preserved after a reboot.
Persistent configuration depends on the Linux distribution.
Common tools include:
| Distribution | Common Configuration Method |
|---|---|
| Ubuntu Server | Netplan |
| RHEL / Rocky / AlmaLinux | NetworkManager (nmcli) or network configuration files |
| Fedora | NetworkManager |
Common Commands¶
View interfaces.
View IP addresses.
View routing table.
Bring interface up.
Bring interface down.
Real Production Examples¶
Display server IP.
Verify default route.
Test gateway.
Enable interface.
Production Perspective¶
IP configuration is required for:
- Cloud virtual machines
- Kubernetes nodes
- Docker hosts
- Database servers
- Web servers
- VPN gateways
- Firewalls
- Enterprise networks
Incorrect IP configuration is one of the most common causes of network connectivity issues.
Hands-on Lab¶
Task 1¶
List network interfaces.
Task 2¶
Display IP addresses.
Task 3¶
View the routing table.
Task 4¶
Identify the default gateway.
Task 5¶
Test gateway connectivity.
Replace <gateway-ip> with the gateway shown in your routing table.
Task 6¶
Display the loopback interface.
Task 7¶
Bring a non-production interface down and back up (if available).
Do not perform this on a remote production server or on the interface you're currently using.
Task 8¶
Display the IP configuration for a specific interface.
Replace <interface> with your network interface name (for example, ens160).
Command Deep Dive¶
| Command | Purpose | Production Example |
|---|---|---|
ip addr | View IP addresses | Verify server configuration |
ip link | View network interfaces | Interface management |
ip route | Display routing table | Routing verification |
ip addr add | Assign temporary IP | Testing |
ip addr del | Remove temporary IP | Cleanup |
ip link set up | Enable interface | Restore connectivity |
ip link set down | Disable interface | Maintenance |
Production Troubleshooting Scenario¶
Scenario
A newly provisioned cloud virtual machine cannot access the Internet.
Investigation:
Check the IP address.
Verify the routing table.
Check connectivity to the gateway.
The default route is missing.
Temporarily add the gateway.
Verify Internet access.
The server can now reach external networks. A persistent configuration is then applied using the distribution's network management tools.
Best Practices¶
- Use static IP addresses for production servers.
- Use DHCP where automatic configuration is appropriate.
- Verify the default gateway after configuration changes.
- Use the
ipcommand instead of the deprecatedifconfig. - Test connectivity after making network changes.
- Apply persistent configuration using the distribution's supported network management tools.
Common Mistakes¶
❌ Forgetting that ip command changes are temporary.
✅ Remember to that ip command changes are temporary.
❌ Bringing down the active network interface on a remote server.
✅ Avoid this mistake: bringing down the active network interface on a remote server.
❌ Configuring an incorrect subnet or gateway.
✅ Avoid this mistake: configuring an incorrect subnet or gateway.
❌ Forgetting to verify routing after assigning an IP address.
✅ Remember to to verify routing after assigning an IP address.
Interview Questions¶
Beginner¶
- What is an IP address?
- What is the difference between a static IP address and DHCP?
- Which command displays IP addresses?
- What is the purpose of the loopback interface?
Intermediate¶
- What is CIDR notation?
- How do you temporarily assign an IP address?
- How do you view the routing table?
- Why is the default gateway important?
Architect Level¶
- How would you configure networking for production Linux servers?
- How would you troubleshoot a server that cannot reach the Internet?
- Why are static IP addresses commonly used for infrastructure services?
Summary¶
In this lesson, you learned:
- IP configuration
- Network interfaces
- Static and dynamic addressing
- DHCP
- Routing
- Default gateways
- Temporary network configuration
- Production networking best practices
Proper IP configuration is the foundation of Linux networking. Every server, container, and cloud instance depends on correctly configured network interfaces, IP addresses, gateways, and routing information to communicate reliably.
Key Takeaways¶
- Every network interface requires proper IP configuration.
- Static IP addresses are preferred for production servers.
- DHCP automatically assigns network settings.
- The
ipcommand is the standard tool for Linux network configuration. - The default gateway enables communication outside the local network.
- Changes made with the
ipcommand are temporary unless made persistent.
What's Next?¶
DNS (Domain Name System) — Translating Domain Names into IP Addresses
You'll explore:
- How DNS works
- DNS records
- Name resolution
- DNS configuration
- DNS troubleshooting
- Common DNS tools
- Production DNS best practices
Understanding DNS is essential because nearly every network application depends on reliable name resolution.