-
-
Save cute/dbac4f2cf07c138a5053ebf749f3a491 to your computer and use it in GitHub Desktop.
Routing all traffic to particular IP address via wifi network interface on MacOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# NOTE: wifi network interface is: en1 | |
wifi_router=192.168.200.1 | |
wifi_address=en1:ec.35.86.4f.00.bc | |
TOADDR=`ifconfig en1 inet | sed -nl 's/\w*inet \([^ ]*\).*/\1/p'` | |
TO=`echo -n ${TOADDR//[[:space:]]}` | |
echo "ADDING ROUTE TO $1 VIA en1 (wi-fi): $TO" | |
route -n add -host $1 $wifi_router -ifp $wifi_address -ifa $TO -static | |
echo "" | |
echo "ROUTE ADDED:" | |
route get $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment