Skip to content

Instantly share code, notes, and snippets.

@thorr18
Created May 6, 2017 04:16
Show Gist options
  • Save thorr18/9c5c88b9590c8794f681e85328d65fdb to your computer and use it in GitHub Desktop.
Save thorr18/9c5c88b9590c8794f681e85328d65fdb to your computer and use it in GitHub Desktop.
OSX route metrics
This is for when there are two routes of the same specificity in the table.
netstat -nrv -f inet
Routing tables
Internet:
Destination Gateway Flags Refs Use Netif Expire
default 192.168.43.1 UGSc 4 102 en0
default 172.17.2.1 UGScI 0 0 en4
127 127.0.0.1 UCS 0 0 lo0
127.0.0.1 127.0.0.1 UH 11 222826 lo0
...et al
What witchcraft is used to always send traffic to the interface you don't want?
@thorr18
Copy link
Author

thorr18 commented May 6, 2017

What does not work is changing various metrics on the route or deleting re-adding routes:
sudo route change 0.0.0.0/0 172.17.2.1 -hopcount=4
Also it does not work to change metrics on the interface:
sudo ifconfig en4 metric 13
What does work is reordering your network services.
View current order:
networksetup -listnetworkserviceorder
Set a new order:
sudo networksetup -ordernetworkservices "Wi-Fi" "MiFi 7730L" "Bluetooth PAN"
Verify the interface being used for default routes has successfully changed!:
route get 8.8.8.8

@thorr18
Copy link
Author

thorr18 commented Oct 31, 2019

sudo networksetup -ordernetworkservices "Thunderbolt Ethernet" "Wi-Fi" "Pixel 2 XL" "USB 10/100/1000 LAN" "USB Ethernet" "Bluetooth PAN" "AirCard 791L" "MiFi 7730L" "FT231X USB UART"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment