Hello, I want to forward only 3 ports from my first server to the second server with the iptable command. But the rest of the ports remain normal. And this command does not affect the performance of socat negatively, because I have a forwarded port with socat and when I run the iptable command, this port is disconnected.
For a better explanation, I have a v2ray configuration on my first server on port 2086, on which tls is active, apparently when I forward a port from the second server to the first server on which tls is active with socat, it does not work because of tls mismatch . For this reason, I want to forward only 3 ports from the first server to the second server with the iptable command without any problem with the forwarded port with socat.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
New accounts only. By submitting your email you agree to our Privacy Policy.
Heya @driftinglightcyanurchin,
You can use something like the following to achieve what you want
Use iptables to forward the specific ports:
For instance, if you want to forward ports 3000, 3001, and 3002 from your first server (IP:
1.1.1.1
) to the second server (IP:2.2.2.2
), you would use these commands:Save the iptables rules:
For Ubuntu/Debian:
Please replace
1.1.1.1
and2.2.2.2
with the actual IP addresses of your first and second servers, and3000
,3001
, and3002
with the ports you actually want to forward.Note: This will not affect other ports, so it should not interfere with your existing socat configuration. If the socat forwarding stops working after running these commands, it’s likely due to a conflict on the specific ports you’re trying to forward. Make sure the ports forwarded by iptables and socat are not overlapping.
Remember, any time you manipulate iptables or networking configurations, there is a risk of disrupting network connections. It is highly recommended that you understand the impact of these commands and have a plan to reverse changes if necessary.