#!/bin/bash
# dnat
#
# 內網服務: 192.168.49.85:80
# 網關: 192.168.49.65
# 請求主機: 172.16.0.129
# 請求過程:
# 172.16.0.129 –> 192.168.49.65 –to-destination 192.168.49.85:8080
iptables -t nat -F
iptables -F
iptables -t nat -A PREROUTING -d 192.168.49.65 -p tcp --dport 80 -j DNAT --to-destination 192.168.49.85:8080
iptables-save > /etc/sysconfig/iptables.dnat
iptables-restore < /etc/sysconfig/iptables.dnat