Report this

What is the reason for this report?

how to set up forwarding

Posted on June 22, 2020

i need port forwading i have installed linux debian 9 and vpn server pptp i need forward port 8270 to 192.168.254.2:8270 how to ?

i try with this butnot working

sysctl net.ipv4.ip_forward = 1 iptables -A PREROUTING -t nat -i eth0 -p tcp –dport 8270 -j DNAT –to-destination 192.168.245.1:8270 iptables -A FORWARD -p tcp -d 192.168.245.2 –dport 8270 -j ACEPTA iptables -A POSTROUTING -t nat -s 192.168.245.2 -o eth0 -j MASQUERADE

intente de esta otra manera:

sysctl net.ipv4.ip_forward = 1 iptables -t nat -A PREROUTING -p tcp –dport 8270 -j DNAT –to-destination 192.168.245.2:8270 iptables -t nat -A POSTROUTING -j MASQUERADE



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.

Heya,

Just came across this answer and decided to write some general guidelines for anyone who comes across this in the future despite the old question.

To troubleshoot your problem, let’s start with some basic checks:

  1. Ensure that the iptables rules are correctly set up. The destination in the DNAT rule should match the forwarding rule.
  2. Ensure that you have enabled IP forwarding in your sysctl configuration.
  3. Check that there are no firewall rules or security group settings that would block port 8270.

Here’s a corrected example of how you should set your iptables:

  1. sysctl net.ipv4.ip_forward=1
  2. iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 8270 -j DNAT --to-destination 192.168.254.2:8270
  3. iptables -A FORWARD -p tcp -d 192.168.254.2 --dport 8270 -j ACCEPT
  4. iptables -t nat -A POSTROUTING -s 192.168.254.2 -o eth0 -j MASQUERADE

Remember to replace eth0 with the right interfaces in your case.

Also, ensure to make these changes permanent, as they will be lost after a reboot if not saved. You can use iptables-persistent to make the changes permanent.

Here’s a link to the related DigitalOcean documentation

Hope that this helps!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.