OpenVPN and Guest Wireless Network

Hello,

I have configured OpenVPN on router with LEDE.

This is my conf.

Network conf file:

config interface 'vpn'
        option ifname 'tun0'
        option proto 'none'

Firewall conf file:

config zone
        option name 'vpn'
        option input 'ACCEPT'
        option forward 'ACCEPT'
        option output 'ACCEPT'
        option network 'vpn'
        option masq '1'

config forwarding
        option src 'vpn'
        option dest 'wan'

config rule
        option name 'OpenVPN'
        option target 'ACCEPT'
        option src 'wan'
        option proto 'udp'
        option dest_port '51194'

config forwarding
        option src 'vpn'
        option dest 'lan'

I want to set up a wifi network for guests from this tutorial https://wiki.openwrt.org/doc/recipes/guest-wlan

But when I add this:

config interface 'guest'
       option proto 'static'
       option ipaddr '10.0.0.1'
       option netmask '255.255.255.0'

to network conf file connection via VPN is established but from the connected device (client vpn) I do not have access even to openwrt. When I remove this lines OpenVPN starts to work correctly. What am I doing wrong?

You're showing the first step in configuring a guest WLAN.

Did you complete the other steps?

Yes, but I just quoted the code that causes the problem.

Wireless conf:

config wifi-iface
       option device 'radio0'
       option mode 'ap'
       option network 'guest'
       option ssid 'wifiname'
       option isolate '1'
       option encryption 'psk2'
       option key 'wifipassword'

Dhcp conf:

config dhcp 'guest'
       option interface 'guest'
       option start '5'
       option limit '30'
       option leasetime '1h'

Firewall:

config zone
       option name 'guest'
       option network 'guest'
       option input 'REJECT'
       option forward 'REJECT'
       option output 'ACCEPT'
config forwarding
       option src 'guest'
       option dest 'wan'
config rule
       option name 'Allow DNS Queries'
       option src 'guest'
       option dest_port '53'
       option proto 'tcp udp'
       option target 'ACCEPT'
config rule
       option name 'Allow DHCP request'
       option src 'guest'
       option src_port '67-68'
       option dest_port '67-68'
       option proto 'udp'
       option target 'ACCEPT'

And config in network config file..

That's all.

Rather than seeing bits and pieces of configs, post the full results of the following...

cat /etc/config/network

cat /etc/config/wireless

cat /etc/config/firewall

Ok, Sorry.

**root@router0:~# cat /etc/config/network**

config interface 'loopback'
        option ifname 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fdf9:b1c5:7eeb::/48'

config interface 'lan'
        option type 'bridge'
        option ifname 'eth0.1'
        option proto 'static'
        option netmask '255.255.255.0'
        option ip6assign '60'
        option ipaddr '192.168.0.1'

config device 'lan_dev'
        option name 'eth0.1'
        option macaddr '84:16:f9:7b:95:82'

config interface 'wan'
        option ifname 'eth0.2'
        option proto 'dhcp'

config device 'wan_dev'
        option name 'eth0.2'
        option macaddr '84:16:f9:7b:95:83'

config interface 'wan6'
        option ifname 'eth0.2'
        option proto 'dhcpv6'

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '1'

config switch_vlan
        option device 'switch0'
        option vlan '1'
        option ports '1 2 3 4 0t'

config switch_vlan
        option device 'switch0'
        option vlan '2'
        option ports '5 0t'

config interface 'vpn'
        option ifname 'tun0'
        option proto 'none'

config interface 'guest'
       option proto 'static'
       option ipaddr '10.0.0.1'
       option netmask '255.255.255.0'


**root@router0:~# cat /etc/config/wireless**

config wifi-device 'radio0'
        option type 'mac80211'
        option channel '11'
        option hwmode '11g'
        option path 'platform/qca956x_wmac'
        option htmode 'HT20'
        option country 'US'

config wifi-iface 'default_radio0'
        option device 'radio0'
        option network 'lan'
        option mode 'ap'
        option ssid 'lede'
        option encryption 'psk2'
        option key 'wifipassword'

config wifi-iface
       option device 'radio0'
       option mode 'ap'
       option network 'guest'
       option ssid 'wifiname'
       option isolate '1'
       option encryption 'psk2'
       option key 'wifipassword'

**root@router0:~# cat /etc/config/firewall**

config defaults
        option syn_flood '1'
        option input 'ACCEPT'
        option output 'ACCEPT'
        option forward 'REJECT'

config zone
        option name 'lan'
        list network 'lan'
        option input 'ACCEPT'
        option output 'ACCEPT'
        option forward 'ACCEPT'

config zone
        option name 'wan'
        list network 'wan'
        list network 'wan6'
        option input 'REJECT'
        option output 'ACCEPT'
        option forward 'REJECT'
        option masq '1'
        option mtu_fix '1'

config forwarding
        option src 'lan'
        option dest 'wan'

config rule
        option name 'Allow-DHCP-Renew'
        option src 'wan'
        option proto 'udp'
        option dest_port '68'
        option target 'ACCEPT'
        option family 'ipv4'

config rule
        option name 'Allow-Ping'
        option src 'wan'
        option proto 'icmp'
        option icmp_type 'echo-request'
        option family 'ipv4'
        option target 'ACCEPT'

config rule
        option name 'Allow-IGMP'
        option src 'wan'
        option proto 'igmp'
        option family 'ipv4'
        option target 'ACCEPT'

config rule
        option name 'Allow-DHCPv6'
        option src 'wan'
        option proto 'udp'
        option src_ip 'fc00::/6'
        option dest_ip 'fc00::/6'
        option dest_port '546'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-MLD'
        option src 'wan'
        option proto 'icmp'
        option src_ip 'fe80::/10'
        list icmp_type '130/0'
        list icmp_type '131/0'
        list icmp_type '132/0'
        list icmp_type '143/0'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-ICMPv6-Input'
        option src 'wan'
        option proto 'icmp'
        list icmp_type 'echo-request'
        list icmp_type 'echo-reply'
        list icmp_type 'destination-unreachable'
        list icmp_type 'packet-too-big'
        list icmp_type 'time-exceeded'
        list icmp_type 'bad-header'
        list icmp_type 'unknown-header-type'
        list icmp_type 'router-solicitation'
        list icmp_type 'neighbour-solicitation'
        list icmp_type 'router-advertisement'
        list icmp_type 'neighbour-advertisement'
        option limit '1000/sec'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-ICMPv6-Forward'
        option src 'wan'
        option dest '*'
        option proto 'icmp'
        list icmp_type 'echo-request'
        list icmp_type 'echo-reply'
        list icmp_type 'destination-unreachable'
        list icmp_type 'packet-too-big'
        list icmp_type 'time-exceeded'
        list icmp_type 'bad-header'
        list icmp_type 'unknown-header-type'
        option limit '1000/sec'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-IPSec-ESP'
        option src 'wan'
        option dest 'lan'
        option proto 'esp'
        option target 'ACCEPT'

config rule
        option name 'Allow-ISAKMP'
        option src 'wan'
        option dest 'lan'
        option dest_port '500'
        option proto 'udp'
        option target 'ACCEPT'

config include
        option path '/etc/firewall.user'

config redirect
        option target 'DNAT'
        option src 'wan'
        option dest 'lan'
        option proto 'tcp'
        option src_dport '80'
        option dest_ip '192.168.0.20'
        option dest_port '80'
        option name 'http'

config redirect
        option enabled '1'
        option target 'DNAT'
        option src 'wan'
        option dest 'lan'
        option proto 'tcp'
        option src_dport '443'
        option dest_ip '192.168.0.20'
        option dest_port '443'
        option name 'https'

config zone
        option name 'vpn'
        option input 'ACCEPT'
        option forward 'ACCEPT'
        option output 'ACCEPT'
        option network 'vpn'
        option masq '1'

config forwarding
        option src 'vpn'
        option dest 'wan'

config rule
        option name 'OpenVPN'
        option target 'ACCEPT'
        option src 'wan'
        option proto 'udp'
        option dest_port '51194'

config forwarding
        option src 'vpn'
        option dest 'lan'

config zone
       option name 'guest'
       option network 'guest'
       option input 'REJECT'
       option forward 'REJECT'
       option output 'ACCEPT'

config forwarding
       option src 'guest'
       option dest 'wan'

config rule
       option name 'Allow DNS Queries'
       option src 'guest'
       option dest_port '53'
       option proto 'tcp udp'
       option target 'ACCEPT'

config rule
       option name 'Allow DHCP request'
       option src 'guest'
       option src_port '67-68'
       option dest_port '67-68'
       option proto 'udp'
       option target 'ACCEPT'

No worries.

Also /etc/config/dhcp

config dhcp 'wan'
        option interface 'wan'
        option ignore '1'

config odhcpd 'odhcpd'
        option maindhcp '0'
        option leasefile '/tmp/hosts/odhcpd'
        option leasetrigger '/usr/sbin/odhcpd-update'

config host
        option dns '1'
        option mac 'f0:5b:7b:12:68:a9'
        option ip '192.168.0.90'
        option name 'a5'

config host
        option name 'zenbbok'
        option dns '1'
        option mac '74:da:38:d8:ec:33'
        option ip '192.168.0.80'

config host
        option dns '1'
        option mac 'a4:71:74:3d:73:0f'
        option ip '192.168.0.91'
        option name 'p9lite'

config host
        option name 'rpi'
        option dns '1'
        option mac 'b8:27:eb:9d:d5:c2'
        option ip '192.168.0.20'

config host
        option name 'tv'
        option dns '1'
        option mac 'c4:8e:8f:8d:3b:1d'
        option ip '192.168.0.70'

config host
        option name 'brother'
        option dns '1'
        option mac '54:8c:a0:2d:8f:bd'
        option ip '192.168.0.200'

config host
        option name 'zenbook_wifi'
        option dns '1'
        option mac 'a4:02:b9:47:70:89'
        option ip '192.168.0.81'
config dhcp 'guest'
       option interface 'guest'
       option start '5'
       option limit '30'
       option leasetime '1h'

Does the guest WLAN work if OpenVPN is not running?

Yes. When I stopped OpenVPN, the guest network works normally and I can browse the internet from this network.

I stopped ovpn by:

 /etc/init.d/openvpn stop
config zone
        option name 'vpn'
        option input 'ACCEPT'
        option forward 'ACCEPT'
        option output 'ACCEPT'
        option network 'vpn'
        option masq '1'

Change option input and option forward to REJECT for this zone.

config forwarding
        option src 'vpn'
        option dest 'wan'

I think you only need the vpn to lan and guest to wan forwarding rules.

See the OpenWrt/LEDE documentation for configuring an OpenVPN Client.

https://openwrt.org/docs/guide-user/services/vpn/openvpn/client#openvpn_client

Current Configure a guest WLAN documentation.

don't get me wrong. however, I've a server on the router. nevertheless, should I use the firewall configuration as for the client?

Looks like you were configuring an OpenVPN Client.

I don't see any firewall zone or rules for an OpenVPN Server.

https://openwrt.org/docs/guide-user/services/vpn/openvpn/server.setup#openvpn_server_setup

Ok, I've modified config rule OpenVPN and I changed src to '*' and proto to 'tcpudp', other conf rules is the same of config what's in your link.

And... It's working :slight_smile: Thank you!

Also, I've configured OpenVPN firewall rules and others settings from other tutorial and it normally worked without guest wireless network.

This should NEVER be done

  • What device are you exposing to WAN on 80 & 443?
    • Even if you were running an apache or nginx web server, you'd want it in it's own network zone, not in lan, as no unauthenticated, non-crypto verified traffic should be allowed to pass from WAN to LAN

It's rasoberry pi with owncloud.
This network is in my home. To learning. You suggest that i should create vlan for www server?

Unless you're 100% on your web server config for ownCloud/NextCloud, it should not be exposed to WAN. IIRC, there's a warning in the ownCloud manual about not exposing it to WAN until the user fully understands the webserver they're using and has a secure web server config up and running.

If you've done all that, it should be on its own vlan

I think apache is properly secured. However, I'm not sure. I need external access because sometimes I need OwnCloud data from another device.

Maybe I should start a new topic, but I have such a short question.

Can you configure wshaper on LEDE?
When I install this package and set the configuration as below, all traffic on all networks falls to 1Mbps, and when I uninstall wshaper I have 100Mbps back.

config wshaper 'settings'
    option network 'guest'
    option downlink '8192'
    option uplink '1024'

If you look carefully at the wshaper section, you'll see the following warning...

Wondershaper (wshaper) is not recommended. Better use qos-scripts or sqm-scripts (see the Bufferbloat project).

It's been a few years since I read through the ownCloud manual, as I switched to NextCloud after the mass exodus of ownCloud maintainers back in 2015ish to form NextCloud. I ended up going with Nginx, but if IIRC there's a section in the ownCloud manual about Apache.

If you haven't thoroughly read the manual, or haven't had prior experience with Apache, it would be recommended to configure a VPN or tunnel access to owCloud over SSH, as you don't want to expose it's webserver to WAN unless you're 100% it's secure and is not exploitable. If you do choose to leave it directly exposed to WAN, it definitely needs to be in it's own vLAN with no other devices and strict firewalling in place for it's vLAN.

  • I have NextCloud running in a FreeBSD jail, and I'm not sure what your underlying OS is on the Pi, but, if possible, you definitely want to jail it to protect the underlying OS.

The raspberry system is raspbian, i.e. simply debian. I tried centos, but I miss a lot of packages for this architecture.

I need to think about VLAN, because VPN is ok, but it would be a bother to run VPN whenever I want to get to files. Besides, I have synchronization on my phone and I would have to enable OpenVPN permanently. In total, I could think about the SSH tunnel.

In fact, I was thinking about NextCloud, but ultimately I chose OwnCloud.

Are you suggesting that NextCloud is safer? I seriously consider migration from OwnCloud. I need to investigate whether the database is compatible to copy contacts and calendars.