Skip to content

Instantly share code, notes, and snippets.

@ursuad
Forked from mowings/masq.sh
Created October 31, 2017 16:29
Show Gist options
  • Save ursuad/33f719eb171bce0a973e4fe6111b7f8c to your computer and use it in GitHub Desktop.
Save ursuad/33f719eb171bce0a973e4fe6111b7f8c to your computer and use it in GitHub Desktop.

Revisions

  1. @mowings mowings revised this gist Jan 4, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion masq.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    #!/bin/bash
    interfaces=( $(ifconfig | grep 'utun.*mtu 1500' | cut -d ':' -f 1))
    interfaces=( $(netstat -in | egrep 'utun\d .*\d+\.\d+\.\d+\.\d+' | cut -d ' ' -f 1) )
    rulefile="rules.tmp"
    echo "" > $rulefile
    sudo pfctl -a com.apple/tun -F nat
  2. @mowings mowings created this gist Jan 4, 2017.
    11 changes: 11 additions & 0 deletions masq.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    #!/bin/bash
    interfaces=( $(ifconfig | grep 'utun.*mtu 1500' | cut -d ':' -f 1))
    rulefile="rules.tmp"
    echo "" > $rulefile
    sudo pfctl -a com.apple/tun -F nat
    for i in "${interfaces[@]}"
    do
    RULE="nat on ${i} proto {tcp, udp, icmp} from 192.168.64.0/24 to any -> ${i}"
    echo $RULE >> $rulefile
    done
    sudo pfctl -a com.apple/tun -f $rulefile