Skip to content

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

ifconfig

Explanation
Displays all active network interfaces along with:

  • IP address

  • MAC address

  • Netmask

  • Broadcast address


Note

  • ifconfig is deprecated in modern systems

  • Replaced by ip command


ip addr — View IP Address

Description

Displays detailed information about network interfaces.


Usage

ip addr

Explanation

Shows:

  • IP addresses (IPv4 & IPv6)

  • Interface status (UP/DOWN)

  • MAC address


ip route — Routing Table

Description

Displays the system's routing table.


Usage

ip route show

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

dhclient

Explanation

  • Automatically assigns IP address

  • Useful when network configuration fails


netstat — Network Statistics

Description

netstat displays network connections, ports, and statistics.


Basic Usage

netstat

Common Options

Routing Table

netstat -r

Network Interfaces

netstat -i

Protocol Statistics

netstat -s

Verbose Output

netstat -v

Show Process ID

netstat -p

TCP Connections

netstat -t

UDP Connections

netstat -u

Listening Ports

netstat -l

Combined Example

netstat -tulnp

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

netdiscover -i eth0

Explanation

  • -i → specify network interface

  • Scans local network for active hosts

  • Useful in penetration testing


DNS Configuration

Edit DNS Server

vim /etc/resolv.conf

Explanation

  • Used to configure DNS servers manually

  • Example entry:

```id="p2s9xz" nameserver 8.8.8.8

---

## Check DNS Status

```bash
systemd-resolve --status

Explanation

  • Displays active DNS servers

  • Shows resolver configuration


Hosts File — Local DNS Mapping

Edit Hosts File

vim /etc/hosts

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

netstat -tulnp

Renew IP Address

dhclient

Discover Devices on Network

netdiscover -i wlan0

Important Notes

  • Root privileges may be required for some commands

  • Prefer ip over ifconfig in modern systems

  • Be cautious when editing /etc/resolv.conf and /etc/hosts

  • netdiscover should 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.