Last active
January 8, 2016 12:49
-
-
Save binarytemple/3f60fa19f02835bc5493 to your computer and use it in GitHub Desktop.
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 | |
| ######################################################################## | |
| # Target : OSX | |
| # Description : | |
| # Port forwarding and networking can sometimes be a tricky to set up | |
| # particularly when using vmware fusion. | |
| # This script takes a port as a single argument then attempts to | |
| # connect on each of the local ipv4 interfaces in turn. | |
| # Use 'nc' to check for open port is as it has less overhead than curl. | |
| ######################################################################### | |
| PORT_TO_TEST=${1:?please provide a port number as argument to this script} | |
| INTERFACES_ADDRS=$(ifconfig | \ | |
| sed -n '/inet/{ | |
| /inet6/!{ | |
| s_inet[ ]*\([0-9\.]*\).*_\1_; | |
| s_[^0-9\.]*__g;p; | |
| }; | |
| }') | |
| for IP in ${INTERFACES_ADDRS}; | |
| do nc -v -z -w2 $IP $PORT_TO_TEST | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment