Network configuration is the process of setting up and managing network interfaces on Linux systems to enable communication with other devices and networks.

List Network Interfaces

# List network interfaces - ifconfig
ifconfig
 
# List network interfaces - ip
ip addr

Setup Network

# Activate network interface - ifconfig
sudo ifconfig eth0 up
# OR using - ip
sudo ip link set eth0 up
 
# Assign IP 
sudo ifconfig eth0 192.168.1.10
 
# Assign Netmask
sudo ifconfig eth0 netmask 255.255.255.0
 
# Assign Gateway
sudo route add default gw 192.168.1.1 eth0
 
# Restart Network
sudo systemctl restart networking

List Listening Ports

# Show all listening ports - netstat
netstat -tuln
 
# Show all listening ports - ss
ss -tuln
 
# Show listening ports with process information
sudo netstat -tulnp
 
# Show specific port (e.g., 80)
sudo netstat -tulnp | grep 80