Skip to content

Instantly share code, notes, and snippets.

Created Nov 18, 2014
What would you like to do?
Generate command for forwarding Windows local port to OSX host for accessing OSX hosted web application as localhost
#!/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
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
echo netsh interface portproxy add v4tov4 listenport=$PORT listenaddress= connectport=$PORT connectaddress=$IP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment