0

I'm trying to set up my raspberry pi as a VPN Gateway following this tutorial: http://blog.frd.mn/raspberry-pi-vpn-gateway/

I'm using another WLAN-adapter but that shouldn't matter. So at the end I get all the services (hostapde, isc-dhcp-server, and openvpn) to run but I cannot connect to the DHCP. When I try to connect my Android Phone to the new WLAN it just stops trying at some point and connects to my original WLAN. When I connect my Windows-Computer to the new WLAN it tells me that the connection is restricted and when I check, I can see that I don't have an IP-adress from the DHCP.

When I check /var/log/syslog, I get:

Dec 22 16:56:42 rpi-livingroom kernel: [ 3421.603270] ---[ end trace e7db3c361613ef28 ]---
Dec 22 16:56:47 rpi-livingroom dhcpd: DHCPDISCOVER from fc:c2:de:9f:6e:fe (android-29649d76dedea826) via wlan0
Dec 22 16:56:47 rpi-livingroom dhcpd: DHCPOFFER on 192.168.18.10 to fc:c2:de:9f:6e:fe (android-29649d76dedea826) via wlan0
Dec 22 16:56:49 rpi-livingroom hostapd: wlan0: STA fc:c2:de:9f:6e:fe IEEE 802.11: disassociated
Dec 22 16:56:49 rpi-livingroom kernel: [ 3428.693154] ------------[ cut here ]------------
Dec 22 16:56:49 rpi-livingroom kernel: [ 3428.693324] WARNING: CPU: 0 PID: 2150 at net/mac80211/ieee80211_i.h:813 ieee80211_tdls_mgmt+0xa38/0xa48 [mac80211]()
Dec 22 16:56:49 rpi-livingroom kernel: [ 3428.693341] Modules linked in: tun 8021q garp stp llc ipt_MASQUERADE iptable_nat nf_nat_ipv4 nf_nat ipt_REJECT xt_comment nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack iptable_filter ip_tables x_tables snd_bcm2835 arc4 snd_usb_audio snd_hwdep snd_usbmidi_lib snd_seq_midi snd_seq_midi_event rt2800usb snd_soc_bcm2708_i2s rt2800lib crc_ccitt regmap_mmio rt2x00usb rt2x00lib snd_soc_core regmap_spi snd_rawmidi snd_pcm_dmaengine mac80211 joydev snd_pcm snd_page_alloc regmap_i2c snd_compress snd_seq cfg80211 snd_timer rfkill snd_seq_device snd
Dec 22 16:56:49 rpi-livingroom kernel: [ 3428.693517] CPU: 0 PID: 2150 Comm: hostapd Tainted: G        W    3.12.26-rpi-aufs #1
Dec 22 16:56:49 rpi-livingroom kernel: [ 3428.693587] [<c00147d8>] (unwind_backtrace+0x0/0xf0) from [<c0011b9c>] (show_stack+0x10/0x14)
Dec 22 16:56:49 rpi-livingroom kernel: [ 3428.693627] [<c0011b9c>] (show_stack+0x10/0x14) from [<c001fa48>] (warn_slowpath_common+0x68/0x88)
Dec 22 16:56:49 rpi-livingroom kernel: [ 3428.693730] [<c001fa48>] (warn_slowpath_common+0x68/0x88) from [<c001fa84>] (warn_slowpath_null+0x1c/0x24)
Dec 22 16:56:49 rpi-livingroom kernel: [ 3428.693831] [<c001fa84>] (warn_slowpath_null+0x1c/0x24) from [<bf0a4058>] (ieee80211_tdls_mgmt+0xa38/0xa48 [mac80211])
Dec 22 16:56:49 rpi-livingroom kernel: [ 3428.693965] [<bf0a4058>] (ieee80211_tdls_mgmt+0xa38/0xa48 [mac80211]) from [<bf0a4204>] (ieee80211_change_station+0x19c/0x308 [mac80211])
Dec 22 16:56:49 rpi-livingroom kernel: [ 3428.694106] [<bf0a4204>] (ieee80211_change_station+0x19c/0x308 [mac80211]) from [<bf035fb4>] (nl80211_set_station+0x1c0/0x258 [cfg80211])
Dec 22 16:56:49 rpi-livingroom kernel: [ 3428.694338] [<bf035fb4>] (nl80211_set_station+0x1c0/0x258 [cfg80211]) from [<c03df468>] (genl_rcv_msg+0x1fc/0x328)
Dec 22 16:56:49 rpi-livingroom kernel: [ 3428.694385] [<c03df468>] (genl_rcv_msg+0x1fc/0x328) from [<c03de890>] (netlink_rcv_skb+0xbc/0xd8)
Dec 22 16:56:49 rpi-livingroom kernel: [ 3428.694418] [<c03de890>] (netlink_rcv_skb+0xbc/0xd8) from [<c03deb48>] (genl_rcv+0x20/0x34)
Dec 22 16:56:49 rpi-livingroom kernel: [ 3428.694448] [<c03deb48>] (genl_rcv+0x20/0x34) from [<c03de280>] (netlink_unicast+0x158/0x1b4)
Dec 22 16:56:49 rpi-livingroom kernel: [ 3428.694476] [<c03de280>] (netlink_unicast+0x158/0x1b4) from [<c03de4d0>] (netlink_sendmsg+0x1f4/0x35c)
Dec 22 16:56:49 rpi-livingroom kernel: [ 3428.694513] [<c03de4d0>] (netlink_sendmsg+0x1f4/0x35c) from [<c03a2464>] (sock_sendmsg+0x98/0xb8)
Dec 22 16:56:49 rpi-livingroom kernel: [ 3428.694542] [<c03a2464>] (sock_sendmsg+0x98/0xb8) from [<c03a2804>] (___sys_sendmsg+0x2a0/0x2b8)
Dec 22 16:56:49 rpi-livingroom kernel: [ 3428.694575] [<c03a2804>] (___sys_sendmsg+0x2a0/0x2b8) from [<c03a4334>] (__sys_sendmsg+0x3c/0x68)
Dec 22 16:56:49 rpi-livingroom kernel: [ 3428.694610] [<c03a4334>] (__sys_sendmsg+0x3c/0x68) from [<c000e3a0>] (ret_fast_syscall+0x0/0x30)
Dec 22 16:56:49 rpi-livingroom kernel: [ 3428.694627] ---[ end trace e7db3c361613ef29 ]---
Dec 22 16:56:50 rpi-livingroom hostapd: wlan0: STA fc:c2:de:9f:6e:fe IEEE 802.11: deauthenticated due to inactivity

I do not fully understand this, but it seems to me that there is a request for an IP and the server hands one out. But why is my client not connected to the network, then?

My /etc/network/interfaces is:

# Static network configuration handled by Berryboot
iface eth0 inet manual

auto lo
iface lo inet loopback

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
        address 192.168.18.1
        netmask 255.255.255.0

up iptables-restore < /etc/iptables.ipv4.nat

At the end of /etc/dhcp/dhcpd.conf I have the lines:

subnet 192.168.18.0 netmask 255.255.255.0 {
        range 192.168.18.10 192.168.18.50;
        option broadcast-address 192.168.18.255;
        option routers 192.168.18.1;
        default-lease-time 600;
        max-lease-time 7200;
#       option domain-name "local";
#       option domain-name-servers 8.8.8.8, 8.8.4.4;
}

Can anyone tell me, what I could check next?

EDIT: So it looks like it has something to do with the iptables. I removed the rules from the tutorial above and instead used the ones from here: http://learn.adafruit.com/downloads/pdf/setting-up-a-raspberry-pi-as-a-wifi-access-point.pdf

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT

Now, I can use the raspberry pi as a DHCP server and have internet connection on the connected devices. Unfortunately I cannot use openvpn on the pi with this setup, as the rules for iptables above seem not to work once openvpn is running.

1

Setting up the raspberry pi as gateway for an openvpn-connection:

(I know this doesn't exactly answer my original question but it solved the problem for me and I thought maybe someone else is having the same problem.)

I think I have it working now. I followed this guide to set up the raspberry pi as a bridge (instead of an access point). I then set up openvpn like described here.

After that I added the iptables-rules:

sudo iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
sudo iptables -A FORWARD -i tun0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i tun0 -o eth0 -j ACCEPT

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.