Forum SubscriptionsForum Subscriptions   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
NAT Masquerade reflection/bounce

 
Post new topic   Reply to topic    Vyatta.org Forum Index -> Users
View previous topic :: View next topic  
Author Message
HakanL
Forum Newbie
Forum Newbie


Joined: 10 Apr 2008
Posts: 15

PostPosted: Thu Apr 10, 2008 7:24 pm    Post subject: NAT Masquerade reflection/bounce Reply with quote

Hi,

I'm new to Vyatta but really like it so far. I'm trying to set up a scenario where I want to access a private server which is mapped thru destination NAT to my public ip from the private subnet.

Private subnet: 192.168.1.0/24

Public ip: 20.1.1.1
Destination port: 80
Server private ip: 192.168.1.100

Workstation: 192.168.1.200

I can access the Internet fine from both the workstation and the server, and I can access the server on its private ip. I can also access the server from the interne.
However I'd like to access the server on the workstation thru the public ip as well. That way I don't need a separate internal DNS server or a similar hack. I've done this with several firewalls in the past, including Linksys and IpCop. I also know I can't do this on a Cisco PIX which I think is a big limitation.

My question is, how do I configure this in vyatta?
I found this (http://www.zeroshell.net/eng/forum/viewtopic.php?p=671&sid=2a0ae8daee70abb55ba84acb6cbefaf1) forum post for another firewall (ZeroShell) where someone explains how this is done in iptables. I hope that helps describe what I'm trying to accomplish.


Thanks,
/Hakan
Back to top
View user's profile Send private message
john.southworth
Super User
Super User


Joined: 26 Feb 2008
Posts: 302

PostPosted: Wed Apr 16, 2008 5:55 pm    Post subject: Reply with quote

I have managed to do this very convolutely, since this is just for my local network and I have a dynamic wan IP I had to go around the world to make it work. Luckly you have what i assume is a static wan IP so it should be easier. Here goes the procedure. Like in the IPtables example you linked to you need two nat rules.

First the DNAT rule
Code:
destination {
     address 20.1.1.1
     port 80
 }
 inbound-interface eth1
 inside-address {
     address 192.168.1.100
     port 80
 }
 protocol tcp
 source {
     address 192.168.1.0/24
 }
 type destination


then the MASQ rule
Code:
 destination {
     address 192.168.1.100
     port 80
 }
 outbound-interface eth1
 protocol tcp
 source {
     address 192.168.1.0/24
 }
 type masquerade


Assuming that this will work off the WAN port like it does for the internal address that I have mine bouncing off of.

Hope this helps.
Back to top
View user's profile Send private message
john.southworth
Super User
Super User


Joined: 26 Feb 2008
Posts: 302

PostPosted: Thu Apr 17, 2008 5:13 am    Post subject: Reply with quote

I have verified that the above will work against the wan interface.

Also note that eth1 is my LAN side NIC and it should remain the interface we are watching on.
Back to top
View user's profile Send private message
HakanL
Forum Newbie
Forum Newbie


Joined: 10 Apr 2008
Posts: 15

PostPosted: Thu Apr 17, 2008 7:11 am    Post subject: Reply with quote

Excellent, thank you very much! I'll give this a try and see how it goes.

/Hakan
Back to top
View user's profile Send private message
shad
Forum Newbie
Forum Newbie


Joined: 21 Jan 2009
Posts: 3

PostPosted: Thu Jan 22, 2009 7:19 pm    Post subject: NAT Masquerade reflection/bounce Reply with quote

Hi,

Sorry to reply to such an old thread but I seem to be stuck with this.

Following the examples almost exactly, other than my subnet is 192.168.0.0/24 and the local LAN is eth0, the closest I can come to getting this to work is getting a timeout instead of a connection refused.
I am using VC5 beta, have a static IP through PPPoE and have tried with the firewall on eth0 disabled with no luck.

Any suggestions?

Thanks,

Dave
Back to top
View user's profile Send private message
john.southworth
Super User
Super User


Joined: 26 Feb 2008
Posts: 302

PostPosted: Fri Jan 23, 2009 6:50 am    Post subject: Reply with quote

Those rules were kind of a nasty hack. I think that you might be better running an internal DNS server and resolving your external domain name to the internal address of the server you are forwarding ports to, or something similar.

If you want to persue the nat reflection route, pleas post your config and I'll see if I can help you with that.
Back to top
View user's profile Send private message
murmel
Active Member
Active Member


Joined: 21 Jan 2009
Posts: 24

PostPosted: Fri Jan 23, 2009 9:36 am    Post subject: Reply with quote

john.southworth wrote:
I have managed to do this very convolutely, since this is just for my local network and I have a dynamic wan IP I had to go around the world to make it work. Luckly you have what i assume is a static wan IP so it should be easier. Here goes the procedure. Like in the IPtables example you linked to you need two nat rules.

First the DNAT rule
Code:
destination {
     address 20.1.1.1
     port 80
 }
 inbound-interface eth1
 inside-address {
     address 192.168.1.100
     port 80
 }
 protocol tcp
 source {
     address 192.168.1.0/24
 }
 type destination


then the MASQ rule
Code:
 destination {
     address 192.168.1.100
     port 80
 }
 outbound-interface eth1
 protocol tcp
 source {
     address 192.168.1.0/24
 }
 type masquerade


Assuming that this will work off the WAN port like it does for the internal address that I have mine bouncing off of.

Hope this helps.


I'm now sending you a big freaking hug! You made my day! =)

Code:
set service nat rule 2
set service nat rule 2 destination port 443
set service nat rule 2 inbound-interface eth0
set service nat rule 2 inside-address address 192.168.0.42
set service nat rule 2 protocol tcp
set service nat rule 2 type destination

set service nat rule 3
set service nat rule 3 destination address 84.xxx.xxx.123
set service nat rule 3 destination port 443
set service nat rule 3 inbound-interface eth1
set service nat rule 3 inside-address address 192.168.0.42
set service nat rule 3 inside-address port 443
set service nat rule 3 protocol tcp
set service nat rule 3 source address 192.168.0.0/24
set service nat rule 3 type destination

set service nat rule 4
set service nat rule 4 destination address 192.168.0.42
set service nat rule 4 destination port 443
set service nat rule 4 outbound-interface eth1
set service nat rule 4 protocol tcp
set service nat rule 4 source address 192.168.0.0/24
set service nat rule 4 type masquerade


This forwards port 443 to my webserver and also makes it possible to use the external ip (in this case: 84.xxx.xxx.123) from inside the lan.
Thanks man! Smile
Back to top
View user's profile Send private message
shad
Forum Newbie
Forum Newbie


Joined: 21 Jan 2009
Posts: 3

PostPosted: Fri Jan 23, 2009 11:43 am    Post subject: Reply with quote

Here is my working config before adding any refection rules. Please let me know if I have something wrong even before I add the rules.

Thanks,

Dave


firewall {
broadcast-ping disable
name ALLOW_ESTABLISHED {
rule 10 {
action accept
}
}
}
interfaces {
ethernet eth0 {
address 192.168.0.2/24
description "LAN - Onboard"
firewall {
in {
name ALLOW_ESTABLISHED
}
local {
name ALLOW_ESTABLISHED
}
}
hw-id 00:19:66:40:da:5c
}
ethernet eth1 {
duplex auto
hw-id 00:19:5b:fc:8e:e3
pppoe 1 {
default-route auto
mtu 1440
password ****************
user-id ******
}
}
ethernet eth2 {
duplex auto
hw-id 00:19:5b:fc:8e:e6
pppoe 2 {
default-route auto
mtu 1440
password ****************
user-id *****
}
}
ethernet eth3 {
duplex auto
hw-id 00:19:5b:fc:8f:c0
pppoe 3 {
default-route auto
mtu 1440
password ****************
user-id *****
}
}
loopback lo {
}
}
load-balancing {
wan {
interface-health pppoe1 {
failure-count 5
nexthop 209.183.xxx.10
ping 199.166.6.4
}
interface-health pppoe2 {
failure-count 4
nexthop 209.183.xxx.10
ping 199.166.6.4
}
interface-health pppoe3 {
failure-count 3
nexthop 209.183.xxx.10
ping 199.166.6.4
}
rule 10 {
inbound-interface eth0
interface pppoe1 {
weight 1
}
interface pppoe2 {
weight 1
}
interface pppoe3 {
weight 1
}
}
}
}
protocols {
static {
route 0.0.0.0/0 {
next-hop 209.183.xxx.10 {
}
}
}
}
service {
nat {
rule 10 {
description "Backup MX SMTP out to internet"
outbound-interface pppoe1
outside-address {
address 216.75.xxx.103
}
protocol tcp
source {
address 192.168.0.12
port 25
}
type source
}
rule 11 {
description "Backup MX SMTP inbound to neptune"
destination {
address 216.75.xxx.103
port smtp
}
inbound-interface pppoe1
inside-address {
address 192.168.0.12
}
protocol tcp
type destination
}
rule 12 {
description "Secure Remote Access"
destination {
port 2222
}
inbound-interface pppoe+
inside-address {
address 192.168.0.1
}
protocol tcp
type destination
}
rule 13 {
description "DNS"
destination {
port domain
}
inbound-interface pppoe+
inside-address {
address 192.168.0.1
}
protocol udp
type destination
}
rule 14 {
description "email to Mars"
destination {
address 209.183.xxx.45
port 25
}
inbound-interface pppoe2
inside-address {
address 192.168.0.11
port 2525
}
protocol tcp
type destination
}
rule 15 {
description "email to Mars"
destination {
address 216.75.xxx.131
port 25
}
inbound-interface pppoe3
inside-address {
address 192.168.0.11
port 2525
}
protocol tcp
type destination
}
rule 16 {
description "FTP"
destination {
port 21
}
inbound-interface pppoe+
inside-address {
address 192.168.0.12
}
protocol tcp
type destination
}
rule 17 {
description "Web Site"
destination {
port 80
}
inbound-interface pppoe+
inside-address {
address 192.168.0.12
port 8080
}
protocol tcp
type destination
}
rule 18 {
description "Remote Assistance"
destination {
port 6900
}
inbound-interface pppoe+
inside-address {
address 192.168.0.13
}
protocol tcp
type destination
}
rule 19 {
description RSBU
destination {
port 2774,31024-32048
}
inbound-interface pppoe+
inside-address {
address 192.168.0.252
}
protocol tcp
type destination
}
rule 20 {
description "OCS Inventory"
destination {
port 8888
}
inbound-interface pppoe+
inside-address {
address 192.168.0.12
}
protocol tcp
type destination
}
rule 21 {
description "IMAP and SSL"
destination {
port 143,443
}
inbound-interface pppoe+
inside-address {
address 192.168.0.11
}
protocol tcp
type destination
}
rule 22 {
description ESET
destination {
port 22221,22222,22846
}
inbound-interface pppoe+
inside-address {
address 192.168.0.12
}
protocol tcp
type destination
}
rule 23 {
description "Client Intranet"
destination {
port 9999
}
inbound-interface pppoe+
inside-address {
address 192.168.0.12
}
protocol tcp
type destination
}
rule 24 {
description "Standards Updater"
destination {
port 873
}
inbound-interface pppoe+
inside-address {
address 192.168.0.9
}
protocol tcp
type destination
}
}
ssh {
allow-root false
}
}
system {
domain-name aplus.local
gateway-address 209.183.xxx.10
host-name router
login {
user root {
authentication {
encrypted-password ****************
}
}
user vyatta {
authentication {
encrypted-password ****************
}
}
}
name-server 199.166.6.4
ntp-server 69.59.150.135
package {
auto-sync 1
repository community {
components main
distribution stable
url http://packages.vyatta.com/vyatta
}
}
time-zone "New York"
Back to top
View user's profile Send private message
hslabbert
Active Member
Active Member


Joined: 18 Mar 2009
Posts: 33

PostPosted: Sat Apr 11, 2009 6:49 pm    Post subject: More generic MASQ rule? Reply with quote

Hi John,

I was just looking at the second rule you have there for the masquerade portion. Would it not be possible to make that rule a bit more generic?

Instead of:

Code:
 destination {
     address 192.168.1.100
     port 80
 }
 outbound-interface eth1
 protocol tcp
 source {
     address 192.168.1.0/24
 }
 type masquerade


Couldn't you instead do:

Code:
 destination {
     address 192.168.1.0/24
 }
 outbound-interface eth1
 protocol tcp
 source {
     address 192.168.1.0/24
 }
 type masquerade


The idea there being that if you have multiple services or servers for which you would want to provide this type of reflexive configuration, you don't need a separate MASQ rule for each of those, but rather only a separate DNAT rule instead?

It looks like a fairly safe rule to my mind (and does appear to work as expected in a test environment), as LAN machines should not be intentionally going to the router if they know that their final destination is on their own LAN, and so we should only be catching these reflexive cases with that rule.

Any thoughts on that or any unforeseen consequences with making that rule more generic as described above?
Back to top
View user's profile Send private message
john.southworth
Super User
Super User


Joined: 26 Feb 2008
Posts: 302

PostPosted: Sat Apr 11, 2009 8:00 pm    Post subject: Reply with quote

That should work fine.

I haven't tested it, but i wonder I don't see why it shouldn't do anything (I'll have to play with it in a lab and see what happens)
Back to top
View user's profile Send private message
hslabbert
Active Member
Active Member


Joined: 18 Mar 2009
Posts: 33

PostPosted: Sat Apr 11, 2009 8:05 pm    Post subject: Reply with quote

Cool; thanks.
Back to top
View user's profile Send private message
geejay
Forum Newbie
Forum Newbie


Joined: 23 Aug 2009
Posts: 3

PostPosted: Fri Sep 25, 2009 1:58 am    Post subject: Reply with quote

I tried the above configuration with load-balancing and it didn*t work.

The router locked up completely.

Is there anything to observe when doing NAT reflection with load balancing ?

Thanks

Geejay
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Vyatta.org Forum Index -> Users All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum