Operations 20 min read

Master Linux Network Configuration: From IP Settings to NIC Bonding

This guide walks through Linux network fundamentals, covering hostname, IP and netmask configuration, default gateway, DNS, connection status tools, domain resolution, using ifconfig and ip commands, permanent and temporary IP changes, renaming interfaces, routing, traceroute, nslookup, tcpdump packet capture, and bonding multiple NICs for redundancy or load‑balancing.

MaGe Linux Operations
MaGe Linux Operations
MaGe Linux Operations
Master Linux Network Configuration: From IP Settings to NIC Bonding

Linux Network Settings and Basic Services

1 Configure network settings

Hostname – hostname IP address / netmask – ifconfig; ip a Default gateway – route -n DNS server – cat /etc/resolv.conf Network connection status – ss / netstat Domain name resolution –

nslookup
host

2 ifconfig

ifconfig          specific‑interface-name   # show details of a specific NIC
ifconfig -a                         # show all interfaces, even down
ifconfig interface [up|down]        # enable or disable an interface
ifconfig interface ip/netmask      # set IP address and netmask
ifconfig interface ip[/mask‑len]    # temporary change
ifconfig ens33:0 address           # virtual interface

ifconfig modify IP address

inconfig ens33 new‑IP‑address

[root@localhost ~]# ifconfig ens33 192.168.11.8

[root@localhost ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
        inet 192.168.11.8 netmask 255.255.255.0 broadcast 192.168.11.255
        inet6 fe80::42b7:9714:f504:2343 prefixlen 64 scopeid 0x20<link>
        ether 00:0c:29:96:50:48 txqueuelen 1000 (Ethernet)
        RX packets 641 bytes 49417 (48.2 KiB)

ifconfig add temporary IP address

ifconfig delete temporary IP address

Permanent modify IP address

# vim /etc/sysconfig/network-scripts/ifcfg-ens33

Best to restart the network service:

# systemctl restart network

3 Modify network card name

Temporary modify network card name

ip link set ens36 down   # bring the NIC down
ip link set ens36 name abc   # rename
ip link set abc up   # bring it back up

① down the interface ② rename ③ bring it up

[root@localhost ~]# ifconfig ens33 down

Socket error Event: 32 Error: 10053.

[root@localhost ~]# ip link set ens33 name mcb
[root@localhost ~]# ifconfig mcb up
[root@localhost ~]# ifconfig mcb
mcb: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
        inet 192.168.11.8 netmask 255.255.255.0 broadcast 192.168.11.255
        inet6 fe80::761e:9150:7c6f:2b3d prefixlen 64 scopeid 0x20<link>
        ether 00:0c:29:96:50:48 txqueuelen 1000 (Ethernet)

4 Permanent modify network card name

# vim /etc/default/grub

reboot/init 6 succeeded

5 Practical: dual‑NIC configuration (experiment not finished)

① Add a NIC in the VM

② Copy ens33 configuration to ens36

[root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# cp ifcfg-ens33 ifcfg-ens36
[root@localhost network-scripts]# vim ifcfg-ens36

TYPE=Ethernet
BOOTPROTO=static
NAME=ens36
DEVICE=ens36
ONBOOT=yes
IPADDR=192.168.91.110
NETMASK=255.255.255.0
GATEWAY=192.168.91.2

[root@localhost network-scripts]# systemctl restart network
[root@localhost ~]# ping 192.168.11.20
PING 192.168.11.20 (192.168.11.20) 56(84) bytes of data.
64 bytes from 192.168.11.20: icmp_seq=1 ttl=64 time=0.058 ms
...

③ Modify ens36 configuration file

④ Test

6 IP

ip link – data‑link layer

[root@localhost ~]# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT qlen 1
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000

ip addr – network layer

[root@localhost ~]# ip addr
# shorthand: ip a
# add a new virtual IP
ip address add 172.19.8.211/16 dev ens33
# temporary IP
ip address add 10.0.0.88/24 dev ens33
# delete IP
ip address del 10.0.0.8/24 dev ens33

ip route – routing table

[root@localhost ~]# ip route
default via 192.168.11.2 dev ens33 proto static metric 100
192.168.11.0/24 dev ens33 proto kernel scope link src 192.168.11.20 metric 100
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1

route -n

7 Add/delete routes

Route fields meaning

Destination, Gateway, Genmask, Flags, Metric, Ref, Use, Iface

① Add route to 10.0.0.0/8 via 192.168.227.2

route add -net 10.0.0.0/8 gw 192.168.227.2

② Delete that route

route del -net 10.0.0.0/8

③ Add default route

route add -net 0.0.0.0(default) gw 192.168.227.2

④ Permanent route

# vim /etc/sysconfig/network-scripts/route-ens33
10.0.0.0/24 via 192.168.11.11
# systemctl restart network

8 ss / netstat – network connection status

When services are unreachable (e.g., ftp, httpd):

Ping to test connectivity and firewall.

Check service status: systemctl status <em>service</em> Use ss or netstat to view listening ports.

Verify service configuration files.

netstat options

-a show all connections, -n numeric output, -t TCP, -u UDP, -r routing table, -l listening, -p process info (requires root).

ss options

-t TCP, -u UDP, -w raw sockets, -x UNIX sockets, -l listening, -a all, -n numeric, -p program/PID, -e extended, -m memory, -o timers, -r resolve names.

Difference

ss works closer to the kernel and is faster; netstat is older and slower.

9 traceroute – trace packet path

Shows each hop the packet traverses to reach a destination IP.

10 nslookup – DNS query

Verifies that a DNS server can resolve domain names; alternatives include dig, host, ping.

11 Modify hostname

Temporary change

[root@localhost ~]# hostname mg

Changes disappear after reboot.

Permanent change

Method 1: command‑line editing of /etc/hostname (image omitted).

Method 2: edit /etc/sysconfig/network (image omitted).

12 tcpdump – packet capture

Powerful network protocol analyzer for capturing and displaying packets.

① Capture on a specific NIC

tcpdump -i ens33

② List available NICs

tcpdump -D

③ Capture packets for a specific host

tcpdump host 192.168.11.12

④ Capture packets with source/destination filters

# Capture ICMP from 192.168.12 to 192.168.11.9
tcpdump -i eth0 -nn icmp and src host 192.168.12 and dst host 192.168.11.9
# Capture TCP port 22 from 192.168.11.12
tcpdump tcp port 22 and src host 192.168.11.12
# Capture first 100 packets, exclude SSH port, source net 172.16.12.0/24
tcpdump tcp -i eth1 -t -s 0 -c 100 and dst port ! 22 and src net 172.16.12.0/24 -w ./target.cap

13 Bond multiple NICs

Bonding provides redundancy (active‑backup) or load‑balancing (dual‑master).

Steps

Add a second NIC in the VM.

Copy ifcfg-ens33 to ifcfg-ens36.

Create ifcfg-bond0 and configure slave interfaces.

Restart network and verify bond status.

# Stop firewall and SELinux
systemctl stop firewalld
setenforce 0
# Copy configuration
cd /etc/sysconfig/network-scripts
cp ifcfg-ens33 ifcfg-bond0
vim ifcfg-bond0   # configure MODE=active-backup, IP, etc.
# Add slaves
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 bond0

14 View bond0 status

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

routingNetwork Configurationifconfigip commandBonding
MaGe Linux Operations
Written by

MaGe Linux Operations

Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.