Information Technology Grimoire

Version .0.0.1

IT Notes from various projects because I forget, and hopefully they help you too.

Routing Notes

Routing Checks

A common question is “what device is not allowing me to communicate”. Understanding your routes, and the path your traffic takes will help you troubleshoot the right devices. Every OS has a different interface to their routing commands.

route print
netstat -rn | findstr x.x.x
netstat -rn | grep x.x.x
ip route get x.x.x.x
show ip route
show routing route
show route
show route destination x.x.x.x
clish -c "show routing table" | grep x.x.x
traceroute -d x.x.x.x
traceroute x.x.x.x
tcptraceroute somewhere.ext 443

Windows Routes

route DELETE 192.168.9.0 MASK 255.255.255.0 192.168.7.1 -p
route ADD 192.168.9.0 MASK 255.255.255.0 192.168.4.1

Find Routed Interface (Linux)

ip route get 8.8.8.8 | awk '{print $5}'

Find Routed Interface (Powershell)

Cut and paste in powershell:

$IPAddress = 8.8.8.8

$CombinedOutput = @{
    "Interface Name" = (Find-NetRoute -RemoteIPAddress $IPAddress | Select-Object -First 1).InterfaceAlias
    "Interface IPv4" = (Find-NetRoute -RemoteIPAddress $IPAddress | Select-Object -First 1).IPAddress
    "Nexthop Gateway" = (Find-NetRoute -RemoteIPAddress $IPAddress | Select-Object -Skip 1).NextHop
    "DestinationPrefix" = (Find-NetRoute -RemoteIPAddress $IPAddress | Select-Object -Skip 1).DestinationPrefix
}

$CombinedOutput | Format-Table -AutoSize

as a saved script:

if ($args.Length -eq 0) {
    Write-Output "Syntax: .\getroute.ps1 <IPAddress>"
    Write-Output "Example: .\getroute.ps1 8.8.8.8"
    exit
}

$IPAddress = $args[0]

$CombinedOutput = @{
    "Interface Name" = (Find-NetRoute -RemoteIPAddress $IPAddress | Select-Object -First 1).InterfaceAlias
    "Interface IPv4" = (Find-NetRoute -RemoteIPAddress $IPAddress | Select-Object -First 1).IPAddress
    "Nexthop Gateway" = (Find-NetRoute -RemoteIPAddress $IPAddress | Select-Object -Skip 1).NextHop
    "DestinationPrefix" = (Find-NetRoute -RemoteIPAddress $IPAddress | Select-Object -Skip 1).DestinationPrefix
}

$CombinedOutput | Format-Table -AutoSize