Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

iptables & DNAT 2

Status
Not open for further replies.

tobyheywood

IS-IT--Management
Apr 20, 2001
122
0
0
GB
Hi,

I have two machines, box 1 used as a gateway to the Internet and box 2 amongst other things is being used to provide remote video monitoring by way of a webcam or two. In additional ADSL connection with single public IP.

Now on the internal network I can access box 2 no problems, and I can access the internet, thus proving that box 1 is masquerading properly.

I would like to configure it so that, if I try to access box 1 via the internet using port 8080 that it will redirect it to box number 2.

I have added the following to the nat PREROUTING table

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport -j DNAT --to 192.168.0.100

Is the above enough? If it should work, then can someone please advise me on the best way to troubleshoot, as it is not in actual fact working.

If the above isn't enough, I would be greatful if some one could point out what I am doing wrong.

Kind regards

Toby Heywood

 
First:
iptables -A PREROUTING -t nat -i eth0 -p tcp -d [External_IP] --dport 8080 -j DNAT --to-destination 192.168.0.100:8080

Then:
iptables -A FORWARD -p tcp -d 192.168.0.100 --dport 8080 -j ACCEPT


--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
like zeland said,see what chains packets through
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top