🌐 IP Services & Protocol Ports

DHCP, DNS, NAT, SNMP, NTP & Common Port Numbers

🌐 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.

graph TD A["IP Services"] --> B["DHCP"] A --> C["DNS"] A --> D["NAT"] A --> E["SNMP"] A --> F["NTP"] B --> B1["Address Assignment"] C --> C1["Name Resolution"] D --> D1["IP Translation"] E --> E1["Monitoring"] F --> F1["Time Sync"] 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 style E fill:#ab47bc,stroke:#6a1b9a,stroke-width:2px,color:#fff style F fill:#26a69a,stroke:#00695c,stroke-width:2px,color:#fff

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

sequenceDiagram participant C as Client participant S as DHCP Server Note over C,S: DORA Process C->>S: 1. DISCOVER Note right of C: Broadcast: Who has IP for me? S->>C: 2. OFFER Note right of S: Here is 192.168.1.100 C->>S: 3. REQUEST Note right of C: I accept 192.168.1.100 S->>C: 4. ACKNOWLEDGE Note right of S: Confirmed - IP is yours

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 DHCP

2. 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

sequenceDiagram participant C as Client participant R as Recursive Resolver participant Root as Root Server participant TLD as .com TLD Server participant Auth as Authoritative NS C->>R: Query: www.cisco.com? R->>Root: Where is .com? Root->>R: Ask .com TLD R->>TLD: Where is cisco.com? TLD->>R: Ask cisco.com NS R->>Auth: IP for www? Auth->>R: 72.163.4.185 R->>C: Answer: 72.163.4.185

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.com

3. 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

graph LR PC1["PC1
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

graph LR NMS["NMS
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

graph TD Stratum0["Stratum 0
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.

graph LR A["Port Numbers
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

šŸ’” How to use:
  • Write Python code in the editor
  • Click "ā–¶ Run Code" to execute
  • Try sample code buttons
graph LR A["Internet"] --> B["Firewall"] B --> C["Router"] C --> D["Core Switch"] D --> E["Access Switch"] E --> F["End Devices"] C --> G["Load Balancer"] G --> H["Servers"] style A fill:#e3f2fd,stroke:#1976d2,stroke-width:2px style B fill:#ffebee,stroke:#c62828,stroke-width:2px style C fill:#667eea,stroke:#764ba2,stroke-width:3px,color:#fff style D fill:#66bb6a,stroke:#2e7d32,stroke-width:2px,color:#fff style E fill:#42a5f5,stroke:#1976d2,stroke-width:2px,color:#fff style G fill:#ffa726,stroke:#e65100,stroke-width:2px,color:#fff

1. Switches

šŸ”€ Layer 2 Frame Forwarding

Function: Switches forward frames based on MAC addresses within a local network segment

šŸ“– Diagram Explanation:
This sequence diagram shows a two-phase process:
  1. Phase 1 (Lines 1-6): User logs in with username/password, receives a JWT token
  2. Phase 2 (Lines 7-12): User makes API requests using the token instead of password
sequenceDiagram participant U as User participant C as Client App participant A as Auth API participant D as Device API participant DB as Database U->>C: Enter credentials C->>A: POST /auth/login Note right of C: {username, password} A->>DB: Verify credentials DB-->>A: User valid A-->>C: 200 OK + Token Note right of A: {token: abc123} C->>C: Store token U->>C: Request device list C->>D: GET /devices + Token Note right of C: Authorization: Bearer abc123 D->>D: Validate token D->>DB: Query devices DB-->>D: Device records D-->>C: 200 OK + Data Note right of D: [{id:1, name:R1}] C->>U: Display devices

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

šŸ“– Diagram Explanation:
This shows cloud-managed networking where API calls flow through the Meraki Dashboard to cloud controllers, which then push configs to physical devices.
sequenceDiagram participant S as Script participant M as Meraki API participant C as Cloud participant AP as Access Point S->>M: GET /organizations Note right of S: Header: API-Key M-->>S: 200 OK Note right of M: [{id:123, name:Corp}] S->>M: POST /orgs/123/networks Note right of S: {name:Branch-5, type:wireless} M->>C: Provision network C-->>M: Network created M-->>S: 201 Created Note right of M: {id:net-456} S->>M: PUT /networks/net-456/ssids/0 Note right of S: {name:Corp-WiFi, enabled:true} M->>C: Update SSID C->>AP: Push config AP-->>C: Applied C-->>M: Success M-->>S: 200 OK

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

šŸ“– Diagram Explanation:
Shows how DNA Center discovers devices, assigns them to sites, and deploys configuration templates.
sequenceDiagram participant S as Script participant D as DNA Center participant DB as Database participant R as Router S->>D: POST /auth/token Note right of S: Credentials D->>DB: Validate user DB-->>D: Authenticated D-->>S: 200 OK Note right of D: Token: xyz789 S->>D: POST /network-device/ip Note right of S: IP: 10.1.1.1 D->>R: CDP/LLDP Discovery R-->>D: Device info D->>DB: Store device D-->>S: 202 Accepted Note right of D: taskId: task-123 S->>D: GET /task/task-123 D-->>S: 200 OK Note right of D: Device added S->>D: POST /template-deployment Note right of S: deviceId + templateId D->>R: Deploy via NETCONF R-->>D: Config applied D-->>S: 200 OK

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 configuration

4. Load Balancers

āš–ļø Traffic Distribution and High Availability

Function: Load balancers distribute incoming traffic across multiple servers to optimize resource usage and ensure availability

šŸ“– Diagram Explanation:
Demonstrates error handling in API calls - what happens when configuration fails and how to handle rollback scenarios.
sequenceDiagram participant S as Script participant R as Router RESTCONF participant D as Device OS Note over S,D: SUCCESS SCENARIO S->>R: GET /interfaces/Gi1 R->>D: Read config D-->>R: Interface data R-->>S: 200 OK Note right of R: {enabled: false} S->>R: PATCH /interfaces/Gi1 Note right of S: {enabled: true, desc: WAN} R->>D: Apply config D-->>R: Applied R-->>S: 204 No Content Note over S,D: ERROR SCENARIO S->>R: PATCH /interfaces/Gi99 Note right of S: {enabled: true} R->>D: Check interface D-->>R: Not found R-->>S: 404 Not Found Note right of R: Interface Gi99 missing S->>S: Log error

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

šŸ’” How to use:
  • Write Python code in the editor
  • Click "ā–¶ Run Code" to execute
  • Try sample code buttons
šŸ“ Python Code Editor
⚔ Console Output
Ready to execute Python code...