LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-24-2019, 11:16 AM   #1
lmbalcao
LQ Newbie
 
Registered: Apr 2019
Posts: 1

Rep: Reputation: Disabled
Port Forwarding


Hello, i have the following scenario:

192.168.1.1 - Router
192.168.1.2 - VPN Router
192.168.1.83 Client

192.168.1.1 «eth0» 192.168.1.2 «eth0, tun0» 192.168.1.83

My Router provides internet access, VPN Router serves all the home Machines with it's VPN IP.

Everything is working properly, with the exception that i can't forward a specific port (51413) to my client machine.

This is my actual configuration:

sudo iptables -L

Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT udp -- anywhere anywhere udp dpt:51413
ACCEPT tcp -- anywhere anywhere tcp dpt:51413
ACCEPT udp -- anywhere anywhere state RELATED,ESTABLISHED udp dpt:51413

Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT all -- anywhere anywhere

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere /* vpn */
ACCEPT icmp -- anywhere anywhere /* icmp */
ACCEPT all -- anywhere 192.168.1.0/24 /* lan */
ACCEPT udp -- anywhere anywhere udp dpt:1198 /* openvpn */
ACCEPT tcp -- anywhere anywhere tcp spt:ssh /* ssh */
ACCEPT udp -- anywhere anywhere udp dpt:ntp /* ntp */
ACCEPT udp -- anywhere anywhere udp dpt:domain /* dns */
ACCEPT tcp -- anywhere anywhere tcp dpt:domain /* dns */
DROP all -- anywhere anywhere
ACCEPT udp -- anywhere anywhere udp spt:51413

How can i solve this issue? Can someone point me in the right direction?

Been searching and couldn't find a solution.

Thanks in advance
 
Old 04-26-2019, 08:21 PM   #2
thinknix
Member
 
Registered: Nov 2008
Distribution: Lots!
Posts: 178

Rep: Reputation: 58
You need to use the nat table's prerouting chain to port forward. Port forwarding across two devices (router and VPN) can be more complicated as you might need nat rules on both servers - it depends on how the VPN router is setup. But in general you can port forward from the outside router to your client with rules like this on the router:

Code:
iptables -t nat -A PREROUTING -d $EXT_IP -p tcp --dport 51413 -j DNAT --to-destination 192.168.1.83:51413
iptables -t nat -A PREROUTING -d $EXT_IP -p udp --dport 51413 -j DNAT --to-destination 192.168.1.83:51413
Where $EXT_IP is your external, public IP address on the router. You can view the existing rules with 'iptables -t nat -L'.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] IPtables : ssh port forwarding one port to another port issue routers Linux - Networking 7 08-07-2018 08:41 AM
Redirec port in device eth0 to port+ip in device wlan0 ( port forwarding on hostpd wireless network) MattFly Linux - Networking 2 08-28-2016 07:21 PM
Shorewall: port forwarding problem, port is closed even after forwarding Synt4x_3rr0r Linux - Networking 2 12-13-2009 04:36 PM
IPCHAINS port forwarding and IPTABLES port forwarding ediestajr Linux - Networking 26 01-14-2007 07:35 PM
port forwarding and packet forwarding syrtsardo Linux - Newbie 2 07-03-2003 10:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration