1

This is the scenario

I have configured a web-server in MUX. Now I want to access that web-server from Internet. Ubuntu box has two interfaces, One is connected to WAN (Public IP) and another one is connected to MUX (Private IP). MUX has no option to insert default gateway.

iptables -t nat -A PREROUTING -p tcp -i eth0 -d 103.x.x.x --dport 8001 -j DNAT --to-destination 192.168.1.2:8080
iptables -A FORWARD -p tcp -d 192.168.1.2 --dport 8080 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT

It does not work.

HopelessN00b
  • 53,795
  • 33
  • 135
  • 209
user141610
  • 5
  • 1
  • 7

1 Answers1

3

What you want is this:

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 8081 -m conntrack -ctstate NEW -j DNAT --to 192.168.1.2:8080
iptables -t nat -A PREROUTING -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A POSTROUTING -t nat -j MASQUERADE

hope this helps.

Valentin Bajrami
  • 4,045
  • 1
  • 18
  • 26