RED HAT ENTERPRISE LINUX

TCP/IP Networking Basics

Network Concepts and Configuration Investigation

CIS126RH | RHEL System Administration 1
Mesa Community College

Learning Objectives

1
Understand TCP/IP layers

Describe the network model and how data flows between layers

2
Work with IP addressing

Understand IPv4/IPv6 addresses, subnet masks, and CIDR notation

3
Investigate network configuration

Use ip, ss, and other tools to examine network settings

4
Test network connectivity

Verify connectivity with ping, traceroute, and DNS tools

The TCP/IP Model

Application Layer
HTTP, HTTPS, SSH, DNS, FTP, SMTP
Transport Layer
TCP, UDP
Internet Layer
IP, ICMP, ARP
Data Encapsulation: Data flows down through layers when sending (each layer adds headers) and up through layers when receiving (each layer removes headers).

TCP vs UDP

TCP (Transmission Control Protocol)

  • Connection-oriented - establishes session first
  • Reliable delivery - acknowledges packets
  • Ordered - data arrives in sequence
  • Error checking - retransmits lost packets
  • Flow control - prevents overwhelming receiver

Used by: HTTP, SSH, FTP, SMTP, databases

UDP (User Datagram Protocol)

  • Connectionless - no session setup
  • Unreliable - no delivery guarantee
  • Unordered - packets may arrive out of order
  • No retransmission - lost packets stay lost
  • Lower overhead - faster, less latency

Used by: DNS, DHCP, streaming, VoIP, gaming

Choosing Protocol: Need reliability? Use TCP. Need speed with acceptable loss? Use UDP. Most applications use TCP unless real-time performance is critical.

Ports and Services

A port is a 16-bit number (0-65535) that identifies a specific service or application on a host. Combined with an IP address, it forms a socket.

22
SSH - Secure Shell
80
HTTP - Web (unencrypted)
443
HTTPS - Web (encrypted)
53
DNS - Domain Name System
25
SMTP - Email sending
3306
MySQL - Database
# View well-known port assignments
[student@server ~]$ cat /etc/services | head -30
[student@server ~]$ grep "^ssh" /etc/services
ssh             22/tcp                          # SSH Remote Login Protocol

IPv4 Addresses

An IPv4 address is a 32-bit number, written as four decimal octets separated by dots. Each octet ranges from 0-255.

192
.
168
.
1
.
100

Network portion    Host portion

Network Portion

Identifies which network the host belongs to. All hosts on the same network share this portion.

Host Portion

Identifies the specific host within that network. Must be unique on the network.

Special Addresses: The first address in a network is the network address (192.168.1.0). The last is the broadcast address (192.168.1.255). Neither can be assigned to hosts.

Subnet Masks and CIDR

A subnet mask defines which bits of an IP address are the network portion (1s) and which are the host portion (0s).

CIDR Subnet Mask Network Bits Host Bits Hosts
/8 255.0.0.0 8 24 16,777,214
/16 255.255.0.0 16 16 65,534
/24 255.255.255.0 24 8 254
/25 255.255.255.128 25 7 126
/30 255.255.255.252 30 2 2
# CIDR notation: IP address/prefix length
192.168.1.100/24   # Common for LANs
10.0.0.50/8        # Large private network
172.16.5.20/16     # Medium private network

Private vs Public Addresses

Private Address Ranges

Reserved for internal networks, not routed on the Internet:

10.0.0.0/816M addresses
172.16.0.0/121M addresses
192.168.0.0/1665K addresses

Public Addresses

Globally unique, routable on the Internet:

  • Assigned by ISPs and registries
  • Must be paid for / allocated
  • Used for Internet-facing servers
  • Increasingly scarce (IPv4 exhaustion)
NAT (Network Address Translation): Allows private addresses to access the Internet by translating them to public addresses at the network boundary.
# Loopback address - always refers to this host
127.0.0.1        # IPv4 loopback
::1              # IPv6 loopback

IPv6 Addresses

IPv6 uses 128-bit addresses, written as eight groups of four hexadecimal digits separated by colons.

# Full IPv6 address
2001:0db8:0000:0000:0000:0000:0000:0001

# Simplified (remove leading zeros, :: for consecutive zero groups)
2001:db8::1

# Link-local address (auto-configured, starts with fe80)
fe80::a00:27ff:fe4e:66a1

# Loopback
::1

IPv6 Benefits

  • Vastly larger address space
  • Built-in IPsec support
  • Auto-configuration (SLAAC)
  • No need for NAT

Common Prefixes

  • 2000::/3 - Global unicast
  • fe80::/10 - Link-local
  • fc00::/7 - Unique local (private)
  • ::1/128 - Loopback

DNS - Domain Name System

DNS translates human-readable domain names (like www.example.com) into IP addresses that computers use to route traffic.

www.example.com
DNS Query
93.184.216.34
# DNS configuration file
[student@server ~]$ cat /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
search example.com

# Local hostname resolution
[student@server ~]$ cat /etc/hosts
127.0.0.1   localhost localhost.localdomain
::1         localhost localhost.localdomain
192.168.1.10 webserver.example.com webserver

# Resolution order
[student@server ~]$ grep hosts /etc/nsswitch.conf
hosts:      files dns myhostname

Network Interfaces

A network interface represents a network connection - physical (Ethernet, Wi-Fi) or virtual (loopback, bridge, VLAN). Each has a unique name.

Name Pattern Type Example
lo Loopback (localhost) lo
eno* Onboard Ethernet eno1, eno2
ens* PCI Express hotplug slot ens33, ens192
enp*s* PCI bus location enp0s3, enp3s0
eth* Legacy naming (older systems) eth0, eth1
wl* Wireless LAN wlan0, wlp2s0
Predictable Names: RHEL uses "predictable network interface names" based on hardware location. This prevents names from changing when hardware is added/removed.

The ip Command

# Show all interfaces and addresses
[student@server ~]$ ip addr show
[student@server ~]$ ip a                    # Short form

# Show specific interface
[student@server ~]$ ip addr show ens33

# Show only IPv4 addresses
[student@server ~]$ ip -4 addr

# Show only IPv6 addresses
[student@server ~]$ ip -6 addr

# Show link layer information (MAC addresses, state)
[student@server ~]$ ip link show
[student@server ~]$ ip l                    # Short form

# Brief output format
[student@server ~]$ ip -br addr
lo               UNKNOWN        127.0.0.1/8 ::1/128 
ens33            UP             192.168.1.100/24 fe80::a00:27ff:fe4e:66a1/64
Note: The ifconfig command is deprecated. Always use ip on modern systems.

Understanding ip addr Output

2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 link/ether 00:0c:29:4e:66:a1 brd ff:ff:ff:ff:ff:ff altname enp2s1 inet 192.168.1.100/24 brd 192.168.1.255 scope global dynamic noprefixroute ens33 valid_lft 86400sec preferred_lft 86400sec inet6 fe80::a00:27ff:fe4e:66a1/64 scope link noprefixroute valid_lft forever preferred_lft forever

Interface name: ens33

Flags: UP (enabled), LOWER_UP (link detected)

MTU: 1500 bytes (standard Ethernet)

MAC address: 00:0c:29:4e:66:a1

IPv4: 192.168.1.100/24

Broadcast: 192.168.1.255

IPv6 link-local: fe80::...

Scope: global (routable) or link (local only)

dynamic: Address was assigned by DHCP. noprefixroute: Don't automatically add route for this prefix.

Viewing Routes

The routing table determines where packets are sent based on their destination address. Each entry specifies a destination network and where to send matching packets.

# Show routing table
[student@server ~]$ ip route show
[student@server ~]$ ip r                    # Short form
default via 192.168.1.1 dev ens33 proto dhcp metric 100
192.168.1.0/24 dev ens33 proto kernel scope link src 192.168.1.100 metric 100

# Show IPv6 routes
[student@server ~]$ ip -6 route

# Show route to specific destination
[student@server ~]$ ip route get 8.8.8.8
8.8.8.8 via 192.168.1.1 dev ens33 src 192.168.1.100 uid 1000

default via 192.168.1.1

Default gateway - where to send packets when no other route matches. Essential for Internet access.

192.168.1.0/24 dev ens33

Direct route - this network is directly connected, send packets directly via this interface.

Viewing Connections: ss

# Show all connections
[student@server ~]$ ss

# Show listening sockets
[student@server ~]$ ss -l

# Show TCP connections
[student@server ~]$ ss -t
[student@server ~]$ ss -lt              # TCP listening

# Show UDP sockets
[student@server ~]$ ss -u
[student@server ~]$ ss -lu              # UDP listening

# Show with process information (requires root)
[root@server ~]# ss -tlnp
State  Recv-Q Send-Q Local Address:Port  Peer Address:Port Process
LISTEN 0      128    0.0.0.0:22           0.0.0.0:*         users:(("sshd",pid=1234,fd=3))

# Show numeric (don't resolve names)
[student@server ~]$ ss -n

# Show all with details
[student@server ~]$ ss -tulna

Testing Connectivity: ping

ping sends ICMP Echo Request packets to a host and waits for Echo Reply packets. It's the most basic connectivity test.

# Ping a host (runs until Ctrl+C)
[student@server ~]$ ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.543 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.412 ms
^C
--- 192.168.1.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.412/0.477/0.543/0.065 ms

# Send specific number of pings
[student@server ~]$ ping -c 4 google.com

# Ping IPv6 address
[student@server ~]$ ping -6 ::1
[student@server ~]$ ping6 fe80::1%ens33    # Link-local needs interface

# Quick connectivity check
[student@server ~]$ ping -c 1 -W 2 192.168.1.1 && echo "Host is up"

Tracing Routes

# Trace route to destination
[student@server ~]$ traceroute google.com
traceroute to google.com (142.250.80.46), 30 hops max, 60 byte packets
 1  gateway (192.168.1.1)  0.543 ms  0.412 ms  0.389 ms
 2  10.0.0.1 (10.0.0.1)  5.234 ms  5.112 ms  5.089 ms
 3  isp-router.example.net (203.0.113.1)  12.456 ms  12.234 ms  12.198 ms
 4  * * *
 5  google-peer.example.net (198.51.100.1)  15.678 ms  15.456 ms  15.234 ms
 6  142.250.80.46 (142.250.80.46)  16.789 ms  16.567 ms  16.345 ms

# Use ICMP instead of UDP (may pass firewalls better)
[student@server ~]$ traceroute -I google.com

# Use TCP to specific port
[student@server ~]$ traceroute -T -p 443 google.com

# Alternative: mtr (combines ping and traceroute)
[student@server ~]$ mtr google.com
* * * means: That hop didn't respond - either the router doesn't send ICMP responses, or a firewall blocks them. It doesn't necessarily mean a problem.

DNS Diagnostic Tools

# Simple DNS lookup
[student@server ~]$ host google.com
google.com has address 142.250.80.46
google.com has IPv6 address 2607:f8b0:4004:800::200e
google.com mail is handled by 10 smtp.google.com.

# Detailed DNS query
[student@server ~]$ dig google.com
;; ANSWER SECTION:
google.com.             300     IN      A       142.250.80.46

# Query specific record type
[student@server ~]$ dig google.com MX          # Mail servers
[student@server ~]$ dig google.com NS          # Name servers
[student@server ~]$ dig google.com AAAA        # IPv6 address

# Query specific DNS server
[student@server ~]$ dig @8.8.8.8 google.com

# Reverse lookup (IP to name)
[student@server ~]$ dig -x 8.8.8.8
[student@server ~]$ host 8.8.8.8

# Short output
[student@server ~]$ dig +short google.com
142.250.80.46

NetworkManager Overview

NetworkManager is the default network configuration daemon on RHEL. It manages network connections through profiles called "connections."

# Check NetworkManager status
[student@server ~]$ systemctl status NetworkManager

# List all connections
[student@server ~]$ nmcli connection show
NAME     UUID                                  TYPE      DEVICE
ens33    a1b2c3d4-e5f6-7890-abcd-ef1234567890  ethernet  ens33
virbr0   b2c3d4e5-f6a7-8901-bcde-f12345678901  bridge    virbr0

# Show device status
[student@server ~]$ nmcli device status
DEVICE  TYPE      STATE      CONNECTION
ens33   ethernet  connected  ens33
lo      loopback  unmanaged  --

# Show detailed connection info
[student@server ~]$ nmcli connection show ens33

# Show general network status
[student@server ~]$ nmcli general status

Troubleshooting Workflow

1
Check interface: ip addr - Is the interface UP? Does it have an IP?
2
Check gateway: ip route - Is default route configured? ping gateway
3
Check DNS: cat /etc/resolv.conf - Are nameservers configured? dig
4
Test remote: ping external IP (8.8.8.8), then hostname
5
Check service: ss -tln - Is service listening? Test with client.
# Quick diagnostic sequence
ip -br addr                 # Interface status
ip route                    # Routing table
ping -c 1 192.168.1.1       # Gateway reachable?
ping -c 1 8.8.8.8           # Internet reachable?
dig google.com              # DNS working?
ss -tlnp                    # Services listening?

Key Takeaways

1

TCP/IP Model: Four layers (Application, Transport, Internet, Link); TCP for reliability, UDP for speed

2

IP Addressing: IPv4 (32-bit, dotted decimal), IPv6 (128-bit, hex); subnet masks define network/host portions

3

Investigation: ip addr for interfaces, ip route for routing, ss for connections

4

Testing: ping for connectivity, traceroute for path, dig for DNS

Graded Lab

  • Use ip addr to view all network interfaces and their addresses
  • Examine the routing table and identify the default gateway
  • Use ss to find all TCP services listening on your system
  • Ping your gateway, then ping 8.8.8.8 to test Internet connectivity
  • Use dig to query DNS for various record types (A, MX, NS)
  • Run traceroute to an external host and interpret the results

Next: Managing Network Configuration