At one time I had this working, but the machine rebooted and lost the iptables setup. Now I can't get it to work. I've also tried reading a number of related articles and they're not *quite* my situation.
I have the following computers:
REMOTE SERVER: 172.1.2.20 (via VPN)
LOCAL PC: 10.10.25.20, 10.10.25.21 running Ubuntu
MY PC: 10.10.25.200
REMOTE PC: 10.20.3.20
====================================
The machines on the local network (10.10.25.0/8) can see the 172.1.2.20 machine over a VPN. But our remote co-workers at 10.20.3.20 cannot.
So I took the linux machine at 10.10.25.20 and added another NIC. I did some IP table mumbo jumbo once and I was able to redirect all traffic coming into the 2nd NIC card (eth1) to 172.1.2.20 via the 1st NIC card (eth0). The server rebooted after a power outage and now I can't replicate the setup. Here's what I've scribbled down previously.
# note eth0 IP = 10.10.25.20
# note eth1 IP = 10.10.25.21
export eth0IP=`ifconfig eth0 | grep "inet addr" | cut -d: -f2 | cut -dB -f1`
export eth1IP=`ifconfig eth1 | grep "inet addr" | cut -d: -f2 | cut -dB -f1`
iptables -F
iptables -t nat -F
iptables -t nat -A PREROUTING -i eth1 -j DNAT --to 172.1.2.20
iptables -A FORWARD -p tcp -i eth0 -d 172.1.2.20 -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to ${eth1IP}
iptables -t nat -A POSTROUTING -o eth1 -j SNAT --to ${eth0IP}
What am I doing wrong? I wanted to be able to connect to 10.10.25.21 and have all traffic forwarded to 172.1.2.20 via 10.10.25.20.
Really, all I wanted to do was to do port-forwarding on port 1521 to 172.1.2.20:1521 - but that became too cumbersome and nothing I tried worked...
I've looked at these articles and tried to adapt them to my own to no avail:
http://www.debian-administration.org/articles/73
http://wiki.kartbuilding.net/index.php/Iptables_forward <-- this was the closest to my problem, but didn't work.
http://www.linuxquestions.org/questi...arding-574868/
http://www.linuxquestions.org/questi...fusing-551254/
http://www.linuxquestions.org/questi...-ports-184343/
https://www.linuxquestions.org/quest...ptables-66389/ <- this guy asked a similar question with no response.
===================
I've tried to setup a small webserver on my PC, and reroute traffic from one NIC to the other to my PC. In the past, my webserver responded, but the return path was not properly defined so the traffic never made it back. I had to add the two POSTROUTING lines above.
Today, I'm switching eth1 for eth0 in various combinations, but to no avail... Can somebody help me figure this out?
Thank you sooo much in advance.