IOS Exec Commands

Synopsis

netapi ios exec <COMMAND> [OPTIONS]

Description

Execute show and privileged exec commands on IOS/IOS-XE devices.

Options

Option Description Default

--host

Target device IP/hostname

$IOS_HOST

--format

Output format: raw, json, table

raw

--timeout

Command timeout in seconds

30

Examples

802.1X/MAB Troubleshooting

# List all access sessions
netapi ios exec "show access-session"

# Specific interface detail
netapi ios exec "show access-session interface GigabitEthernet4/0/11 detail"

# Check authentication method status
netapi ios exec "show authentication sessions"
Sample Output: access-session detail
Interface:    GigabitEthernet4/0/11
MAC Address:  00:50:C2:39:F0:F7
IPv4 Address: 10.238.1.28
User-Name:    00-50-C2-39-F0-F7
Status:       Authorized
Domain:       DATA
Oper host mode: multi-auth
Oper control dir: both
Session timeout: N/A
Common Session ID: 0AC190E400000E1B8A5D3C7F
Acct Session ID: 0x00000FA2
Handle: 0x7C00001D
Current Policy: POLICY_Gi4/0/11

Server Policies:
  Vlan Group:  Vlan: 751
  ACS ACL: xACSACLx-IP-TEST_Medical_Temp_Monitor-697290bb

Method status list:
  Method           State
  dot1x            Stopped
  mab              Authc Success

RADIUS Server Status

netapi ios exec "show radius servers"
netapi ios exec "show aaa servers"

Interface Operations

# Interface status
netapi ios exec "show interfaces status"

# Specific interface
netapi ios exec "show interfaces GigabitEthernet4/0/11"

# Running config for interface
netapi ios exec "show run interface GigabitEthernet4/0/11"

MAC Address Table

# Full table
netapi ios exec "show mac address-table"

# By MAC
netapi ios exec "show mac address-table address 00:50:C2:39:F0:F7"

# By interface
netapi ios exec "show mac address-table interface GigabitEthernet4/0/11"

CI/CD Integration

- name: Validate 802.1X sessions
  run: |
    sessions=$(netapi ios exec "show access-session" --format json)
    unauthorized=$(echo "$sessions" | jq '[.[] | select(.status != "Authorized")] | length')
    if [ "$unauthorized" -gt 0 ]; then
      echo "::warning::$unauthorized unauthorized sessions detected"
    fi