#!/bin/sh
[ -z "$HOST" ] && HOST=localhost
IP="`ping -c1 $HOST | egrep -o '([0-9]{1,3}.){3}([0-9]{1,3})' | head -n1`"
# 清除前次设置的 NAPT
iptables -t nat --flush
# 将本机80映射到之前 $HOST 指定的服务器 80 上
/sbin/iptables -t nat -I POSTROUTING -j MASQUERADE
/sbin/iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination "${IP}:80"
[ -z "$HOST" ] && HOST=localhost
IP="`ping -c1 $HOST | egrep -o '([0-9]{1,3}.){3}([0-9]{1,3})' | head -n1`"
# 清除前次设置的 NAPT
iptables -t nat --flush
# 将本机80映射到之前 $HOST 指定的服务器 80 上
/sbin/iptables -t nat -I POSTROUTING -j MASQUERADE
/sbin/iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination "${IP}:80"