How Routers Acquire Public IP Addresses: DHCP, PPPoE and ISP Assignment Protocols Explained for Developers


7 views

When your router boots up and connects to your ISP, it undergoes an IP address acquisition process that differs significantly from local DHCP assignments. The mechanism depends on your ISP's infrastructure:

// Simplified state machine of router IP acquisition
enum ConnectionState {
  PHYSICAL_LINK_UP,
  AUTHENTICATING,
  REQUESTING_IP,
  CONFIGURATION_RECEIVED,
  ROUTING_ESTABLISHED
}

1. DHCP (Dynamic Host Configuration Protocol):

# Example DHCP client config (common in cable modems)
interface eth0 {
  send host-name "client-router-123";
  send dhcp-client-identifier "AA:BB:CC:DD:EE:FF";
  request subnet-mask, broadcast-address, routers;
}

2. PPPoE (Point-to-Point Protocol over Ethernet):

// Typical PPPoE configuration snippet
pppoe {
  auth protocol pap;
  auth username "isp_username@provider.com";
  auth password "securepassword123";
  mtu 1492;
  mru 1492;
}

ISPs implement several safeguards to prevent IP conflicts:

  • DHCP lease tracking with MAC address binding
  • Centralized IP address management (IPAM) systems
  • ARP probing before address assignment
  • Sticky IP assignments based on modem certificates

Use these commands to diagnose ISP-side IP assignment:

# Show current WAN interface status (Linux routers)
ip -4 addr show dev eth0

# PPPoE debug output
pppoe-discovery -I eth0 -D -A

# DHCP client debug mode
dhclient -d -v eth0

Static IP assignment (common in business plans):

// Example static WAN configuration
interface GigabitEthernet0/0/0
 ip address 203.0.113.42 255.255.255.248
 ip nat outside
 negotiation auto

Dynamic IP assignment (typical residential):

# Cable modem config extract
dhcp {
  option vendor-encapsulated-options 0x0102;
  option tftp-server-name "69.28.157.36";
  send vendor-class-identifier "CISCO_EPC3925";
}

When your router connects to your ISP, it obtains its public-facing IP address through one of these protocols:

// Typical DHCP client configuration on a router
interface GigabitEthernet0/0/0
 dhcp client enable
 dhcp client request option 43
!

Most business-class ISPs use DHCP (Dynamic Host Configuration Protocol) for IP assignment:

  • Router sends DHCPDISCOVER broadcast
  • ISP's DHCP server responds with DHCPOFFER
  • Router accepts with DHCPREQUEST
  • Server confirms with DHCPACK
# Wireshark filter for DHCP traffic
dhcp || bootp

Many home ISPs (especially DSL providers) use PPPoE:

// Sample PPPoE configuration (Cisco IOS)
interface Virtual-Template1
 ppp authentication chap callin
 ppp chap hostname customer_12345
 ppp chap password 0 secret_password
!

ISPs implement several safeguards:

// DHCP server conflict detection (ISC DHCPd)
ping-check true;
ping-timeout 2;

Typical lease duration examples:

  • Residential DHCP: 24-48 hours
  • Business static IP: Infinite lease
  • PPPoE: Often tied to session duration
# Checking lease time on Linux router
dhclient -v eth0

Here's how major vendors handle WAN IP assignment:

// Ubiquiti EdgeRouter (DHCP)
set interfaces ethernet eth0 address dhcp

// MikroTik (PPPoE)
/interface pppoe-client
add name=pppoe-out1 interface=ether1 user=user123 password=pass123