Overview¶
Linux provides various commands to configure, monitor, and troubleshoot network settings. These commands are essential for:
-
Network configuration
-
Troubleshooting connectivity
-
Cybersecurity and reconnaissance
-
System administration
ifconfig — Network Interface Configuration¶
Description¶
ifconfig is used to view and configure network interfaces.
Basic Usage¶
Explanation
Displays all active network interfaces along with:
-
IP address
-
MAC address
-
Netmask
-
Broadcast address
Note¶
-
ifconfigis deprecated in modern systems -
Replaced by
ipcommand
ip addr — View IP Address¶
Description¶
Displays detailed information about network interfaces.
Usage¶
Explanation
Shows:
-
IP addresses (IPv4 & IPv6)
-
Interface status (UP/DOWN)
-
MAC address
ip route — Routing Table¶
Description¶
Displays the system's routing table.
Usage¶
Explanation
Shows:
-
Default gateway
-
Network routes
-
Interface used for routing
dhclient — Obtain IP Address¶
Description¶
dhclient requests an IP address from a DHCP server.
Usage¶
Explanation
-
Automatically assigns IP address
-
Useful when network configuration fails
netstat — Network Statistics¶
Description¶
netstat displays network connections, ports, and statistics.
Basic Usage¶
Common Options¶
Routing Table¶
Network Interfaces¶
Protocol Statistics¶
Verbose Output¶
Show Process ID¶
TCP Connections¶
UDP Connections¶
Listening Ports¶
Combined Example¶
Explanation
-
-t→ TCP -
-u→ UDP -
-l→ listening ports -
-n→ numeric output (no DNS resolution) -
-p→ process ID
Netdiscover — Network Reconnaissance¶
Description¶
Netdiscover is used for ARP-based network discovery.
Usage¶
Explanation
-
-i→ specify network interface -
Scans local network for active hosts
-
Useful in penetration testing
DNS Configuration¶
Edit DNS Server¶
Explanation
-
Used to configure DNS servers manually
-
Example entry:
```id="p2s9xz" nameserver 8.8.8.8
Explanation
-
Displays active DNS servers
-
Shows resolver configuration
Hosts File — Local DNS Mapping¶
Edit Hosts File¶
Explanation
-
Maps domain names to IP addresses locally
-
Used for:
-
Blocking websites
-
Testing domains
-
Redirecting traffic
-
Example¶
```id="6k8w2r" 127.0.0.1 example.com
**Effect**
- Redirects `example.com` to localhost
- Can be used to block access
---
# Practical Examples
## Check Network Information
```bash
ip addr
ip route show
Check Open Ports¶
Renew IP Address¶
Discover Devices on Network¶
Important Notes¶
-
Root privileges may be required for some commands
-
Prefer
ipoverifconfigin modern systems -
Be cautious when editing
/etc/resolv.confand/etc/hosts -
netdiscovershould be used only in authorized environments
Summary Table¶
| Command | Purpose |
|---|---|
ifconfig |
View/configure interfaces |
ip addr |
Show IP details |
ip route |
Show routing table |
dhclient |
Get IP via DHCP |
netstat |
Network connections and stats |
netdiscover |
Discover network hosts |
/etc/resolv.conf |
DNS configuration |
/etc/hosts |
Local domain mapping |
Conclusion¶
These networking commands are essential for:
-
Network troubleshooting
-
System configuration
-
Cybersecurity reconnaissance
Mastering them provides strong control over Linux networking environments and is crucial for both administrators and security professionals.