Created
May 11, 2015 21:45
-
-
Save jlongman/e3c1842e1a778d997f56 to your computer and use it in GitHub Desktop.
Netgraph node splicing - add a Tee node
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/sh | |
| # builds an ng_tee with an ng_iface tied in where the LEFT and LEFT_HOOK were so tcpdump can observe | |
| LEFT=$1 | |
| LEFT_HOOK=$2 | |
| ### ngctl show $LEFT:$LEFT_HOOK | |
| # take RIGHT, RIGHT_HOOK from above line | |
| RIGHT=`ngctl show $LEFT:$LEFT_HOOK | grep -Eo 'ID: [0-9a-e]+' | grep -Eo '[0-9a-e]+'` | |
| RIGHT_HOOK=`ngctl show $LEFT:$LEFT_HOOK | grep $LEFT_HOOK | awk '{print $1}'` | |
| ngctl rmhook $LEFT: $LEFT_HOOK | |
| ngctl mkpeer $LEFT: tee $LEFT_HOOK left | |
| ngctl mkpeer $LEFT:$LEFT_HOOK iface right2left inet | |
| ngctl connect $LEFT:$LEFT_HOOK '['$RIGHT']': right $RIGHT_HOOK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment