Home
Help
Search
Login
Register
OPNsense Forum
»
Archive
»
16.1 Legacy Series
»
NAT Outbound And VPN
« previous
next »
Print
Pages: [
1
]
Author
Topic: NAT Outbound And VPN (Read 16411 times)
framura
Jr. Member
Posts: 64
Karma: 3
NAT Outbound And VPN
«
on:
June 21, 2016, 10:25:18 pm »
Hi,
I have a problem with NAT Outbound and my VPN configuration.
I setup months ago OpenVPN (client) with my VPN provider and I setup (Firewall-NAT-Outbound) some manual rules like
192.168.2.0/24 on VPN interface (to force VPN on every device on my LAN).
All works very good.
Now I would like to setup an exception: for a specific device, 192.168.2.12 I want to use wan interface and not VPN.
So I added another rule for 192.168.2.12/32, as first rule, but this device uses always VPN interface.
So, where is my mistake?
Thanks for your help.
«
Last Edit: June 23, 2016, 08:44:03 am by framura
»
Logged
framura
Jr. Member
Posts: 64
Karma: 3
Re: NAT Outbound And VPN
«
Reply #1 on:
June 23, 2016, 08:45:09 am »
I tried also to add a specific rule on Firewall->Rules for above device but doesn't works.
Just a little help?
Thanks in advance
Logged
franco
Administrator
Hero Member
Posts: 17668
Karma: 1611
Re: NAT Outbound And VPN
«
Reply #2 on:
June 23, 2016, 11:07:56 am »
Hi framura,
I just read the pf.conf manual and it states the order you tried should be the correct one, so:
(1) Are you using hybrid mode or manual mode?
(2) When the rules are in place, can you check /tmp/rules.debug if the single host NAT rule is there and that it really is the first rule?
Cheers,
Franco
Logged
framura
Jr. Member
Posts: 64
Karma: 3
Re: NAT Outbound And VPN
«
Reply #3 on:
June 23, 2016, 06:45:59 pm »
Thanks franco.
I use hybrid mode.
Now I removed all new rules but I don't know if I need to add rules on outbound (Firewall->NAT->Outbound) and/or rules on Firewall->Rules.
Now I will try to add a new rule on NAT Outbound for my specific device and I will check /tmp/rules.debug.
Thanks
Logged
framura
Jr. Member
Posts: 64
Karma: 3
Re: NAT Outbound And VPN
«
Reply #4 on:
June 23, 2016, 07:06:11 pm »
Just tried: before new rule I get from /tmp/rules.debug
(192.168.2.1 is my opnsense router (LAN), 192.168.1.1 is my Internet router)
nat on $PROVIDERVPN from 192.168.2.0/24 to any -> ip_gateway_VPN/32 port 1024:65535
nat on $PROVIDERVPN from 192.168.2.0/24 to any port 500 -> ip_gateway_VPN/32 static-port
nat on $PROVIDERVPN from 127.0.0.0/8 to any -> ip_gateway_VPN/32 port 1024:65535
nat on $PROVIDERVPN from 127.0.0.0/8 to any port 500 -> ip_gateway_VPN/32 static-port
and then
tonatsubnets = "{ 127.0.0.0/8 192.168.2.0/24 }"
nat on $WAN from $tonatsubnets to any port 500 -> 192.168.1.7/32 static-port
nat on $WAN from $tonatsubnets to any -> 192.168.1.7/32 port 1024:65535
So, I add a new rule for 192.168.2.12 and I get
nat on $WAN from 192.168.2.12/32 to any -> 192.168.1.7/32 port 1024:65535
before above rules.
I tried again from 192.168.2.12 device (it's a blu-ray player) but I get VPN address (I checked with ipleak.net in a browser).
Have you any idea?
Thanks
Logged
jhh
Newbie
Posts: 6
Karma: 2
Re: NAT Outbound And VPN
«
Reply #5 on:
June 24, 2016, 05:23:22 pm »
Hi framura,
routing table decides, which interface will be used outbound.
Afterwards, NAT rules for that single interface are used.
So it is dependent on the destination and the routingtable.
If you try to access 1.1.1.1 and you have a route, which sends that traffic through openvpn, then NAT rules on openvpn interface are followed.
If you try to acces 99.99.99.99 and you have a route, which sends that through your WAN interface, then that NAT rules are used.
To influence, which interface is used outbound, you can use policy based routing.
This is done on OPNsense, by changing the gateway inside a firewall rule.
So lets assume, you use the default LAN out rule and nothing else, then you could:
add a rule above that LAN rule, which allows traffic from 192.168.2.12 to destinations of your choice (maybe any?)
in "Advanced features" section of that rule change gateway from "default" the the gateway representing your internet router.
Afterwards traffic coming from 192.168.2.12 to specified destinations will go out through WAN interface and not openvpn.
You do not need to add additional outbound NAT rules, cause what you defined is already included in
nat on $WAN from $tonatsubnets to any -> 192.168.1.7/32 port 1024:65535
(192.168.2.12/32 is part of 192.168.2.0/24)
So you can remove your additional outbound NAT rule.
Regards,
Joerg
Logged
framura
Jr. Member
Posts: 64
Karma: 3
Re: NAT Outbound And VPN
«
Reply #6 on:
June 24, 2016, 06:41:27 pm »
Thanks Joerg,
I tried as you stated but now I haven't Internet access from 192.168.2.12.
I have:
6 rules on NAT Outbound (4 Manual for VPNINTERFACE and 2 automatic for Wan interface)
Under Firewall->Rules I have
Floating: 1 block rule for IPV6
WAN: 0 rule
LAN: 3 rules (1st is the one just added, others two enable IPV4 and IPV6 on Lan net)
PROVIDERVPN Interace: 0 rule
OpenVPN: 0 rule
I added on LAN tab following rule (as first rule):
Action: pass, Interface: lan, Source: 192.168.2.12, destination: any, gateway (isn't under advanced options): WAN_DHCP 192.168.1.1
Thanks for your help
Logged
framura
Jr. Member
Posts: 64
Karma: 3
Re: NAT Outbound And VPN
«
Reply #7 on:
June 24, 2016, 08:00:42 pm »
I made a little modification to above rule: as destination I inserted wan_net and I my device is able to connect to Internet but always through VPN address.
I really don't understand.
Logged
franco
Administrator
Hero Member
Posts: 17668
Karma: 1611
Re: NAT Outbound And VPN
«
Reply #8 on:
June 25, 2016, 03:14:42 pm »
How are your gateways set up... VPN is the default gateway, right?
Logged
framura
Jr. Member
Posts: 64
Karma: 3
Re: NAT Outbound And VPN
«
Reply #9 on:
June 25, 2016, 05:16:23 pm »
No franco,
default gateway is WAN_DHCP on WAN interface.
Logged
framura
Jr. Member
Posts: 64
Karma: 3
Re: NAT Outbound And VPN
«
Reply #10 on:
June 26, 2016, 04:27:49 pm »
Hi,
to test my opnsense configuration, I made some tests with pfsense.
With same configuration on pfsense, I get correct result: my 192.168.2.12 device doesn't uses VPN but WAN.
Can you help me?
Thanks in advance
Logged
franco
Administrator
Hero Member
Posts: 17668
Karma: 1611
Re: NAT Outbound And VPN
«
Reply #11 on:
June 27, 2016, 07:43:12 am »
Which pfSense version? If 2.3, there's a 10.3 kernel to try and see if this was a pf-related issue. If not we know that it's definitely a config issue on our side.
Logged
framura
Jr. Member
Posts: 64
Karma: 3
Re: NAT Outbound And VPN
«
Reply #12 on:
June 27, 2016, 09:10:24 am »
I used last pfsense version, 2.3.1.
Do you suggest to try with opnsense 16.7 beta version?
If yes, can I install directly 16.7 beta version without upgrading my 16.1.7 installation?
«
Last Edit: June 27, 2016, 09:51:10 am by framura
»
Logged
franco
Administrator
Hero Member
Posts: 17668
Karma: 1611
Re: NAT Outbound And VPN
«
Reply #13 on:
June 27, 2016, 01:24:00 pm »
Hi framura,
In this case you can change your FreeBSD version underneath using this and an immediate boot afterwards:
# opnsense-update -hbkr 16.1.16-devel && /usr/local/etc/rc.reboot
Please note: this is the latest test version. It works on all machines and is equal in patching to the current 10.2 version. It is, however, not the version that is going to be on the 16.7 RC images and the next firmware update may move you back to FreeBSD 10.2. Use with care.
Cheers,
Franco
Logged
Print
Pages: [
1
]
« previous
next »
OPNsense Forum
»
Archive
»
16.1 Legacy Series
»
NAT Outbound And VPN