Currently Empty: ₹0.00
Uncategorized
Linux Networking Basics: MAC, IP, Subnetting & nmcli Commands Explained
1. What is networking?
A network is formed when multiple physical or virtual computing devices are interconnected so they can share data and resources.
Medium
Devices communicate over a wired medium (copper or fibre cable) or a wireless medium (Wi-Fi, radio).
2. LAN and WAN
LAN (Local Area Network) connects devices within a single building or campus, typically through a switch.
WAN (Wide Area Network) links many LANs across cities or countries. The Internet is the largest WAN.
3. Network Interface Controller (NIC) and MAC address
The NIC is the hardware card or chip that connects a computer to a network.
The MAC (Media Access Control) address:
- is a physical / hardware address assigned to the NIC
- is a unique identifier for IEEE 802 technologies (Ethernet, Wi-Fi, Bluetooth)
- is written in hexadecimal: 12 hex digits, or 48 bits
Example: 00-1E-67-B0-08-D8
4. Internet Protocol (IP) address
- A logical, location-based address
- Written in dotted decimal. An IPv4 address is 32 bits long (4 octets of 8 bits)
Example: 192.168.1.100
Range of IPv4
00000000.00000000.00000000.00000000 → 0.0.0.0 11111111.11111111.11111111.11111111 → 255.255.255.255
5. Classes of IP
| Class | First octet range | Used for |
|---|---|---|
| A | 0 – 127 | Unicast, large networks |
| B | 128 – 191 | Unicast, medium networks |
| C | 192 – 223 | Unicast, small networks |
| D | 224 – 239 | Multicasting |
| E | 240 – 255 | Reserved for R&D |
Special values: 0 means any network (default route), and 127 is the loopback range, used by a machine to talk to itself.
6. Network / Host bits and subnet mask
| Class | Network bits | Host bits | Subnet mask | Prefix |
|---|---|---|---|---|
| A | 8 bits | 24 bits | 255.0.0.0 | /8 |
| B | 16 bits | 16 bits | 255.255.0.0 | /16 |
| C | 24 bits | 8 bits | 255.255.255.0 | /24 |
The network bits identify the network, and the host bits identify a device inside it. The subnet mask, or prefix length, tells the system where that split is. For example, 192.168.1.100/24 means network 192.168.1 and host .100.
7. Naming of NICs in Linux
| Type | Interface names |
|---|---|
| Physical NIC | ethX, ensX, enoX, enpXsY |
| Virtual NIC | lo, brX, virbrX, teamX, vnetX, bond |
| Wireless NIC | wlanX |
Modern RHEL uses predictable names like ens160 or enp0s3, based on where the card sits in the hardware, instead of the older eth0.
8. Verify NIC and IP properties
ip linkLists every network interface with its state (UP/DOWN) and MAC address.
ip addrShows the IPv4 and IPv6 addresses assigned to each interface.
ip link && ip addrRuns both: first the interfaces, then their IP addresses.
Sample output:
[root@servera ~]# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether 00:0c:29:a2:3f:20 brd ff:ff:ff:ff:ff:ff
[root@servera ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:a2:3f:20 brd ff:ff:ff:ff:ff:ff
inet 10.0.0.10/8 brd 10.255.255.255 scope global noprefixroute ens160
inet6 fe80::2e6a:a60b:304b:76e0/64 scope link noprefixroute
9. Add or delete an IP address with the ip command
Delete an IP address
ip addr del 10.0.0.10/8 dev ens160Removes the IP 10.0.0.10 (mask /8) from interface ens160.
Add an IP address
ip addr add 172.16.0.10/16 dev ens160Assigns the IP 172.16.0.10 with a /16 mask to interface ens160.
Note: changes made with the
ip command are not permanent. They are lost after a reboot or network restart.
For a permanent configuration, use NetworkManager. On RHEL 7/8, profiles are stored in /etc/sysconfig/network-scripts/ifcfg-*; on RHEL 9 and later they are stored in /etc/NetworkManager/system-connections/.10. NetworkManager
NetworkManager is a daemon in RHEL that manages IP properties and keeps them persistent across reboots. There are two ways to manage it:
nmtuiOpens a text-based menu to add, edit and activate connections, with no commands to remember.
nmcliThe command-line client for NetworkManager. Fast and scriptable.
11. Listing connections
nmcli con showLists all saved connection profiles with their name, UUID, type and device.
nmcli con show --activeLists only the connections that are currently up.
nmcli con show <con-name> | grep ipv4Filters a profile’s settings down to its IPv4 details: method, address, gateway, DNS.
nmcli con show <con-name> | grep connectionShows the profile’s general settings: ID, UUID, interface name and autoconnect.
12. Creating a connection
DHCP (automatic IP)
nmcli con add con-name <con-name> ifname ens160 type ethernetCreates an Ethernet profile on ens160 that gets its IP automatically from a DHCP server.
Manual (static IP)
nmcli con add con-name <con-name> ifname ens160 type ethernet ip4 172.17.0.10/16 gw4 172.17.0.1 ip6 2000::10/64 gw6 2000::1Creates a profile with a static IPv4 address and gateway plus a static IPv6 address and gateway.
13. Activating and deactivating a connection
nmcli con up <con-name>Activates the profile and applies its settings to the interface.
nmcli con down <con-name>Deactivates the profile and removes its settings from the interface.
14. Deleting a connection
nmcli con del <con-name>Deletes the connection profile permanently and takes it down if it was active.
15. Modifying a connection
nmcli con modify <con-name> ipv4.addresses 172.18.0.10/16 ipv4.gateway 172.18.0.1 ipv4.dns 8.8.8.8 ipv4.method manualChanges the saved profile to a static IP, gateway and DNS server. Run nmcli con up
nmcli con up <con-name>Re-activates the profile so the modified settings take effect immediately.
Tip:
nmcli con modify only edits the saved profile. Nothing changes on the interface until you bring the connection up again.Found this useful?
Bookmark it for your next RHEL lab and follow Annwen Technology for more Linux & automation guides.
Innovate · Automate · Elevate



