Master Linux Network Configuration: IP, Routes, Bonding and Diagnostic Tools
This guide walks through Linux network fundamentals—including hostname, IP address, netmask, gateway, DNS, interface status, temporary and permanent IP changes with ifconfig and ip, routing adjustments, bond interface setup, and diagnostic utilities like ethtool, ss, netstat, traceroute, nslookup, and tcpdump—providing step‑by‑step commands and examples for effective system administration.
1. Configure Network Basics
Hostname : hostname command for temporary change; edit /etc/hostname or /etc/sysconfig/network for permanent change.
IP address / netmask : use ifconfig or ip a to view; ifconfig <iface> <IP> netmask <MASK> to set temporarily.
Default gateway : route -n or ip route.
DNS servers : view /etc/resolv.conf.
Network status : ss or netstat.
Domain lookup : nslookup, host, dig.
2. Using ifconfig
ifconfig # show all interfaces (including down)
ifconfig -a # show all interfaces, even inactive
ifconfig <iface> up|down # enable or disable an interface
ifconfig <iface> <IP> netmask <MASK> # set IP address
ifconfig <iface>:0 <IP> # create virtual interfaceModify IP address
Example: ifconfig ens33 192.168.11.8 then verify with ifconfig. Restart the session (e.g., Xshell) if needed.
Add / Delete temporary IP
# add temporary IP
ip address add 10.0.0.88/24 dev ens33
# delete temporary IP
ip address del 10.0.0.8/24 dev ens333. Rename Network Interface Temporarily
ip link set ens36 down # bring interface down
ip link set ens36 name abc # rename
ip link set abc up # bring it back up4. Permanently Change IP Address
# vim /etc/sysconfig/network-scripts/ifcfg-ens33
After editing, restart the network service: # systemctl restart network (or # systemctl restart NetworkManager on newer distros).
5. Permanent Interface Renaming
# vim /etc/sysconfig/network-scripts/ifcfg-ens33
# change NAME= and DEVICE= to the new name
# systemctl restart network6. IP Management with ip
Link layer : ip link shows interfaces and their state.
Address layer : ip addr (or ip a) lists IPs; ip address add <IP/MASK> dev <iface> adds an address; ip address del <IP/MASK> dev <iface> removes it.
Routing : ip route displays routes; route add -net <net> gw <gw> adds a route; route del -net <net> deletes it; permanent routes can be saved in /etc/sysconfig/network-scripts/route-<iface> then restart network.
7. Network Diagnostics
ss / netstat
Common options: -t TCP, -u UDP, -a all, -n numeric, -p show process, -l listening sockets.
traceroute
Trace the path to a destination IP.
nslookup
Verify DNS resolution of hostnames.
tcpdump – packet capture
Capture on a specific interface: tcpdump -i ens33 List interfaces: tcpdump -D Filter by host, source, destination, port, protocol, etc. Example:
tcpdump -i eth0 -nn icmp and src host 192.168.12 and dst host 192.168.11.9
tcpdump port 1000
tcpdump tcp port 22 and src host 192.168.11.12Limit capture size and count: -s 0 (full packet), -c 100 (stop after 100 packets), -w ./target.cap to save.
8. Bond (Link Aggregation) Configuration
Bonding combines multiple NICs for redundancy or load balancing.
Manual method (CentOS/RHEL)
# Copy existing config
cp /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-ens36
# Edit ifcfg-ens36 (change NAME and DEVICE to ens36)
# Create bond0 config (ifcfg-bond0) with:
TYPE=Bond
BONDING_OPTS="mode=active-backup miimon=100"
DEVICE=bond0
ONBOOT=yes
IPADDR=192.168.91.123
NETMASK=255.255.255.0
GATEWAY=192.168.91.2
# Add slave interfaces to bond0
vim /etc/sysconfig/network-scripts/ifcfg-ens33 # set MASTER=bond0, SLAVE=yes
vim /etc/sysconfig/network-scripts/ifcfg-ens36 # same as above
# Restart network
systemctl restart networkVerify bond status with cat /proc/net/bonding/bond0 or ifconfig bond0.
NMCLI method (CentOS 8)
# Create static connection (no autoconnect)
nmcli con add con-name static ifname eth0 type ethernet ipv4.addresses 172.25.X.10/24 ipv4.gateway 172.25.X.254 autoconnect no
# Add bond interface
nmcli con add type bond con-name mybond0 ifname bond0 mode active-backup ipv4.method manual ipv4.addresses 192.168.91.123/24
# Add slave interfaces
nmcli con add type bond-slave ifname ens33 master bond0
nmcli con add type bond-slave ifname ens36 master bond0
# Bring up slaves then bond
nmcli con up bond-slave-ens33
nmcli con up bond-slave-ens36
nmcli con up mybond0Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
