Created
November 18, 2014 15:21
-
-
Save cfeduke/9ea5e170e6766e53ca68 to your computer and use it in GitHub Desktop.
Generate command for forwarding Windows local port to OSX host for accessing OSX hosted web application as localhost
This file contains 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
#!/usr/bin/env bash | |
# Prints out the Windows netsh command necessary to port forward on localhost to another | |
# IP address. Especially useful when testing IE11 with APIs like Google Maps that only | |
# permit localhost connectivity but the actual server is on your local OSX host machine | |
# usage: | |
# netsh [interface] [port] | |
# | |
# e.g., | |
# netsh en0 8080 | pbcopy | |
set -o nounset | |
set -o errexit | |
IFACE=${1:-en0} | |
PORT=${2:-3000} | |
IP=$(/sbin/ifconfig $IFACE | grep "inet\b" | cut -d " " -f2) | |
if [ -z "$IP" ]; then | |
echo unable to determine IP address from interface $IFACE | |
exit 1 | |
fi | |
echo netsh interface portproxy add v4tov4 listenport=$PORT listenaddress=127.0.0.1 connectport=$PORT connectaddress=$IP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment