kpnboxapi 0.1.3
Python library for interacting with KPN Box modem/router
License: MIT
Requires Python: >=3.8
Keywords: kpn, modem, router, api, networking, home automation

# KPNBoxAPI

Python library for interacting with KPN Box modem/router. Tested with Box 14.

## Installation

```bash
pip install kpnboxapi
```

## Quick Start

```python
from kpnboxapi import KPNBoxAPI

# Connect and authenticate
api = KPNBoxAPI(host="192.168.2.254")
api.login(username="admin", password="your_password")

# Get all connected devices
devices = api.get_devices()

# Get only currently connected devices
active_devices = api.get_devices(filter='active')

# Get previously connected devices
inactive_devices = api.get_devices(filter='inactive')
```

more examples in the `examples/` folder and down below in this readme.

```bash
python examples/basic_usage.py
```

## API Reference

### KPNBoxAPI(host="192.168.2.254", timeout=30)

Initialize the API client.

**Parameters:**
- `host` (str): KPN Box IP address (default: "192.168.2.254")
- `timeout` (int): Request timeout in seconds (default: 30)

### login(username="admin", password="")

Authenticate with the KPN Box.

**Parameters:**
- `username` (str): Username (default: "admin")
- `password` (str): Password

**Returns:** `bool` - True if successful

### get_connected_devices()

Get raw device data from the KPN Box API.

**Returns:** Raw device data (dict/list)

### get_devices(filter='all')

Get filtered list of connected devices.

**Parameters:**
- `filter` (str): Filter devices - `'all'`, `'active'`, or `'inactive'` (default: 'all')

**Returns:** List of device dictionaries

**Device Fields:**
- `Name`: Device name
- `PhysAddress`: MAC address
- `IPAddress`: IP address
- `Active`: Connection status (True/False)
- `DeviceType`: Device type (e.g., "Computer", "Mobile", "TV")
- `Layer2Interface`: Network interface (e.g., "ETH0", "ETH3")
- `FirstSeen`: First connection timestamp
- `LastConnection`: Last connection timestamp
- `VendorClassID`: DHCP vendor class
- `ClientID`: DHCP client ID
- `UniqueID`: Device unique identifier
- `Index`: Device index
- `Names`: List of device names from different sources
- `DeviceTypes`: List of device types from different sources
- `IPv4Address`: List of IPv4 addresses
- `IPv6Address`: List of IPv6 addresses
- `Security`: Security scoring information
- `Priority`: Traffic priority settings
- And many other fields from the KPN Box API

### delete_device(mac_address)

Delete/destroy a device from the router's device list.

**Parameters:**
- `mac_address` (str): MAC address of the device to delete (e.g., "96:16:1A:D6:0F:30")

**Returns:** `bool` - True if device was successfully deleted

**Note:** 
- This only removes the device from the router's memory
- If the device reconnects, it will reappear in the device list
- Typically used for inactive devices to clean up the device list
- Device schedules and restrictions are also removed

### cleanup_inactive_devices(days_inactive=30)

Clean up devices that haven't been seen for a specified number of days.

**Parameters:**
- `days_inactive` (int): Number of days of inactivity before considering device for cleanup (default: 30)

**Returns:** Dictionary with cleanup results

**Cleanup Result Fields:**
- `candidates`: List of devices eligible for cleanup
- `deleted`: List of devices that were deleted
- `failed`: List of devices that failed to delete
- `total_candidates`: Number of devices eligible for cleanup
- `total_deleted`: Number of devices successfully deleted
- `total_failed`: Number of devices that failed to delete

**Note:** This function will automatically delete devices, use with caution.

### list_inactive_devices(days_inactive=7)

List devices that haven't been seen for a specified number of days.

**Parameters:**
- `days_inactive` (int): Number of days of inactivity to filter by (default: 7)

**Returns:** List of inactive device dictionaries with additional fields

**Additional Fields:**
- `days_since_seen`: Number of days since last connection
- All standard device management fields

### get_device_info()

Get information about the KPN Box modem itself.

**Returns:** Dictionary with modem information

**Modem Info Fields:**
- `Manufacturer`: Modem manufacturer (e.g., "Arcadyan")
- `ModelName`: Modem model (e.g., "BoxV14")
- `SerialNumber`: Modem serial number
- `SoftwareVersion`: Current firmware version
- `HardwareVersion`: Hardware version
- `UpTime`: Modem uptime in seconds
- `ExternalIPAddress`: External/WAN IP address
- `DeviceStatus`: Current device status
- `BaseMAC`: Modem base MAC address
- `Country`: Country code
- `NumberOfReboots`: Total number of reboots
- `ManufacturerOUI`: Manufacturer OUI
- `Description`: Device description
- `ProductClass`: Product class
- `RescueVersion`: Rescue firmware version
- `FirstUseDate`: First use timestamp
- And other modem details

### get_public_ipv6()

Get the public IPv6 address of the KPN Box modem.

**Returns:** `str` - Public IPv6 address

### get_wifi_networks()

Get WiFi network configurations (regular networks, not guest).

**Returns:** List of WiFi network dictionaries

**WiFi Network Fields:**
- `VAPName`: Virtual Access Point name (e.g., "vap2g0priv", "vap5g0priv")
- `SSID`: Network name
- `VAPStatus`: Status ("Up" or "Down")
- `BSSID`: MAC address of the access point
- `MACAddress`: MAC address
- `Security`: Security configuration including:
  - `ModeEnabled`: Security mode (e.g., "WPA2-Personal")
  - `KeyPassPhrase`: WiFi password
  - `ModesSupported`: List of supported security modes
- `MaxAssociatedDevices`: Maximum number of devices
- `AssociatedDeviceNumberOfEntries`: Current connected devices
- `EssIdentifier`: Network identifier ("Primary", "Secondary")
- `BridgeInterface`: Network bridge interface
- `WPS`: WPS configuration
- `IEEE80211r`: Fast roaming configuration
- `MACFiltering`: MAC filtering settings
- And many other WiFi configuration fields

### get_guest_wifi_networks()

Get guest WiFi network configurations.

**Returns:** List of guest WiFi network dictionaries with same structure as `get_wifi_networks()` but for guest networks

### get_all_wifi_networks()

Get all WiFi networks (both regular and guest).

**Returns:** Dictionary with keys:
- `'regular'`: List of regular WiFi networks
- `'guest'`: List of guest WiFi networks

### set_wifi_config(ssid_2g=None, ssid_5g=None, password_2g=None, password_5g=None, security_mode_2g=None, security_mode_5g=None, mfp_config_2g="", mfp_config_5g="")

Configure WiFi network settings (SSID, password, security).

**Parameters:**
- `ssid_2g` (str): 2.4GHz network name/SSID
- `ssid_5g` (str): 5GHz network name/SSID
- `password_2g` (str): 2.4GHz network password
- `password_5g` (str): 5GHz network password
- `security_mode_2g` (str): 2.4GHz security mode (e.g., "WPA2-Personal", "WPA3-Personal")
- `security_mode_5g` (str): 5GHz security mode (e.g., "WPA2-Personal", "WPA3-Personal")
- `mfp_config_2g` (str): 2.4GHz Management Frame Protection - "", "Optioneel", "Benodigd", "Uit" (default: "")
- `mfp_config_5g` (str): 5GHz Management Frame Protection - "", "Optioneel", "Benodigd", "Uit" (default: "")

**Returns:** `bool` - True if successful

### set_wifi_visibility(visible_2g=None, visible_5g=None)

Enable or disable WiFi network visibility (SSID advertisement).

**Parameters:**
- `visible_2g` (bool): Whether 2.4GHz network should be visible (broadcast SSID)
- `visible_5g` (bool): Whether 5GHz network should be visible (broadcast SSID)

**Returns:** `bool` - True if successful

### set_wps_enabled(enabled_2g=None, enabled_5g=None)

Enable or disable WPS (WiFi Protected Setup) for WiFi networks.

**Parameters:**
- `enabled_2g` (bool): Whether to enable WPS on 2.4GHz network
- `enabled_5g` (bool): Whether to enable WPS on 5GHz network

**Returns:** Dictionary with 'band_2g' and 'band_5g' keys indicating success for each band

### get_dhcp_server(pool_id="default")

Get DHCP server configuration for a specific pool.

**Parameters:**
- `pool_id` (str): DHCP pool ID - `"default"` or `"guest"` (default: "default")

**Returns:** Dictionary with DHCP server configuration

**DHCP Server Fields:**
- `PoolID`: DHCP pool identifier ("default" or "guest")
- `Enable`: Whether DHCP server is enabled (True/False)
- `Status`: Current status ("Enabled" or "Disabled")
- `MinAddress`: Start of IP address range (e.g., "192.168.2.100")
- `MaxAddress`: End of IP address range (e.g., "192.168.2.200")
- `SubnetMask`: Network subnet mask (e.g., "255.255.255.0")
- `IPRouters`: Gateway IP address (e.g., "192.168.2.254")
- `LeaseTime`: DHCP lease duration in seconds (e.g., 14400 = 4 hours)
- `DNSServers`: DNS server addresses (comma-separated)
- `DomainName`: Network domain name (e.g., "home")
- `Interface`: Network interface (e.g., "bridge", "brguest")
- `LeaseNumberOfEntries`: Number of active DHCP leases
- `StaticAddressNumberOfEntries`: Number of static IP assignments
- `Allocation`: DHCP allocation method ("dynamic")
- `ARPProtect`: ARP protection enabled
- And many other DHCP configuration fields

### get_default_dhcp_server()

Get default network DHCP server configuration.

**Returns:** Dictionary with default DHCP server configuration

### get_guest_dhcp_server()

Get guest network DHCP server configuration.

**Returns:** Dictionary with guest DHCP server configuration

### get_all_dhcp_servers()

Get all DHCP server configurations (both default and guest).

**Returns:** Dictionary with keys:
- `'default'`: Default network DHCP configuration
- `'guest'`: Guest network DHCP configuration

### set_dhcp_server_config(network="lan", gateway_ip=None, subnet_mask=None, dhcp_enabled=None, dhcp_min_ip=None, dhcp_max_ip=None, lease_time_seconds=None, dhcp_authoritative=None, dns_servers=None)

Configure DHCP server settings for a network.

**Parameters:**
- `network` (str): Network to configure ("lan" for home, "guest" for guest network)
- `gateway_ip` (str): Gateway IP address (e.g., "192.168.2.254")
- `subnet_mask` (int): Subnet prefix length (e.g., 24 for /24)
- `dhcp_enabled` (bool): Enable/disable DHCP server
- `dhcp_min_ip` (str): Minimum IP address for DHCP pool (e.g., "192.168.2.100")
- `dhcp_max_ip` (str): Maximum IP address for DHCP pool (e.g., "192.168.2.200")
- `lease_time_seconds` (int): DHCP lease time in seconds (e.g., 14400 for 4 hours)
- `dhcp_authoritative` (bool): Whether DHCP server is authoritative
- `dns_servers` (str): DNS servers as comma-separated string (e.g., "9.9.9.9,149.112.112.112")

**Returns:** `bool` - True if configuration was successful

### set_home_dhcp_config(gateway_ip=None, subnet_mask=None, dhcp_enabled=None, dhcp_min_ip=None, dhcp_max_ip=None, lease_time_seconds=None, dhcp_authoritative=None, dns_servers=None)

Configure DHCP server settings for the home network.

**Parameters:**
- `gateway_ip` (str): Gateway IP address (default: "192.168.2.254")
- `subnet_mask` (int): Subnet prefix length (default: 24)
- `dhcp_enabled` (bool): Enable/disable DHCP server (default: True)
- `dhcp_min_ip` (str): Minimum IP for DHCP pool (default: "192.168.2.100")
- `dhcp_max_ip` (str): Maximum IP for DHCP pool (default: "192.168.2.200")
- `lease_time_seconds` (int): DHCP lease time in seconds (default: 14400)
- `dhcp_authoritative` (bool): Whether DHCP server is authoritative (default: True)
- `dns_servers` (str): DNS servers comma-separated (default: "9.9.9.9,149.112.112.112")

**Returns:** `bool` - True if configuration was successful

### set_guest_dhcp_config(gateway_ip=None, subnet_mask=None, dhcp_enabled=None, dhcp_min_ip=None, dhcp_max_ip=None, lease_time_seconds=None, dns_servers=None)

Configure DHCP server settings for the guest network.

**Parameters:**
- `gateway_ip` (str): Gateway IP address (default: "192.168.3.254")
- `subnet_mask` (int): Subnet prefix length (default: 24)
- `dhcp_enabled` (bool): Enable/disable DHCP server (default: True)
- `dhcp_min_ip` (str): Minimum IP for DHCP pool (default: "192.168.3.1")
- `dhcp_max_ip` (str): Maximum IP for DHCP pool (default: "192.168.3.32")
- `lease_time_seconds` (int): DHCP lease time in seconds (default: 14400)
- `dns_servers` (str): DNS servers comma-separated (default: "9.9.9.9,149.112.112.112")

**Returns:** `bool` - True if configuration was successful

### configure_network_isolation(home_subnet="192.168.2.0/24", guest_subnet="192.168.3.0/24", home_dhcp_range=("192.168.2.100", "192.168.2.200"), guest_dhcp_range=("192.168.3.1", "192.168.3.32"), dns_servers="9.9.9.9,149.112.112.112")

Configure network isolation between home and guest networks.

**Parameters:**
- `home_subnet` (str): Home network subnet in CIDR notation
- `guest_subnet` (str): Guest network subnet in CIDR notation
- `home_dhcp_range` (tuple): Tuple of (min_ip, max_ip) for home DHCP
- `guest_dhcp_range` (tuple): Tuple of (min_ip, max_ip) for guest DHCP
- `dns_servers` (str): DNS servers for both networks

**Returns:** Dictionary with configuration results for home and guest networks

**Note:** This sets up proper IP ranges and DHCP pools to keep networks separated.

### get_dhcp_leases(pool_id="default")

Get DHCP leases for a specific pool.

**Parameters:**
- `pool_id` (str): DHCP pool ID - `"default"` or `"guest"` (default: "default")

**Returns:** List of DHCP lease dictionaries

**DHCP Lease Fields:**
- `PoolID`: DHCP pool identifier ("default" or "guest")
- `ClientID`: DHCP client identifier
- `IPAddress`: Assigned IP address (e.g., "192.168.2.117")
- `MACAddress`: Device MAC address
- `FriendlyName`: Device name/hostname (e.g., "Studio", "iPhone")
- `Active`: Whether lease is currently active (True/False)
- `Reserved`: Whether IP is reserved for this device (True/False)
- `LeaseTime`: Total lease duration in seconds
- `LeaseTimeRemaining`: Remaining lease time in seconds (-1 = permanent)
- `Gateway`: Gateway configuration
- `Flags`: DHCP flags and options
- `TransactionID`: DHCP transaction identifier
- Various DHCP protocol fields

### get_default_dhcp_leases()

Get DHCP leases for the default network.

**Returns:** List of DHCP lease dictionaries for default network

### get_guest_dhcp_leases()

Get DHCP leases for the guest network.

**Returns:** List of DHCP lease dictionaries for guest network

### get_all_dhcp_leases()

Get all DHCP leases (both default and guest networks).

**Returns:** Dictionary with keys:
- `'default'`: List of default network DHCP leases
- `'guest'`: List of guest network DHCP leases

### get_active_dhcp_leases(pool_id="default")

Get only active DHCP leases for a specific pool.

**Parameters:**
- `pool_id` (str): DHCP pool ID - `"default"` or `"guest"` (default: "default")

**Returns:** List of active DHCP lease dictionaries

### get_dyndns_hosts()

Get Dynamic DNS host configurations.

**Returns:** List of DynDNS host dictionaries

**DynDNS Host Fields:**
- `service`: DynDNS provider service (e.g., "No-IP", "DynDNS")
- `hostname`: Dynamic DNS hostname (e.g., "example.ddns.net")
- `username`: DynDNS account username
- `password`: DynDNS account password
- `last_update`: Last update timestamp (ISO format, e.g., "2025-06-03T23:58:30Z")
- `status`: Current status (e.g., "UPDATED", "ERROR", "PENDING")
- `enable`: Whether DynDNS is enabled (True/False)

### add_dyndns_host(service, username, hostname, password)

Add a new Dynamic DNS host configuration.

**Parameters:**
- `service` (str): DynDNS provider service (e.g., "dyndns", "noip", "freedns")
- `username` (str): DynDNS account username
- `hostname` (str): Dynamic DNS hostname (e.g., "yourdomain.ddns.net")
- `password` (str): DynDNS account password

**Returns:** `bool` - True if host was successfully added

### delete_dyndns_host(hostname)

Delete a Dynamic DNS host configuration.

**Parameters:**
- `hostname` (str): Dynamic DNS hostname to delete (e.g., "yourdomain.ddns.net")

**Returns:** `bool` - True if host was successfully deleted

### update_dyndns_host(hostname, service=None, username=None, password=None)

Update an existing Dynamic DNS host configuration.

**Parameters:**
- `hostname` (str): Dynamic DNS hostname to update (e.g., "yourdomain.ddns.net")
- `service` (str): New DynDNS provider service (if changing)
- `username` (str): New DynDNS account username (if changing)
- `password` (str): New DynDNS account password (if changing)

**Returns:** `bool` - True if host was successfully updated

**Note:** This method deletes the existing host and adds it back with new configuration.

### get_dyndns_status(hostname=None)

Get Dynamic DNS status for a specific hostname or all hosts.

**Parameters:**
- `hostname` (str): Specific hostname to check (optional, returns all if not specified)

**Returns:** Dictionary with DynDNS status information or single host if hostname specified

**Status Fields (when hostname=None):**
- `total_hosts`: Total number of configured hosts
- `hosts`: List of all host configurations
- `active_hosts`: List of enabled hosts only
- `last_updated`: Most recent update timestamp

### manage_dyndns_service(action, hostname, service=None, username=None, password=None)

Comprehensive DynDNS management method.

**Parameters:**
- `action` (str): Action to perform ("add", "delete", "update")
- `hostname` (str): Dynamic DNS hostname
- `service` (str): DynDNS provider service (required for add)
- `username` (str): DynDNS account username (required for add)
- `password` (str): DynDNS account password (required for add)

**Returns:** `bool` - True if action was successful

### get_network_stats(interface="ETH0")

Get network device statistics for a specific interface.

**Parameters:**
- `interface` (str): Interface name - `"ETH0"`, `"ETH1"`, `"ETH2"`, `"ETH3"`, `"eth4"`, or `"ppp_vdata"` (default: "ETH0")
  - ETH0-ETH3: Individual Ethernet ports
  - eth4: Total WAN statistics (all WAN traffic combined)
  - ppp_vdata: PPP connection statistics

**Returns:** Dictionary with network statistics

**Network Statistics Fields:**
- `Interface`: Interface name (e.g., "ETH0", "eth4", "ppp_vdata")
- `RxPackets`: Received packets count
- `TxPackets`: Transmitted packets count
- `RxBytes`: Received bytes count
- `TxBytes`: Transmitted bytes count
- `RxErrors`: Received errors count
- `TxErrors`: Transmitted errors count
- `RxDropped`: Received dropped packets count
- `TxDropped`: Transmitted dropped packets count
- `Multicast`: Multicast packets count
- `Collisions`: Network collisions count
- `RxLengthErrors`: Received length errors
- `RxOverErrors`: Received overflow errors
- `RxCrcErrors`: Received CRC errors
- `RxFrameErrors`: Received frame errors
- `RxFifoErrors`: Received FIFO errors
- `RxMissedErrors`: Received missed errors
- `TxAbortedErrors`: Transmitted aborted errors
- `TxCarrierErrors`: Transmitted carrier errors
- `TxFifoErrors`: Transmitted FIFO errors
- `TxHeartbeatErrors`: Transmitted heartbeat errors
- `TxWindowErrors`: Transmitted window errors

### get_all_network_stats()

Get network device statistics for all interfaces (ETH0-ETH3, WAN total, PPP).

**Returns:** Dictionary with keys for all interfaces containing their respective statistics

### get_wan_total_stats()

Get total WAN network statistics (all WAN traffic combined).

**Returns:** Dictionary with total WAN network statistics

### get_ppp_stats()

Get PPP connection network statistics.

**Returns:** Dictionary with PPP connection network statistics

### format_bytes(bytes_count)

Helper method to format byte counts in human-readable format.

**Parameters:**
- `bytes_count` (int): Number of bytes

**Returns:** `str` - Formatted string (e.g., "1.2 GB", "45.6 MB")

### get_port_forwarding(origin="webui")

Get firewall port forwarding rules.

**Parameters:**
- `origin` (str): Rule origin filter - `"webui"`, `"upnp"`, or other origin (default: "webui")

**Returns:** List of port forwarding rule dictionaries

**Port Forwarding Rule Fields:**
- `Id`: Rule identifier (e.g., "webui_pi")
- `Origin`: Rule origin (e.g., "webui", "upnp")
- `Description`: Human-readable description (e.g., "pi", "HTTP")
- `Status`: Current status ("Enabled" or "Disabled")
- `Enable`: Whether rule is enabled (True/False)
- `SourceInterface`: Source interface (e.g., "data")
- `Protocol`: Protocol numbers (6=TCP, 17=UDP, comma-separated)
- `ExternalPort`: External port number (e.g., "1339", "8080")
- `InternalPort`: Internal port number
- `DestinationIPAddress`: Target internal IP address
- `DestinationMACAddress`: Target MAC address (if specified)
- `LeaseDuration`: Rule lease duration in seconds
- `HairpinNAT`: Whether hairpin NAT is enabled
- `SymmetricSNAT`: Whether symmetric SNAT is enabled
- `UPnPV1Compat`: Whether UPnP v1 compatibility is enabled

### get_all_port_forwarding()

Get all port forwarding rules from different origins.

**Returns:** Dictionary with keys for different origins containing their respective rules

### get_active_port_forwarding(origin="webui")

Get only enabled port forwarding rules.

**Parameters:**
- `origin` (str): Rule origin filter - `"webui"`, `"upnp"`, or other origin (default: "webui")

**Returns:** List of enabled port forwarding rule dictionaries

### format_protocol(protocol_str)

Helper method to format protocol numbers into readable names.

**Parameters:**
- `protocol_str` (str): Protocol string (e.g., "6,17" or "6")

**Returns:** `str` - Formatted protocol string (e.g., "TCP,UDP" or "TCP")

### get_ipv6_pinholes()

Get IPv6 pinhole (port forwarding) rules.

**Returns:** List of IPv6 pinhole rule dictionaries

**IPv6 Pinhole Rule Fields:**
- `Id`: Rule identifier (e.g., "webui_1")
- `Origin`: Rule origin (e.g., "webui", "upnp")
- `Description`: Human-readable description (e.g., "FTP")
- `Status`: Current status ("Enabled" or "Disabled")
- `Enable`: Whether rule is enabled (True/False)
- `SourceInterface`: Source interface (e.g., "data")
- `Protocol`: Protocol numbers (6=TCP, 17=UDP, comma-separated)
- `IPVersion`: IP version (6 for IPv6)
- `SourcePort`: Source port filter (if specified)
- `DestinationPort`: Destination port or port range (e.g., "20-21", "80")
- `SourcePrefix`: Source IP prefix filter (if specified)
- `DestinationIPAddress`: Target IPv6 address
- `DestinationMACAddress`: Target MAC address (if specified)

### get_active_ipv6_pinholes()

Get only enabled IPv6 pinhole rules.

**Returns:** List of enabled IPv6 pinhole rule dictionaries

### get_all_firewall_rules()

Get all firewall rules (both IPv4 port forwarding and IPv6 pinholes).

**Returns:** Dictionary with keys:
- `'port_forwarding'`: IPv4 port forwarding rules organized by origin
- `'ipv6_pinholes'`: IPv6 pinhole rules

### get_wan_status()

Get WAN connection status and information.

**Returns:** Dictionary with WAN connection information

**WAN Status Fields:**
- `LinkType`: Connection link type (e.g., "ethernet")
- `LinkState`: Physical link state (e.g., "up", "down")
- `MACAddress`: WAN interface MAC address
- `Protocol`: Connection protocol (e.g., "ppp")
- `ConnectionState`: Connection state (e.g., "Connected", "Disconnected")
- `LastConnectionError`: Last connection error (if any)
- `IPAddress`: Current public IPv4 address
- `RemoteGateway`: ISP gateway IP address
- `DNSServers`: DNS server addresses (comma-separated)
- `IPv6Address`: Current public IPv6 address
- `IPv6DelegatedPrefix`: IPv6 prefix delegated by ISP

### get_ppp_info()

Get detailed PPP connection information.

**Returns:** Dictionary with PPP connection details

**PPP Info Fields:**
- `Interface`: PPP interface name (e.g., "ppp_vdata")
- `Username`: PPP authentication username
- `Password`: PPP authentication password
- `ConnectionStatus`: Current connection status
- `LastConnectionError`: Last connection error code
- `MaxMRUSize`: Maximum Receive Unit size
- `PPPoESessionID`: PPPoE session identifier
- `PPPoEACName`: PPPoE Access Concentrator name
- `PPPoEServiceName`: PPPoE service name
- `RemoteIPAddress`: Remote PPP endpoint IP
- `LocalIPAddress`: Local PPP endpoint IP
- `LastChangeTime`: Time since last status change
- `LastChange`: Last change timestamp
- `DNSServers`: DNS servers from PPP negotiation
- `TransportType`: Transport protocol (e.g., "PPPoE")
- `LCPEcho`: LCP echo interval
- `LCPEchoRetry`: LCP echo retry count
- `IPCPEnable`: Whether IPCP is enabled
- `IPv6CPEnable`: Whether IPv6CP is enabled
- `IPv6CPLocalInterfaceIdentifier`: Local IPv6 interface ID
- `IPv6CPRemoteInterfaceIdentifier`: Remote IPv6 interface ID
- `ConnectionTrigger`: Connection trigger mode
- `IdleDisconnectTime`: Idle disconnect timeout

### get_connection_info()

Get comprehensive internet connection information (WAN + PPP).

**Returns:** Dictionary with keys:
- `'wan_status'`: WAN connection status
- `'ppp_info'`: Detailed PPP connection information

### is_connected()

Check if the internet connection is active.

**Returns:** `bool` - True if connected to the internet, False otherwise

### get_wwan_status()

Get WWAN (mobile internet backup) interface status and configuration.

**Returns:** Dictionary with WWAN interface information

**WWAN Status Fields:**
- `Name`: Interface name ("wwan")
- `Enable`: Whether WWAN interface is enabled
- `Status`: Current status (True/False)
- `Flags`: Interface flags
- `Alias`: Interface alias (e.g., "cpe-wwan")
- `APN`: Access Point Name (e.g., "basicinternet")
- `PINCode`: SIM PIN code (if configured)
- `Username`: Authentication username
- `Password`: Authentication password
- `AuthenticationMethod`: Auth method (e.g., "chap")
- `DNSServers`: DNS servers for mobile connection
- `IPRouter`: Gateway IP address
- `LocalIPAddress`: Assigned local IP address
- `ConnectionStatus`: Connection status (e.g., "NotPresent", "Connected")
- `ConnectionError`: Last connection error
- `ConnectionErrorSource`: Source of connection error
- `AutoConnection`: Whether auto-connection is enabled
- `SignalStrength`: Signal strength (0-100)
- `Technology`: Mobile technology (e.g., "4G", "5G", "none")
- `Manufacturer`: Modem manufacturer
- `Model`: Modem model
- `IMEI`: Device IMEI number
- `PinType`: PIN type required
- `PinRetryCount`: Remaining PIN retry attempts
- `PukRetryCount`: Remaining PUK retry attempts
- `IMSI`: SIM IMSI number
- `ICCID`: SIM card identifier
- `MSISDN`: Mobile number
- `LastChange`: Last change timestamp
- `LastChangeTime`: Last change time
- `TechnologyPreference`: Preferred technology
- `NATEnabled`: Whether NAT is enabled
- `MTU`: Maximum Transmission Unit
- `IPv4Forwarding`: Whether IPv4 forwarding is enabled
- `IPv6Disable`: Whether IPv6 is disabled
- And other network interface settings

### get_lan_ipv4_config()

Get LAN IPv4 network configuration.

**Returns:** Dictionary with LAN IPv4 configuration

**LAN IPv4 Config Fields:**
- `Address`: LAN IPv4 address (e.g., "192.168.2.254")
- `PrefixLength`: Network prefix length (e.g., 24)
- `DHCPEnable`: Whether DHCP server is enabled
- `DHCPAuthoritative`: Whether DHCP server is authoritative
- `DHCPMinAddress`: DHCP range start address
- `DHCPMaxAddress`: DHCP range end address
- `LeaseTime`: DHCP lease time in seconds
- `DNSServers`: DNS server addresses (comma-separated)
- `NTPServers`: NTP server addresses (comma-separated)
- `DomainSearchList`: Domain search list
- `Enable`: Whether IPv4 is enabled
- `AllowPublic`: Whether public access is allowed
- `NATEnable`: Whether NAT is enabled

### get_lan_ipv6_config()

Get LAN IPv6 network configuration.

**Returns:** Dictionary with LAN IPv6 configuration

**LAN IPv6 Config Fields:**
- `Address`: LAN IPv6 address
- `PrefixLength`: Network prefix length
- `Intf`: Interface name (e.g., "data")
- `SubnetOffset`: Subnet offset value
- `DHCPEnable`: Whether DHCPv6 server is enabled
- `DHCPIAPDEnable`: Whether DHCPv6 Identity Association for Prefix Delegation is enabled
- `DHCPIANAEnable`: Whether DHCPv6 Identity Association for Non-temporary Addresses is enabled
- `DNSServers`: IPv6 DNS server addresses (comma-separated)
- `NTPServers`: IPv6 NTP server addresses (comma-separated)
- `Enable`: Whether IPv6 is enabled

### get_lan_config()

Get comprehensive LAN network configuration (both IPv4 and IPv6).

**Returns:** Dictionary with keys:
- `'ipv4'`: LAN IPv4 configuration
- `'ipv6'`: LAN IPv6 configuration

### get_dns_servers()

Get DNS server configuration for both IPv4 and IPv6.

**Returns:** Dictionary with keys:
- `'ipv4'`: IPv4 DNS servers (comma-separated)
- `'ipv6'`: IPv6 DNS servers (comma-separated)

### set_ipv6_enabled(enabled=True, prefix_mode="DHCPv6")

Enable or disable IPv6 globally on the router.

**Parameters:**
- `enabled` (bool): Whether to enable IPv6 (default: True)
- `prefix_mode` (str): IPv6 prefix mode when enabling - "DHCPv6" or "RA" (default: "DHCPv6")

**Returns:** `bool` - True if successful

### set_ipv6_prefix_delegation(mode="off")

Configure IPv6 prefix delegation settings.

**Parameters:**
- `mode` (str): IPv6 prefix delegation mode - "off", "on", or "on_with_dhcpv6" (default: "off")

**Returns:** `bool` - True if all configuration calls were successful

**IPv6 Prefix Delegation Modes:**
- `"off"`: Disable prefix delegation, use DHCPv6 mode for single address
- `"on"`: Enable prefix delegation with RA (Router Advertisement) mode
- `"on_with_dhcpv6"`: Enable prefix delegation with RA + DHCPv6 mode

**Note:** This function makes multiple API calls (2-4 depending on mode) to configure both LAN and guest network prefix delegation.

### disable_ipv6_prefix_delegation()

Disable IPv6 prefix delegation.

**Returns:** `bool` - True if successful

**Note:** Convenience method that calls `set_ipv6_prefix_delegation("off")`.

### enable_ipv6_prefix_delegation(use_dhcpv6=False)

Enable IPv6 prefix delegation.

**Parameters:**
- `use_dhcpv6` (bool): Whether to enable with DHCPv6 mode (True) or RA mode (False, default)

**Returns:** `bool` - True if successful

**Note:** 
- When `use_dhcpv6=False`: Uses RA (Router Advertisement) mode only
- When `use_dhcpv6=True`: Uses RA + DHCPv6 combined mode

### configure_ipv6_prefix_delegation(enabled=True, use_dhcpv6=False, prefix_length=56)

Comprehensive IPv6 prefix delegation configuration.

**Parameters:**
- `enabled` (bool): Whether to enable prefix delegation (default: True)
- `use_dhcpv6` (bool): Whether to enable DHCPv6 mode when enabling (default: False = RA mode)
- `prefix_length` (int): Prefix length for delegation (default: 56)

**Returns:** `bool` - True if successful

**Note:** This is the most comprehensive method that combines all prefix delegation options into a single call.

### set_lan_ipv4_config(network="lan", dns_servers=None, address=None, dhcp_enabled=None, dhcp_min_address=None, dhcp_max_address=None, prefix_length=None)

Configure LAN IPv4 settings including DNS servers and DHCP.

**Parameters:**
- `network` (str): Network to configure - "lan" (default) or "guest"
- `dns_servers` (str): DNS servers (comma-separated, e.g., "9.9.9.9,149.112.112.112")
- `address` (str): LAN gateway IP address (e.g., "192.168.2.254")
- `dhcp_enabled` (bool): Whether to enable DHCP server
- `dhcp_min_address` (str): DHCP range start (e.g., "192.168.2.100")
- `dhcp_max_address` (str): DHCP range end (e.g., "192.168.2.200")
- `prefix_length` (int): Network prefix length (e.g., 24 for /24)

**Returns:** `bool` - True if successful

### set_lan_ipv6_config(network="lan", dns_servers=None)

Configure LAN IPv6 DNS servers.

**Parameters:**
- `network` (str): Network to configure - "lan" (default) or "guest"
- `dns_servers` (str): IPv6 DNS servers (comma-separated, e.g., "2620:fe::fe,2620:fe::9")

**Returns:** `bool` - True if successful

### set_dns_servers(ipv4_dns=None, ipv6_dns=None, network="lan")

Set DNS servers for both IPv4 and IPv6 on specified network.

**Parameters:**
- `ipv4_dns` (str): IPv4 DNS servers (comma-separated, e.g., "9.9.9.9,149.112.112.112")
- `ipv6_dns` (str): IPv6 DNS servers (comma-separated, e.g., "2620:fe::fe,2620:fe::9")
- `network` (str): Network to configure - "lan" (default) or "guest"

**Returns:** Dictionary with 'ipv4' and 'ipv6' keys indicating success for each

### get_netmaster_config()

Get NetMaster network configuration settings.

**Returns:** Dictionary with network master configuration

**NetMaster Config Fields:**
- `EnableInterfaces`: Whether interfaces are enabled
- `EnableIPv6`: Whether IPv6 is globally enabled
- `IPv6PrefixMode`: IPv6 prefix mode (e.g., "RA" for Router Advertisement)
- `DisablePhysicalInterfaces`: Whether physical interfaces are disabled
- `WANMode`: WAN connection mode (e.g., "Ethernet_PPP")

### get_dhcpv6_client_status()

Get DHCPv6 client status (router acting as DHCPv6 client to ISP).

**Returns:** Dictionary with DHCPv6 client information

**DHCPv6 Client Status Fields:**
- `Name`: Interface name (e.g., "dhcpv6_pdata")
- `Enable`: Whether DHCPv6 client is enabled
- `Status`: Current status (True/False)
- `Flags`: Status flags (e.g., "dhcpv6 enabled up")
- `Alias`: Interface alias
- `DHCPStatus`: DHCP status (e.g., "Bound", "Requesting")
- `LastConnectionError`: Last connection error (e.g., "RenewTimeout")
- `Uptime`: Client uptime in seconds
- `DSCPMark`: DSCP marking value
- `DUID`: DHCP Unique Identifier
- `RequestAddresses`: Whether requesting individual addresses
- `RequestPrefixes`: Whether requesting prefix delegation
- `RapidCommit`: Whether using rapid commit
- `IAID`: Identity Association Identifier
- `SuggestedT1`: Suggested renewal time (-1 = not set)
- `SuggestedT2`: Suggested rebind time (-1 = not set)
- `SupportedOptions`: Supported DHCP options
- `RequestedOptions`: Requested DHCP options (comma-separated)
- `Reason`: Status reason
- `Renew`: Whether currently renewing
- `ResetOnPhysDownTimeout`: Reset timeout on physical down
- `CheckAuthentication`: Whether checking authentication
- `AuthenticationInfo`: Authentication information
- `RetryOnFailedAuth`: Whether retrying on failed authentication

### get_firewall_level()

Get the current firewall security level.

**Returns:** `str` - Firewall level (e.g., "Low", "Medium", "High")

### get_ping_response_settings(source_interface="data")

Get ping response settings for a specific interface.

**Parameters:**
- `source_interface` (str): Source interface to check (default: "data")

**Returns:** Dictionary with ping response settings

**Ping Response Settings Fields:**
- `enableIPv4`: Whether responding to IPv4 pings is enabled
- `enableIPv6`: Whether responding to IPv6 pings is enabled

### get_firewall_config()

Get comprehensive firewall configuration.

**Returns:** Dictionary with firewall configuration

**Firewall Config Fields:**
- `Status`: Firewall status ("Enabled" or "Disabled")
- `AdvancedLevel`: Advanced firewall level for IPv4
- `AdvancedIPv6Level`: Advanced firewall level for IPv6
- `ExcludedOriginsPCP`: Excluded origins for PCP
- `UpnpPortForwardingStatus`: Current UPnP port forwarding status
- `UpnpPortForwardingEnable`: Whether UPnP port forwarding is enabled
- `ChainNumberOfEntries`: Number of firewall chain entries
- `ProtocolForwardingNumberOfEntries`: Number of protocol forwarding entries
- `PinholeNumberOfEntries`: Number of pinhole entries
- `ListNumberOfEntries`: Number of list entries

### get_dmz_config()

Get DMZ (Demilitarized Zone) configuration.

**Returns:** Dictionary with DMZ configuration

**DMZ Config Fields:**
- `Origin`: Configuration origin (e.g., "webui")
- `SourceInterface`: Source interface (e.g., "data")
- `DestinationIPAddress`: IP address of DMZ host
- `SourcePrefix`: Source prefix filter
- `Status`: DMZ status ("Enabled" or "Disabled")
- `Enable`: Whether DMZ is enabled

### set_upnp_enabled(enabled=True)

Enable or disable UPnP port forwarding.

**Parameters:**
- `enabled` (bool): Whether to enable UPnP port forwarding (default: True)

**Returns:** `bool` - True if successful

**Note:**
When enabled, devices on the network can automatically open ports through UPnP protocol. This can be convenient but may reduce security.

### set_dmz_host(destination_ip, enabled=True, dmz_id="webui", source_interface="data")

Set up a DMZ (Demilitarized Zone) host.

**Parameters:**
- `destination_ip` (str): IP address of the DMZ host (e.g., "192.168.2.108")
- `enabled` (bool): Whether to enable the DMZ (default: True)
- `dmz_id` (str): DMZ configuration ID (default: "webui")
- `source_interface` (str): Source interface (default: "data")

**Returns:** `str` - DMZ ID if successful, empty string if failed

**Note:**
DMZ forwards all incoming traffic to the specified host. This effectively puts the host outside the firewall protection. Only one DMZ host can be active at a time.

### delete_dmz_host(dmz_id="webui")

Delete DMZ host configuration.

**Parameters:**
- `dmz_id` (str): DMZ configuration ID to delete (default: "webui")

**Returns:** `bool` - True if successful

### set_ping_response(source_interface="data", enable_ipv4=True, enable_ipv6=True)

Configure ping response settings for router.

**Parameters:**
- `source_interface` (str): Source interface to configure (default: "data")
- `enable_ipv4` (bool): Whether to respond to IPv4 pings (default: True)
- `enable_ipv6` (bool): Whether to respond to IPv6 pings (default: True)

**Returns:** `bool` - True if successful

**Note:** When disabled, the router will not respond to ping requests from the internet, improving security but making connectivity testing harder.

### enable_ping_response(ipv4=True, ipv6=True)

Enable ping response for IPv4 and/or IPv6.

**Parameters:**
- `ipv4` (bool): Enable IPv4 ping response (default: True)
- `ipv6` (bool): Enable IPv6 ping response (default: True)

**Returns:** `bool` - True if successful

**Note:** Convenience method that calls `set_ping_response(enable_ipv4=ipv4, enable_ipv6=ipv6)`.

### disable_ping_response()

Disable ping response for both IPv4 and IPv6.

**Returns:** `bool` - True if successful

**Note:** Convenience method that calls `set_ping_response(enable_ipv4=False, enable_ipv6=False)`.

### set_firewall_level(level="Medium", ipv6_level=None)

Set firewall security level for IPv4 and optionally IPv6.

**Parameters:**
- `level` (str): Firewall level - "Low", "Medium", "High", or "Custom" (default: "Medium")
- `ipv6_level` (str): IPv6 firewall level - if None, uses same as IPv4 level (default: None)

**Returns:** Dictionary with 'ipv4' and 'ipv6' keys indicating success for each

**Firewall Levels:**
- `Low`: Minimal protection, allows most traffic
- `Medium`: Balanced protection and functionality
- `High`: Maximum protection, blocks more traffic
- `Custom`: Allows custom firewall rules (required for custom rule methods)

### set_firewall_level_ipv4(level="Medium")

Set IPv4 firewall security level.

**Parameters:**
- `level` (str): Firewall level - "Low", "Medium", "High", or "Custom" (default: "Medium")

**Returns:** `bool` - True if successful

### set_firewall_level_ipv6(level="Medium")

Set IPv6 firewall security level.

**Parameters:**
- `level` (str): Firewall level - "Low", "Medium", "High", or "Custom" (default: "Medium")

**Returns:** `bool` - True if successful

### enable_custom_firewall()

Enable custom firewall mode for both IPv4 and IPv6.

**Returns:** Dictionary with 'ipv4' and 'ipv6' keys indicating success for each

**Note:** This is required before using custom firewall rule methods. Sets both IPv4 and IPv6 firewall levels to "Custom".

### get_custom_firewall_rules()

Get all custom firewall rules.

**Returns:** List of custom firewall rule dictionaries

**Custom Rule Fields:**
- `Id`: Rule identifier (e.g., "ssh", "http", "myshit")
- `Target`: Rule action ("Accept" or "Drop")
- `Status`: Rule status ("Enabled" or "Disabled")
- `Class`: Rule class (e.g., "Forward")
- `IPVersion`: IP version (4 or 6)
- `Protocol`: Protocol number (6=TCP, 17=UDP, comma-separated)
- `DestinationPort`: Destination port or port range (e.g., "22", "6660-6669")
- `SourcePort`: Source port filter
- `DestinationPrefix`: Destination IP prefix filter
- `SourcePrefix`: Source IP prefix filter
- `DestinationMACAddress`: Destination MAC address filter
- `SourceMACAddress`: Source MAC address filter
- `TargetChain`: Target firewall chain
- `Description`: Rule description
- `Enable`: Whether rule is enabled

**Note:** This method requires Custom firewall level to be enabled.

### add_custom_firewall_rul