š 6.6 IP Services Functionality
Overview
IP services provide essential network functions that enable communication, address management, time synchronization, and network monitoring. Understanding DHCP, DNS, NAT, SNMP, and NTP is crucial for network operations and automation.
1. DHCP (Dynamic Host Configuration Protocol)
š Automatic IP Address Assignment
Function: DHCP automatically assigns IP addresses and network configuration to devices, eliminating manual configuration
DHCP Process - DORA
DHCP Information Provided
| Parameter | Description | Example |
|---|---|---|
| IP Address | Assigned to client | 192.168.1.100 |
| Subnet Mask | Network/host boundary | 255.255.255.0 |
| Default Gateway | Router to other networks | 192.168.1.1 |
| DNS Server | Name resolution | 8.8.8.8, 8.8.4.4 |
| Lease Time | How long IP is valid | 86400 seconds (24 hours) |
| Domain Name | DNS suffix | example.com |
DHCP Ports
- Server Port: UDP 67
- Client Port: UDP 68
# Cisco IOS DHCP Server Configuration
Router(config)# ip dhcp pool LAN_POOL
Router(dhcp-config)# network 192.168.1.0 255.255.255.0
Router(dhcp-config)# default-router 192.168.1.1
Router(dhcp-config)# dns-server 8.8.8.8 8.8.4.4
Router(dhcp-config)# domain-name example.com
Router(dhcp-config)# lease 7
# Exclude addresses from DHCP pool
Router(config)# ip dhcp excluded-address 192.168.1.1 192.168.1.10
# Python - DHCP Client Simulation
from scapy.all import *
# Send DHCP Discover
dhcp_discover = Ether(dst="ff:ff:ff:ff:ff:ff") / IP(src="0.0.0.0", dst="255.255.255.255") / UDP(sport=68, dport=67) / BOOTP(chaddr='00:11:22:33:44:55') / DHCP(options=[("message-type", "discover"), "end"])
# In production, use dhclient or built-in OS DHCP2. DNS (Domain Name System)
š Name-to-IP Address Resolution
Function: DNS translates human-readable domain names (like www.cisco.com) into IP addresses (like 72.163.4.185) that computers use for communication
DNS Query Process
DNS Record Types
| Record Type | Purpose | Example |
|---|---|---|
| A | Maps hostname to IPv4 | www.cisco.com ā 72.163.4.185 |
| AAAA | Maps hostname to IPv6 | www.cisco.com ā 2001:420:1101:1::185 |
| CNAME | Alias to another name | mail ā webmail.cisco.com |
| MX | Mail exchange server | Priority 10 ā mail.cisco.com |
| NS | Name server for domain | ns1.cisco.com |
| PTR | Reverse lookup (IP ā name) | 185.4.163.72.in-addr.arpa ā www |
| TXT | Text information (SPF, DKIM) | v=spf1 include:_spf.cisco.com |
DNS Ports
- Standard Queries: UDP 53 (preferred for speed)
- Zone Transfers: TCP 53 (reliable transfer)
- Large Responses: TCP 53 (if UDP response > 512 bytes)
# Cisco IOS DNS Configuration
Router(config)# ip domain-name cisco.com
Router(config)# ip name-server 8.8.8.8
Router(config)# ip name-server 8.8.4.4
# Python DNS Query
import socket
# Method 1: Built-in
ip_address = socket.gethostbyname("www.cisco.com")
print(f"IP Address: {ip_address}")
# Method 2: Using dnspython library
# import dns.resolver
# answer = dns.resolver.resolve('www.cisco.com', 'A')
# for rdata in answer:
# print(f"IP: {rdata.address}")
# Linux/Windows command
# nslookup www.cisco.com
# dig www.cisco.com3. NAT (Network Address Translation)
š Private-to-Public IP Address Translation
Function: NAT translates private IP addresses (RFC 1918) to public IP addresses, allowing multiple devices to share a single public IP and providing security by hiding internal addresses
192.168.1.10"] --> R["NAT Router
Inside: 192.168.1.1
Outside: 203.0.113.50"] PC2["PC2
192.168.1.11"] --> R PC3["PC3
192.168.1.12"] --> R R --> I["Internet
Destination: 8.8.8.8"] style PC1 fill:#e3f2fd,stroke:#1976d2,stroke-width:2px style PC2 fill:#e3f2fd,stroke:#1976d2,stroke-width:2px style PC3 fill:#e3f2fd,stroke:#1976d2,stroke-width:2px style R fill:#667eea,stroke:#764ba2,stroke-width:3px,color:#fff style I fill:#fff3e0,stroke:#e65100,stroke-width:2px
NAT Types
| NAT Type | Description | Use Case |
|---|---|---|
| Static NAT | One-to-one mapping (1 private ā 1 public) | Web servers, mail servers |
| Dynamic NAT | Pool of public IPs assigned dynamically | Multiple users, limited public IPs |
| PAT (NAT Overload) | Many private IPs to ONE public IP using ports | Home/office networks (most common) |
NAT Table Example (PAT)
Inside Local Inside Global Protocol 192.168.1.10:5001 203.0.113.50:5001 TCP 192.168.1.11:5002 203.0.113.50:5002 TCP 192.168.1.12:5003 203.0.113.50:5003 TCP Translation: Inside Local ā Private IP + Port (before NAT) Inside Global ā Public IP + Port (after NAT) All three PCs share 203.0.113.50 but use different port numbers!
# Cisco IOS NAT Configuration # Static NAT (1:1) Router(config)# ip nat inside source static 192.168.1.100 203.0.113.10 # PAT (NAT Overload - most common) Router(config)# access-list 1 permit 192.168.1.0 0.0.0.255 Router(config)# ip nat inside source list 1 interface GigabitEthernet0/0 overload # Interface configuration Router(config)# interface GigabitEthernet0/1 Router(config-if)# ip nat inside Router(config)# interface GigabitEthernet0/0 Router(config-if)# ip nat outside # View NAT translations Router# show ip nat translations Router# show ip nat statistics
4. SNMP (Simple Network Management Protocol)
š Network Monitoring and Management
Function: SNMP enables network administrators to monitor and manage network devices, collect statistics, and receive alerts about device status
Network Management
System"] -->|GET/SET| R["Router"] NMS -->|GET/SET| SW["Switch"] NMS -->|GET/SET| FW["Firewall"] R -->|TRAP/Notification| NMS SW -->|TRAP/Notification| NMS FW -->|TRAP/Notification| NMS style NMS fill:#667eea,stroke:#764ba2,stroke-width:3px,color:#fff style R fill:#66bb6a,stroke:#2e7d32,stroke-width:2px,color:#fff style SW fill:#42a5f5,stroke:#1976d2,stroke-width:2px,color:#fff style FW fill:#ffa726,stroke:#e65100,stroke-width:2px,color:#fff
SNMP Versions & Ports
| Version | Security | Ports |
|---|---|---|
| SNMPv1 | Community strings (plain text) | UDP 161 (agent), UDP 162 (traps) |
| SNMPv2c | Community strings (plain text) | UDP 161 (agent), UDP 162 (traps) |
| SNMPv3 | Authentication & Encryption ā | UDP 161 (agent), UDP 162 (traps) |
SNMP Operations
- GET: Retrieve specific value from device
- GET-NEXT: Retrieve next value in MIB tree
- GET-BULK: Retrieve multiple values (v2c+)
- SET: Change configuration on device
- TRAP: Unsolicited alert from device to NMS
- INFORM: Acknowledged TRAP (v2c+)
# Cisco IOS SNMP Configuration
Router(config)# snmp-server community PUBLIC ro
Router(config)# snmp-server community PRIVATE rw
Router(config)# snmp-server host 192.168.1.100 version 2c PUBLIC
Router(config)# snmp-server enable traps
# SNMPv3 (Secure)
Router(config)# snmp-server group ADMIN v3 priv
Router(config)# snmp-server user admin ADMIN v3 auth sha Authpass123 priv aes 128 Privpass123
# Python SNMP Query
from pysnmp.hlapi import *
# GET request
iterator = getCmd(
SnmpEngine(),
CommunityData('public'),
UdpTransportTarget(('192.168.1.1', 161)),
ContextData(),
ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0))
)
errorIndication, errorStatus, errorIndex, varBinds = next(iterator)
if not errorIndication:
for varBind in varBinds:
print(f'{varBind[0]} = {varBind[1]}')5. NTP (Network Time Protocol)
š Time Synchronization
Function: NTP synchronizes clocks across network devices, crucial for logging, authentication, and time-sensitive applications
Atomic Clock
GPS"] Stratum1["Stratum 1
NTP Server
time.nist.gov"] Stratum2["Stratum 2
Corporate NTP Server
192.168.1.1"] R1["Router 1"] R2["Router 2"] SW1["Switch 1"] Stratum0 --> Stratum1 Stratum1 --> Stratum2 Stratum2 --> R1 Stratum2 --> R2 Stratum2 --> SW1 style Stratum0 fill:#667eea,stroke:#764ba2,stroke-width:3px,color:#fff style Stratum1 fill:#66bb6a,stroke:#2e7d32,stroke-width:2px,color:#fff style Stratum2 fill:#42a5f5,stroke:#1976d2,stroke-width:2px,color:#fff
NTP Details
- Port: UDP 123
- Stratum 0: Reference clocks (atomic, GPS)
- Stratum 1: Servers directly connected to Stratum 0
- Stratum 2-15: Clients of higher stratum servers
- Accuracy: Milliseconds over Internet, microseconds on LAN
- Why Important: Log correlation, certificates, Kerberos, compliance
# Cisco IOS NTP Configuration
Router(config)# ntp server 132.163.96.1
Router(config)# ntp server 216.239.35.0
Router(config)# ntp update-calendar
# Set timezone
Router(config)# clock timezone EST -5
Router(config)# clock summer-time EDT recurring
# Verify NTP
Router# show ntp status
Router# show ntp associations
# Python NTP Query
import ntplib
from time import ctime
ntp_client = ntplib.NTPClient()
response = ntp_client.request('pool.ntp.org', version=3)
print(f"Current time: {ctime(response.tx_time)}")
print(f"Offset: {response.offset} seconds")
print(f"Stratum: {response.stratum}")š 6.7 Common Protocol Port Values
Overview
Port numbers identify specific services and applications running on network devices. Recognizing common ports is essential for network management, security, and troubleshooting. Ports range from 0-65535 and are divided into three categories.
0-65535"] --> B["Well-Known
0-1023"] A --> C["Registered
1024-49151"] A --> D["Dynamic/Private
49152-65535"] B --> B1["SSH: 22"] B --> B2["HTTP: 80"] B --> B3["HTTPS: 443"] C --> C1["Custom Apps"] C --> C2["Vendor Services"] D --> D1["Ephemeral Ports"] D --> D2["Client Connections"] style A fill:#667eea,stroke:#764ba2,stroke-width:3px,color:#fff style B fill:#66bb6a,stroke:#2e7d32,stroke-width:2px,color:#fff style C fill:#42a5f5,stroke:#1976d2,stroke-width:2px,color:#fff style D fill:#ffa726,stroke:#e65100,stroke-width:2px,color:#fff
1. Well-Known Ports (0-1023)
š Standard System and Protocol Ports
Purpose: Well-known ports are assigned by IANA for standard services and require root/admin privileges on Unix/Windows systems
DEVASC Exam Focus Ports
| Port | Protocol | Service | Description |
|---|---|---|---|
| 22 | TCP | SSH | Secure Shell - Encrypted remote access |
| 23 | TCP | Telnet | Unencrypted remote access (insecure) |
| 53 | TCP/UDP | DNS | Domain Name System (UDP queries, TCP zone transfers) |
| 67/68 | UDP | DHCP | Dynamic Host Configuration (67=server, 68=client) |
| 80 | TCP | HTTP | HyperText Transfer Protocol (unencrypted web) |
| 123 | UDP | NTP | Network Time Protocol |
| 161/162 | UDP | SNMP | Simple Network Management (161=agent, 162=traps) |
| 443 | TCP | HTTPS | HTTP Secure - TLS/SSL encrypted web traffic |
| 830 | TCP | NETCONF | Network Configuration Protocol over SSH |
Additional Common Well-Known Ports
| Port | Protocol | Service | Use Case |
|---|---|---|---|
| 20/21 | TCP | FTP | File Transfer (20=data, 21=control) |
| 25 | TCP | SMTP | Simple Mail Transfer Protocol |
| 69 | UDP | TFTP | Trivial FTP (IOS upgrades, config backup) |
| 110 | TCP | POP3 | Post Office Protocol (email retrieval) |
| 143 | TCP | IMAP | Internet Message Access Protocol |
| 389 | TCP/UDP | LDAP | Lightweight Directory Access Protocol |
| 514 | UDP | Syslog | System logging |
| 636 | TCP | LDAPS | LDAP over SSL/TLS |
2. Cisco-Specific & Registered Ports (1024-49151)
š§ Cisco Network Device Management Ports
Purpose: Registered ports are assigned by IANA for specific applications and services, including Cisco network management and API protocols
Cisco Network Management Ports
| Port | Protocol | Service | Description |
|---|---|---|---|
| 8443 | TCP | DNA Center | Cisco DNA Center API (HTTPS) |
| 9443 | TCP | APIC | Cisco ACI APIC GUI/API |
| 8080 | TCP | HTTP Alt | Alternative HTTP, often for APIs |
| 8008/8888 | TCP | Web Services | Common alternative web ports |
RESTCONF & Other Programmability Ports
| Port | Protocol | Service | Platform |
|---|---|---|---|
| 443 | TCP | RESTCONF | IOS XE (over HTTPS) |
| 830 | TCP | NETCONF | IOS XE, NX-OS (over SSH) |
| 8181 | TCP | RESTCONF | Cisco NSO |
| 9080/9060 | TCP | Webex APIs | Collaboration platforms |
| 5555 | TCP | APIC-EM | Legacy Cisco controller |
Port Memorization Tips for DEVASC
ā MUST KNOW (Exam Critical): SSH: 22 (Secure remote management) Telnet: 23 (Insecure - avoid) HTTP: 80 (APIs, web) HTTPS: 443 (Secure APIs, RESTCONF) NETCONF: 830 (Model-driven over SSH) SNMP: 161/162 (Monitoring) DNS: 53 (Name resolution) DHCP: 67/68 (IP assignment) NTP: 123 (Time sync) š§ Good to Know: TFTP: 69 (IOS upgrades) Syslog: 514 (Logging) FTP: 20/21 (File transfer) LDAP: 389 (Directory services) š” Memory Aid - "Security Trio" 22 = SSH (Secure Shell) 443 = HTTPS (Secure Web) 830 = NETCONF (Secure Config) All use encryption! Remember: 22, 443, 830
3. Python Code Examples - Working with Ports
š Practical Port Usage in Network Programming
Purpose: Understanding how to work with ports programmatically for API calls, socket programming, and network automation
Example 1: API Calls with Different Ports
# Python - REST API with Custom Ports
import requests
from requests.auth import HTTPBasicAuth
# HTTPS API (port 443 - standard)
response = requests.get(
"https://192.168.1.1/restconf/data/ietf-interfaces:interfaces",
auth=HTTPBasicAuth("admin", "password"),
headers={"Accept": "application/yang-data+json"},
verify=False
)
print(response.status_code)
# Custom port API (e.g., DNA Center on 443, Meraki on 443)
meraki_response = requests.get(
"https://api.meraki.com/api/v1/organizations",
headers={"X-Cisco-Meraki-API-Key": "your_api_key"}
)
# ACI APIC on port 9443
aci_response = requests.post(
"https://apic-ip:9443/api/aaaLogin.json",
json={"aaaUser": {"attributes": {"name": "admin", "pwd": "password"}}},
verify=False
)Example 2: Socket Programming with Ports
# Python - Socket Connection Examples
import socket
# Connect to SSH port (22)
def check_ssh(host):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(2)
result = sock.connect_ex((host, 22))
if result == 0:
print(f"Port 22 (SSH) is OPEN on {host}")
else:
print(f"Port 22 (SSH) is CLOSED on {host}")
sock.close()
# Port scanner for common services
def scan_common_ports(host):
common_ports = {
22: "SSH",
23: "Telnet",
80: "HTTP",
443: "HTTPS",
830: "NETCONF",
161: "SNMP"
}
print(f"Scanning {host}...")
for port, service in common_ports.items():
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.settimeout(1)
result = sock.connect_ex((host, port))
if result == 0:
print(f" ā
{service:10} (Port {port}) - OPEN")
else:
print(f" ā {service:10} (Port {port}) - CLOSED")
sock.close()
# Usage
scan_common_ports("192.168.1.1")Example 3: NETCONF Connection (Port 830)
# Python - NETCONF over port 830
from ncclient import manager
# Connect to device via NETCONF (port 830)
with manager.connect(
host="192.168.1.1",
port=830,
username="admin",
password="password",
hostkey_verify=False
) as m:
# Get running configuration
config = m.get_config(source="running")
print(config)
# Get operational data
filter = '''
'''
result = m.get(filter=filter)
print(result)Example 4: Port in URL Construction
# Python - Explicit port specification
from urllib.parse import urlparse
# Construct URLs with custom ports
base_url_custom_port = "https://dna-center.example.com:8443/api/v1/network-device"
apic_url = "https://apic.example.com:9443/api/node/class/fvTenant.json"
# Parse URL to extract port
parsed = urlparse(base_url_custom_port)
print(f"Scheme: {parsed.scheme}") # https
print(f"Host: {parsed.hostname}") # dna-center.example.com
print(f"Port: {parsed.port}") # 8443
print(f"Path: {parsed.path}") # /api/v1/network-device
# Make request
response = requests.get(
base_url_custom_port,
auth=("admin", "password"),
verify=False
)
print(f"Status: {response.status_code}")Port Security Best Practices
- Disable Telnet (23): Always use SSH (22) instead
- Use HTTPS (443): Never send credentials over HTTP (80)
- Firewall Rules: Only allow necessary ports
- SNMPv3: Use encrypted SNMP, not v1/v2c
- Change Default Ports: Consider non-standard ports for added security
- Monitor Open Ports: Regular audits with nmap or similar tools
š Interactive Python Interpreter
- Write Python code in the editor
- Click "ā¶ Run Code" to execute
- Try sample code buttons
1. Switches
š Layer 2 Frame Forwarding
Function: Switches forward frames based on MAC addresses within a local network segment
This sequence diagram shows a two-phase process:
- Phase 1 (Lines 1-6): User logs in with username/password, receives a JWT token
- Phase 2 (Lines 7-12): User makes API requests using the token instead of password
Step-by-Step Interpretation
PHASE 1: LOGIN AND GET TOKEN Step 1: User enters username and password into Client App Step 2: Client sends POST request to /api/v1/auth/login with credentials Step 3: Auth API queries Database to verify username and password Step 4: Database confirms user is valid Step 5: Auth API returns 200 OK with JWT token (e.g., "abc123...") Step 6: Client App stores the token locally (memory, localStorage, etc.) PHASE 2: USE TOKEN FOR API CALLS Step 7: User requests to see device list Step 8: Client sends GET /api/v1/devices with "Authorization: Bearer abc123" header Step 9: Device API validates the token is authentic and not expired Step 10: Device API queries Database for device records Step 11: Database returns list of devices Step 12: Device API returns 200 OK with JSON array of devices Step 13: Client App displays devices to User KEY INSIGHTS: ā Password is only sent ONCE during login (Step 2) ā Token is used for ALL subsequent API calls (Step 8, etc.) ā Token can expire and requires re-authentication ā More secure than sending password with every request
2. Routers
š Layer 3 Packet Routing
Function: Routers forward packets between different networks based on IP addresses and routing tables
This shows cloud-managed networking where API calls flow through the Meraki Dashboard to cloud controllers, which then push configs to physical devices.
Step-by-Step Interpretation
Step 1-2: Script retrieves organization list using API key authentication ā Response: Organization ID 123 named "Corp" Step 3-6: Script creates new wireless network in organization 123 ā POST request with network name and type ā Meraki provisions network in cloud ā Response: Network ID "net-456" created (HTTP 201) Step 7-12: Script configures WiFi SSID on the new network ā PUT request to update SSID 0 ā Cloud controller receives config update ā Config is pushed to physical Access Point ā AP applies the configuration ā Success confirmation flows back through cloud to API ā Response: 200 OK WORKFLOW PATTERN: 1. GET (retrieve org ID) 2. POST (create new resource) 3. PUT/PATCH (configure resource) KEY INSIGHT: ⢠Cloud-managed: Changes go through API ā Cloud ā Device ⢠No direct device access needed ⢠Centralized management
3. Firewalls
š”ļø Network Security and Traffic Filtering
Function: Firewalls control incoming and outgoing network traffic based on security rules and policies
Shows how DNA Center discovers devices, assigns them to sites, and deploys configuration templates.
Step-by-Step Interpretation
AUTHENTICATION:
Step 1-4: Script authenticates to DNA Center
ā POST to /auth/token with credentials
ā DNAC validates user in database
ā Returns authentication token (xyz789)
DEVICE DISCOVERY:
Step 5-9: Script initiates device discovery
ā POST device IP address (10.1.1.1)
ā DNAC uses CDP/LLDP to discover device
ā Router responds with device information
ā DNAC stores device in inventory database
ā Returns task ID (202 Accepted - async operation)
TASK MONITORING:
Step 10-11: Script polls for task completion
ā GET /task/{taskId} to check status
ā Returns progress update
TEMPLATE DEPLOYMENT:
Step 12-15: Script deploys configuration template
ā POST with device ID and template ID
ā DNAC pushes config to router via NETCONF
ā Router applies configuration
ā Returns 200 OK (success)
PATTERN:
⢠Asynchronous operations (discovery returns task ID)
⢠Polling required for long-running tasks
⢠Uses NETCONF for device configuration4. Load Balancers
āļø Traffic Distribution and High Availability
Function: Load balancers distribute incoming traffic across multiple servers to optimize resource usage and ensure availability
Demonstrates error handling in API calls - what happens when configuration fails and how to handle rollback scenarios.
Step-by-Step Interpretation
SUCCESSFUL CONFIGURATION (Steps 1-8): Step 1-4: Script reads current interface configuration ā GET interface Gi1 current state ā Device OS retrieves config ā Returns interface is disabled (enabled: false) Step 5-8: Script updates interface configuration ā PATCH to enable interface and add description ā Device OS applies the changes ā Returns 204 No Content (successful, no body needed) ERROR SCENARIO (Steps 9-13): Step 9-12: Script attempts to configure non-existent interface ā PATCH interface Gi99 (which doesn't exist) ā Device OS checks interface existence ā Interface not found in configuration ā Returns 404 Not Found with error message Step 13: Script handles error gracefully ā Logs the error for troubleshooting ā Continues with next operation (doesn't crash) KEY INSIGHTS: ā Always GET before PATCH to verify resource exists ā Handle HTTP error codes (404, 400, 500) ā Implement try/except in scripts ā Log errors for debugging
5. Reading Sequence Diagrams - Quick Reference
š Sequence Diagram Symbols and Notation
Reference Guide: Understanding all sequence diagram elements
| Symbol/Notation | Meaning | Example |
|---|---|---|
| participant | Actor/system in diagram | participant S as Script |
| ->> | Synchronous call (solid line) | A->>B: Request |
| -->> | Response (dashed line) | B-->>A: Response |
| ->>+ | Call activates participant | A->>+B: Start |
| -->>- | Response deactivates | B-->>-A: End |
| Note over A,B | Add notes/comments | Note over: Phase 1 |
| alt/else/end | Conditional logic | alt success / else fail |
| loop/end | Repeated operations | loop Every 5 seconds |
Common API Patterns in Sequence Diagrams
| Pattern | Description | APIs |
|---|---|---|
| Authentication | Login ā Get token ā Use token | DNA Center, ACI, Custom APIs |
| CRUD Operations | GET ā POST ā PUT ā DELETE | REST APIs, RESTCONF |
| Async Processing | POST ā Get task ID ā Poll status | DNA Center, NSO |
| Error Handling | Request ā Error response ā Retry/Log | All APIs |
| Multi-tier | Client ā API ā Controller ā Device | Meraki, DNA Center |
š Interactive Python Interpreter
- Write Python code in the editor
- Click "ā¶ Run Code" to execute
- Try sample code buttons