LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-15-2015, 07:30 PM   #1
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
QUESTION: Network: Bridging: External WiFi access point to VPN


I want to connect an external WiFi access point plugged into my laptop to a VPN that is established by my laptop. I am not sure how to do this. I am most of the way there, but lack the knowledge of what I need to do to complete the last step.

Here is what I currently have in place, that is working:

(1) Laptop comes up and uses either wlan0 (internal wireless) or eth0 (CAT5 cable) to connect to a network

(2) Laptop brings up secondary WiFi access point, an external usb dongle, wlan1, using hostapd/dnsmasq. At this point, clients can connect to this secondary WiFi access point and subsequently access the internet. I have tested this and it works. But I am not sure exactly HOW it works, because I did not manually set up any bridge between wlan1 and wlan0 (or eth0). I thought I would need to do this manually, but apparently not, since clients connected to wlan1 can successfully access the internet.

(3) Laptop establishes VPN to home over the network connection, which brings up interface tap0 (or tun0, depending on which type of VPN I decided to use). I use OpenVPN for this, have been for some time, and it works perfectly.

Here is what config I have in place, that makes (1), (2) and (3) work (I just list the added or changed lines):

Hardware
---
TPLINK TL-WN722N external usb WiFi adapter

/etc/hostapd/hostapd.conf
---
interface=wlan1
driver=nl80211
ssid=my-ssid
channel=1
hw_mode=g
ieee80211n=1
wpa=3
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP CCMP
wpa_passphrase=my-password
macaddr_acl=0
auth_algs=1
country_code=US
ieee80211d=1

/etc/network/interfaces
---
auto wlan1
allow-hotplug wlan1
iface wlan1 inet static
hostapd /etc/hostapd/hostapd.conf
address 10.192.4.1
netmask 255.255.255.0

/etc/dnsmasq.conf
---
interface=lo,wlan1
no-dhcp-interface=lo
dhcp-range=10.192.4.3,10.192.4.50,255.255.255.0,12h

/etc/NetworkManager.conf
---
[keyfile]
unmanaged-devices=mac:c4:e9:84:xx:xx:xx (the MAC address of the TPLINK device)

/etc/rc.local
---
iptables -t nat -A POSTROUTING -s 10.192.4.0/24 ! -d 10.192.4.0/24 -j MASQUERADE

/etc/openvpn/client.conf
---
No real need to list the details here, because it works 100% perfectly.


Below is the new functionality I want to add after the above basic stuff:

(4) How do I connect wlan1 to tap0 (or tun0, depending type of VPN in use)? Do I need to create a bridge on the laptop? How?

(5) Optional, but preferable, everything would be as automated as possible. e.g., When I plug in the usb external WiFi adapter, wlan1 comes up automatically (it apparently does so now, but I had some error which I forgot the details of and need to re-test and troubleshoot - I believe it was a DHCP or DNS issue, but I can't remember). Manual workaround - use "ifup wlan1" and "ifdown wlan1". Also, when I bring up the VPN (this will always be manual), any bridging necessary to connect wlan1 to the VPN would be automatic (assuming wlan1 was already up when the VPN was brought up). Or, if the VPN is already up when I hot plug the external usb WiFi adapter, any bridging to the VPN would be automatic there as well.

Can anyone give me pointers to where I should research on how to accomplish (4) and (5)?

Thanks in advance!
 
Old 09-16-2015, 10:25 AM   #2
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
To traverse from one interface to another you need to have FORWARDing turned on.

To turn it on right away use:
Code:
echo 1 > /proc/sys/net/ipv4/ip_forward
To make it permanent you need to edit /etc/sysctl.conf and add or change the following:
Code:
net.ipv4.ip_forward = 1
 
Old 09-16-2015, 10:50 AM   #3
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Original Poster
Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
Thanks. Yes, I already have that enabled. But I do not think that alone will allow packets to move between wlan1 and tap0 without additional configuration (bridging?)
 
Old 09-21-2015, 01:28 PM   #4
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
You could try THIS
 
Old 09-23-2015, 09:26 PM   #5
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Original Poster
Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
That looks like a good tutorial. Thanks for posting the link to it!
 
Old 09-24-2015, 11:31 AM   #6
lazydog
Senior Member
 
Registered: Dec 2003
Location: The Key Stone State
Distribution: CentOS Sabayon and now Gentoo
Posts: 1,249
Blog Entries: 3

Rep: Reputation: 194Reputation: 194
yw. Hope it helps.
 
  


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
setting up a vpn-only wifi access point danbeen Linux - Networking 0 08-17-2013 08:46 PM
LXer: Use of IPSEC in Linux when configuring network-to-network and point-to-point VPN connections LXer Syndicated Linux News 0 05-16-2012 03:51 AM
Bridging a Wifi and Wired Network... sancho Linux - Wireless Networking 8 07-18-2008 06:31 PM
Bridging the Wired Segment (Ethernet) & Wireless Segments (Access Point) Paris Heng Linux - Wireless Networking 0 07-14-2007 08:38 AM
measure the network speed between a wifi station and access point powah Linux - Wireless Networking 1 08-19-2005 11:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:29 PM.

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