- 论坛徽章:
- 13
|
让内网用户直接用80端口访问,让外网用户访问时使用1234端口
用户自定义端口:1234,$wan为外网IP,$lan为内网ip,$mask子网掩码
Iptables –t nat –A PROUTING –d $wan –s !$lan/$mask –p tcp –m tcp –dport 1234 –j DNAT –to-destination $wan:80
Iptables –t nat –A PROUTING –s $wan –d !$lan/$mask –p tcp –m tcp –sport 80 –j DNAT –to-destination $wan:1234
- LAN_IP="local ip address"
- LAN_IP_RANGE="lan/mask"
- LAN_IFACE="lan nic"
- INET_IP="public ip address"
- INET_IFACE="internet nic"
- IPTABLES="/sbin/iptables"
- $IPTABLES -t nat -A PREROUTING -p tcp -s ! $LAN_IP_RANGE -d $INET_IP -i $INET_IFACE --dport 1234 -j DNAT --to-destination $LAN_IP:80
复制代码 |
|