I have three machines: A local PC (public IP 1.2.3.4), an Ubuntu 10 Server box in a datacentre (eth0 on 5.6.7.8 public IP), and a third-party server hosting a website outside of my network (let's say Slashdot on 216.34.181.45).
- Using iptables, how do I access Slashdot from my local machine using 5.6.7.8:8080 ?
- Would this process differ if Slashdot was on the same LAN as my Ubuntu box?
- Can this be done with just NAT PREROUTING/POSTROUTING, or do I need MASQUERADE?
Best Answer
Enable the IP forwarding on Ubuntu:
and add the following rules:
No.
You should use MASQUERADE if the Ubuntu has a dynamic IP:
You can also use SSH local port forwarding in this case by executing the below command on the Ubuntu:
There's still another (or more) way to do this. Take a look at the rinetd:
The configuration is very simple. Add the belows line into
/etc/rinetd.conf
:and start:
It will do everything for you.