problem:
I have an application sitting on a host (let's call it host1) that sends TLS-encrypted TCP packets to another host's port 5015 (let's call it host2). Due to network restrictions, the host1 must have all inbound and outbound traffic enter and leave through either 80 or 443. I have no access to host2.
approach:
My thinking is that I could create an iptables rule on host1 that will route/redirect/forward the 5015 traffic out of 443 and have to have it arrive at host2:5015. The problem I'm having is creating the right rule. Here's what I have so far:
TCP_TRAFFIC_PORT=5015 PROXY_PORT=443 _apply_outbound_rules() { # Forward outgoing packets through the proxy port sudo iptables -t nat \ -I OUTPUT 1 \ -p tcp --destination-port $TCP_TRAFFIC_PORT \ -j DNAT --to-destination :$PROXY_PORT # Send packets to host2:5015 port (this is likely the rule to fix) sudo iptables -t nat \ -I POSTROUTING 1 \ -p tcp --destination-port $PROXY_PORT \ -j SNAT --to-source :$TCP_TRAFFIC_PORT } apply_outbound_rules Does anyone know how to do this? It seems like a common thing to run into, but I'm having trouble with it.
host1, thanks for pointing that out. I'll update the question to state thatecho 1 > /proc/sys/net/ipv4/ip_forward? That will enable routing in the kernel.host1. Do you know how to modify the rules to change the packet's destination port to 5015 after it leaves 443?host1) to a hosted ELK stack on Logz.io (host2) under the network restrictions (which are a bureaucratic hassle to get altered). And of course, the module will only be deployed if all legal contracts and parameters were agreed and signed off on beforehand by all parties.