Hello everybody!
I've got a situation where I need to setup something that does the following:
Host: 1.2.3.4 Port 1234
Remote Host 5.6.7.8 Port 5678
If I connect to host 1.2.3.4:1234 it forwards things to 5.6.7.8:5678
1.2.3.4:1234 should accept any connection on there and just foward it on...
I've seen some examples with IPTables doing this...these seem to be for the software/connections that originate on that host to be forwarded, but not something that comes in via net, ie:
9.0.1.2.3:1234 - > 1.2.3.4:1234 - > 5.6.7.8:5678
Basically this is just "proxy" in other words to the host...but this would be TCP or UDP traffic that comes in...
A VPN via say OpenVPN to this host and forward everything out is one solution, but for this case its not an option... I really only need to forward ONE SPECIFIC HOST:PORT to ONE SPECIFIC REMOTE HOST:PORT. I don't want to forward out all traffic via the VPN to this host, and then on... I've got other things that are VPN'd out to places...
I really just want to be able to point the software that I need to do this at this 1.2.3.4:5678 and it forwards everything to 5.6.7.8:5678 TCP/UDP
I am NOT an iptables guru.... I probably could do this with some Cisco IOS stuff if I had it at the location, but this is not a colo right now...
Any one have other suggestions or solutions???
An example of what I've seen in various similar forms on various sites:
https://www.debuntu.org/how-to-redirecting-network-traffic-to-a-new-ip-using-iptables/
# echo "1" > /proc/sys/net/ipv4/ip_forward
or
# sysctl net.ipv4.ip_forward=1
Then, we will add a rule telling to forward the traffic on port 1111 to ip 2.2.2.2 on port 1111:
# iptables -t nat -A PREROUTING -p tcp --dport 1111 -j DNAT --to-destination 2.2.2.2:1111
and finally, we ask IPtables to masquerade:
iptables -t nat -A POSTROUTING -j MASQUERADE
Optionally, you could only redirect the traffic from a specific source/network with, for a host only:
# iptables -t nat -A PREROUTING -s 192.168.1.1 -p tcp --dport 1111 -j DNAT --to-destination 2.2.2.2:1111
or for a whole network
# iptables -t nat -A PREROUTING -s 192.168.1.0/24 -p tcp --dport 1111 -j DNAT --to-destination 2.2.2.2:1111
Rick
... Ding Dong the Witch is DEAD! I Made America Great Again! President Trump! --- GoldED+/LNX 1.1.5-b20161221
# Origin: Vina's Talos Moon Base Alpha (1:135/377)
* Origin: LiveWire BBS - Synchronet - LiveWireBBS.com (1:2320/100)