LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > *BSD
User Name
Password
*BSD This forum is for the discussion of all BSD variants.
FreeBSD, OpenBSD, NetBSD, etc.

Notices


Reply
  Search this Thread
Old 11-15-2017, 02:03 AM   #1
kzl
LQ Newbie
 
Registered: Feb 2017
Distribution: Slackware, FreeBSD, pfSense
Posts: 7

Rep: Reputation: Disabled
Port forwarding in a dual wan setup is not possible from the internet gateway


Hi!

Port forwarding is not working as expected in the following setup. Connection is always timing out.
My provider is detecting the incoming traffic, it seams no issue there.

However, when I try to connect like the following from the TestPC to the Server behind MyRouter
it is working without any problem, port will be forwarded and connection establishes:

Provider_gateway(192.168.3.254)
|
|
|
Switch-------------------TestPC(192.168.3.33)
|
|
MyRouter(192.168.3.24)
|
|
Server(192.168.1.111)

If the connection initiated from the internet -> through a public IP and open port -> to the Provider_gateway,
it is timing out... Why is that?

I've tried to implement the following rule to place load-balancing out of order for the server:
pass in quick on em1 proto tcp from $server route-to $wan_if $wan_gw
--doesn't work.

Here is the complete related configuration:

Code:
int_if = "{ em1 em2 }"
ext_if = "{ em0 em3 }"

lan_if = "em1"
lan_net = "192.168.1.0/24"

lan2_if = "em2"
lan2_net = "192.168.2.0/24"

wan_if = "em0"
wan_gw = "192.168.3.254"

wan2_if = "em3"
wan2_gw = "123.123.123.123"

server = "192.168.1.111"
pc = "192.168.1.23"

set block-policy drop
set loginterface egress
set skip on lo0

block all

pass in quick on em0 proto tcp from any to (em0) port 5000 rdr-to $server port 22
pass out quick on em1 proto tcp from any to $server

match out on $wan_if from $lan_net nat-to ($wan_if)
match out on $wan_if from $lan2_net nat-to ($wan_if)
match out on $wan2_if from $lan_net nat-to ($wan2_if)
match out on $wan2_if from $lan2_net nat-to ($wan2_if)

pass in on $lan_if from $lan_net route-to { ($wan_if $wan_gw) weight 1, ($wan2_if $wan2_gw) weight 15 } round-robin
pass in on $lan2_if from $lan2_net route-to { ($wan_if $wan_gw) weight 1, ($wan2_if $wan2_gw) weight 15 } round-robin

pass out on $ext_if

pass out on $wan_if from $wan2_if route-to ($wan2_if $wan2_gw)
pass out on $wan2_if from $wan_if route-to ($wan_if $wan_gw)

pass in proto tcp from $lan_net to $lan_if
pass in proto udp from $lan_net to $lan_if

pass in proto tcp from $lan2_net to $lan2_if
pass in proto udp from $lan2_net to $lan2_if

pass in on $lan_if from $lan_if:network to $lan2_if:network
pass out on $lan2_if from $lan_if:network to $lan2_if:network

pass in on $lan_if from $pc to $lan_if
Thanks in advance!
 
Old 11-15-2017, 11:13 AM   #2
kzl
LQ Newbie
 
Registered: Feb 2017
Distribution: Slackware, FreeBSD, pfSense
Posts: 7

Original Poster
Rep: Reputation: Disabled
In case somebody needs the solution:

Code:
pass out quick on em1 proto tcp from any to $server
block log on $ext_if all
match in on $wan_if proto tcp from any to 192.168.3.24 port 5000 rdr-to $server port 22
pass in on $wan_if proto tcp from any to $server port 22 reply-to ($wan_if $wan_gw) set prio 7
 
  


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
Network configuration for LAN and WAN - DNS, port forwarding, etc. glupa4e Slackware 1 10-31-2016 07:25 AM
Ubuntu gateway port forwarding on two networks mornsen Linux - Networking 6 01-25-2012 02:44 AM
Port Forwarding trouble with iptables on ubuntu gateway elgranjefe Linux - Networking 2 11-17-2008 07:44 PM
port forwarding on Belkin 4-port Cable/DSL Gateway Router sycamorex Linux - Networking 5 03-05-2007 03:27 PM
Internet gateway with ip packet forwarding GiX Linux - Networking 10 07-29-2005 10:33 AM

LinuxQuestions.org > Forums > Other *NIX Forums > *BSD

All times are GMT -5. The time now is 01:38 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