[GUIDE] Making infrastructure wifi hotspot on ubuntu 12.04/12.10 - Upgrading, Modifying and Unlocking

As many of you know, most of our android(not only android) devices can't connect to ad hoc hotspots. There's a solution for win7/8 users to set up infrastructure hotspot on their laptop using software like connectify and so on. Ubuntu also allows to create wifi hotspot to share internet, but it will be ad hoc one.
So here's the guide how to set up infrastructure hotspot on ubuntu 12.04/12.10. Unlike some other methods described on the internet, this one will not break default network manager.
1. First of all you should make sure, that your wifi adapter supports infrastructure hotspots. If you used connectify on your windows system and it worked, skip this step.
open terminal and type: sudo lshw | less
find -network section and make sure that driver is ath5k or ath9k, this solution will only work for those drivers, but should fit the needs for the most laptop users.
2. We now need to install 2 additional tools to make out hotspot, 1st one is hostapd(hotspot server), 2nd one is dnsmasq(dns dhcp server)
in terminal type: sudo apt-get install hostapd dnsmasq
3. stop those services if started already, and prevent them from starting on system start up.
in terminal type:
sudo service hostapd stop
sudo service dnsmasq stop
sudo update-rc.d hostapd disable
sudo update-rc.d dnsmasq disable
4. Now we need to set up config files.
in terminal type: sudo gedit /etc/dnsmasq.conf
or sudo kate /etc/dnsmasq.conf if you use kde
add those lines to the config file
Code:
# Bind to only one interface
bind-interfaces
# Choose interface for binding
interface=wlan0
# Specify range of IP addresses for DHCP leasses
dhcp-range=192.168.150.2,192.168.150.10
5. hostapd config
in terminal type: sudo gedit /etc/hostapd.conf
and add those lines
Code:
# Define interface
interface=wlan0
# Select driver
driver=nl80211
# Set access point name
ssid=myhotspot
# Set access point harware mode to 802.11g
hw_mode=g
# Set WIFI channel (can be easily changed)
channel=6
# Enable WPA2 only (1 for WPA, 2 for WPA2, 3 for WPA + WPA2)
wpa=2
wpa_passphrase=mypassword
You can change ssid name and password for anything you want here. Current config will create hotspot named myhotspot with mypassword password.
6. Now create anywhere you want a file named start.sh
edit it with any text editor like this:
Code:
#!/bin/bash
# Start
# Configure IP address for WLAN
sudo ifconfig wlan0 192.168.150.1
# Start DHCP/DNS server
sudo service dnsmasq restart
# Enable routing
sudo sysctl net.ipv4.ip_forward=1
# Enable NAT
sudo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
# Run access point daemon
sudo hostapd /etc/hostapd.conf
# Stop
# Disable NAT
sudo iptables -D POSTROUTING -t nat -o ppp0 -j MASQUERADE
# Disable routing
sudo sysctl net.ipv4.ip_forward=0
# Disable DHCP/DNS server
sudo service dnsmasq stop
sudo service hostapd stop
You will probably need to change ppp0 in this to eth0 (or any other number which refers to your wired connection.
7. Last step. Now you can start your hotspot by starting our script. just run it using sudo sh
for me it looks like this sudo sh /home/ogyct/Desktop/start.sh because I have it on my desktop
I am not sure who is the author of this guide, I only translated it to english. But anyway if this helped, hit the thanks button. Good day

Android device having issues connecting to AP
I have an eth0 connection running behind an authenticated proxy server.
I followed the steps and managed to create a hotspot which my google nexus 7 detects. However, it seems stuck at "obtaining an ip address" and is not able to connect to the internet.
I initially received the following error message when running your script in the terminal:
dnsmasq: failed to create listening socket for 127.0.0.1: Address already in use [fail]​
I figured it is because of a conflict with the network manager, I commented out the "dns=dnsmasq" line in the nm configuration file. After a network-manager restart, the first error doesn't show up but I get the following:
Configuration file: /etc/hostapd.conf
Failed to create interface mon.wlan0: -23 (Too many open files in system)
Try to remove and re-create mon.wlan0​
In both cases, however, the hotspot is created and is detected by my android device. only that it cannot "obtain an ip address" and connect to it.
Is it because my eth0 connects via a proxy server?
Or could there be something wrong with the dnsmasq config? Any help would be appreciated.

anandkarthikeyan said:
I have an eth0 connection running behind an authenticated proxy server.
I followed the steps and managed to create a hotspot which my google nexus 7 detects. However, it seems stuck at "obtaining an ip address" and is not able to connect to the internet.
I initially received the following error message when running your script in the terminal:
dnsmasq: failed to create listening socket for 127.0.0.1: Address already in use [fail]​
I figured it is because of a conflict with the network manager, I uncommented "dns=dnsmasq" line in the nm configuration file. After a network-manager restart, the first error doesn't show up but I get the following:
Configuration file: /etc/hostapd.conf
Failed to create interface mon.wlan0: -23 (Too many open files in system)
Try to remove and re-create mon.wlan0​
In both cases, however, the hotspot is created and is detected by my android device. only that it cannot "obtain an ip address" and connect to it.
Is it because my eth0 connects via a proxy server?
Or could there be something wrong with the dnsmasq config? Any help would be appreciated.
Click to expand...
Click to collapse
I've never worked with a proxy server, but from what I see, it seems like your problem has nothing to do with a proxy server. Something's wrong with configuration on wifi side. Try to disable network manager first, if it doesn't help, try to completely clean dnsmaq and hostapd configs and paste code from this thread again. Unfortunately I can not provide any further help, since I have a different configuration on my side.

My galaxy s2 is able to see the "myhotspot" network created following this guide. I set a static ip and gateway to make it obtain an ip address.
Now it seems to be connected, but I have no internet access on my phone...
Could anyone help me?

gio182 said:
My galaxy s2 is able to see the "myhotspot" network created following this guide. I set a static ip and gateway to make it obtain an ip address.
Now it seems to be connected, but I have no internet access on my phone...
Could anyone help me?
Click to expand...
Click to collapse
I am using ubuntu 12.04 and I just figured out the instructions on ".../questions/180733/how-to-setup-a-wi-fi-hotspot-access-point-mode/" (askubuntu) thread worked like a charm for me. It uses the isc-dhcp-server instead of dnsmasq and a different dhcp range I guess. I really don't know enough to tell the difference but it worked. Maybe ogyct can explain it to us.

gio182 said:
My galaxy s2 is able to see the "myhotspot" network created following this guide. I set a static ip and gateway to make it obtain an ip address.
Now it seems to be connected, but I have no internet access on my phone...
Could anyone help me?
Click to expand...
Click to collapse
If everything's made right, there'll be no need for setting static ip adress, dhcp will do it for you.
Try to check if your devices are called wlan0 and eth0, if not, change configs accordingly. Simply type in console iwconfig to see the names. Remember, you may have a different configuration of your system, so be aware of that

HI ogyct,
This is the error i received.
Code:
wlan0: ERROR while getting interface flags: No such device
* Restarting DNS forwarder and DHCP server dnsmasq
dnsmasq: unknown interface wlan0
[fail]
net.ipv4.ip_forward = 1
Configuration file: /etc/hostapd.conf
Could not read interface wlan0 flags: No such device
Could not read interface wlan0 flags: No such device
nl80211 driver initialization failed.
net.ipv4.ip_forward = 0
* Stopping DNS forwarder and DHCP server dnsmasq * (not running)
And my wifi config reads this
Code:
*-network
description: Wireless interface
product: BCM4313 802.11b/g/n Wireless LAN Controller
vendor: Broadcom Corporation
physical id: 0
bus info: [email protected]:03:00.0
logical name: eth1
version: 01
serial: cc:af:78:78:44:03
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless
configuration: broadcast=yes driver=wl0 driverversion=5.100.82.112 latency=0 multicast=yes wireless=IEEE 802.11
resources: irq:17 memory:f1500000-f1503fff
I guess I need to update the interfaces file in /etc/network....??
Any suggestions?

BCM4313 doesn't support AP
You wireless card doesn't support the AP operation mode. You can look up on the hostapd support website and there is a list of suppored devices. The BCM 4313 is part of brcmsmac which is in the NO section for AP. You would need to get a new card or purchase an external wifi card. Hope this helps.
bad_asteroid said:
HI ogyct,
This is the error i received.
Code:
wlan0: ERROR while getting interface flags: No such device
* Restarting DNS forwarder and DHCP server dnsmasq
dnsmasq: unknown interface wlan0
[fail]
net.ipv4.ip_forward = 1
Configuration file: /etc/hostapd.conf
Could not read interface wlan0 flags: No such device
Could not read interface wlan0 flags: No such device
nl80211 driver initialization failed.
net.ipv4.ip_forward = 0
* Stopping DNS forwarder and DHCP server dnsmasq * (not running)
And my wifi config reads this
Code:
*-network
description: Wireless interface
product: BCM4313 802.11b/g/n Wireless LAN Controller
vendor: Broadcom Corporation
physical id: 0
bus info: [email protected]:03:00.0
logical name: eth1
version: 01
serial: cc:af:78:78:44:03
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless
configuration: broadcast=yes driver=wl0 driverversion=5.100.82.112 latency=0 multicast=yes wireless=IEEE 802.11
resources: irq:17 memory:f1500000-f1503fff
I guess I need to update the interfaces file in /etc/network....??
Any suggestions?
Click to expand...
Click to collapse

a little help
I made the hotspot successfully but its not sharing the internet connection
im using linuxmint 14 and HUAWEI EC1261-2 (EVDO)

unkown interface error
it says unknown interface wlan1 [fail]
.....phone detects the network but gets stuck during authentication, and then disabled, and keeps on trying...

stuck at # what to do please help

getting an error
here's the error i'm getting
Code:
SIOCSIFFLAGS: Operation not possible due to RF-kill
* Restarting DNS forwarder and DHCP server dnsmasq
dnsmasq: failed to create listening socket for 127.0.0.1: Address already in use
[fail]
net.ipv4.ip_forward = 1
Configuration file: /etc/hostapd.conf
Could not set interface wlan0 flags: Operation not possible due to RF-kill
nl80211: Failed to set interface wlan0 into AP mode
nl80211 driver initialization failed.
ELOOP: remaining socket: sock=4 eloop_data=0x8e20908 user_data=0x8e20e88 handler=0x807c5e0
ELOOP: remaining socket: sock=6 eloop_data=0x8e22ca0 user_data=(nil) handler=0x8086770
net.ipv4.ip_forward = 0
* Stopping DNS forwarder and DHCP server dnsmasq * (not running)

It doesn't work!
It's a pity!

Thanks
THANKS BRO IT REALLY WORKED LIKE A CHRAM!!!!! :highfive:

Thanks!

ogyct said:
As many of you know, most of our android(not only android) devices can't connect to ad hoc hotspots. There's a solution for win7/8 users to set up infrastructure hotspot on their laptop using software like connectify and so on. Ubuntu also allows to create wifi hotspot to share internet, but it will be ad hoc one.
So here's the guide how to set up infrastructure hotspot on ubuntu 12.04/12.10. Unlike some other methods described on the internet, this one will not break default network manager.
1. First of all you should make sure, that your wifi adapter supports infrastructure hotspots. If you used connectify on your windows system and it worked, skip this step.
open terminal and type: sudo lshw | less
find -network section and make sure that driver is ath5k or ath9k, this solution will only work for those drivers, but should fit the needs for the most laptop users.
2. We now need to install 2 additional tools to make out hotspot, 1st one is hostapd(hotspot server), 2nd one is dnsmasq(dns dhcp server)
in terminal type: sudo apt-get install hostapd dnsmasq
3. stop those services if started already, and prevent them from starting on system start up.
in terminal type:
sudo service hostapd stop
sudo service dnsmasq stop
sudo update-rc.d hostapd disable
sudo update-rc.d dnsmasq disable
4. Now we need to set up config files.
in terminal type: sudo gedit /etc/dnsmasq.conf
or sudo kate /etc/dnsmasq.conf if you use kde
add those lines to the config file
Code:
# Bind to only one interface
bind-interfaces
# Choose interface for binding
interface=wlan0
# Specify range of IP addresses for DHCP leasses
dhcp-range=192.168.150.2,192.168.150.10
5. hostapd config
in terminal type: sudo gedit /etc/hostapd.conf
and add those lines
Code:
# Define interface
interface=wlan0
# Select driver
driver=nl80211
# Set access point name
ssid=myhotspot
# Set access point harware mode to 802.11g
hw_mode=g
# Set WIFI channel (can be easily changed)
channel=6
# Enable WPA2 only (1 for WPA, 2 for WPA2, 3 for WPA + WPA2)
wpa=2
wpa_passphrase=mypassword
You can change ssid name and password for anything you want here. Current config will create hotspot named myhotspot with mypassword password.
6. Now create anywhere you want a file named start.sh
edit it with any text editor like this:
Code:
#!/bin/bash
# Start
# Configure IP address for WLAN
sudo ifconfig wlan0 192.168.150.1
# Start DHCP/DNS server
sudo service dnsmasq restart
# Enable routing
sudo sysctl net.ipv4.ip_forward=1
# Enable NAT
sudo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
# Run access point daemon
sudo hostapd /etc/hostapd.conf
# Stop
# Disable NAT
sudo iptables -D POSTROUTING -t nat -o ppp0 -j MASQUERADE
# Disable routing
sudo sysctl net.ipv4.ip_forward=0
# Disable DHCP/DNS server
sudo service dnsmasq stop
sudo service hostapd stop
You will probably need to change ppp0 in this to eth0 (or any other number which refers to your wired connection.
7. Last step. Now you can start your hotspot by starting our script. just run it using sudo sh
for me it looks like this sudo sh /home/ogyct/Desktop/start.sh because I have it on my desktop
I am not sure who is the author of this guide, I only translated it to english. But anyway if this helped, hit the thanks button. Good day
Click to expand...
Click to collapse
This is running awesome. Just one question. How do I stop the script?
I find disabling and enabling wifi works. But is there any other way?

Hi, this script works perfectly. I was having issues with ubuntu shared wifi not being visible with android.
Now the hard question. I have a box that is already acting as a router sharing ip with dnsmasq over eth1
i added a wifi card wlan0 and i want to share not only internet but also the services running on my box
the problem is this script uses a different ip range and i cannot access my nfs shares.
my network is 192.168.128.x and i have set up this script in other range.
Setting it up in 192.168.128.10x for instance will not work
Is it possible to make this wifi share part of my network?
regards.

worked !!!
ogyct said:
As many of you know, most of our android(not only android) devices can't connect to ad hoc hotspots. There's a solution for win7/8 users to set up infrastructure hotspot on their laptop using software like connectify and so on. Ubuntu also allows to create wifi hotspot to share internet, but it will be ad hoc one.
So here's the guide how to set up infrastructure hotspot on ubuntu 12.04/12.10. Unlike some other methods described on the internet, this one will not break default network manager.
1. First of all you should make sure, that your wifi adapter supports infrastructure hotspots. If you used connectify on your windows system and it worked, skip this step.
open terminal and type: sudo lshw | less
find -network section and make sure that driver is ath5k or ath9k, this solution will only work for those drivers, but should fit the needs for the most laptop users.
2. We now need to install 2 additional tools to make out hotspot, 1st one is hostapd(hotspot server), 2nd one is dnsmasq(dns dhcp server)
in terminal type: sudo apt-get install hostapd dnsmasq
3. stop those services if started already, and prevent them from starting on system start up.
in terminal type:
sudo service hostapd stop
sudo service dnsmasq stop
sudo update-rc.d hostapd disable
sudo update-rc.d dnsmasq disable
4. Now we need to set up config files.
in terminal type: sudo gedit /etc/dnsmasq.conf
or sudo kate /etc/dnsmasq.conf if you use kde
add those lines to the config file
Code:
# Bind to only one interface
bind-interfaces
# Choose interface for binding
interface=wlan0
# Specify range of IP addresses for DHCP leasses
dhcp-range=192.168.150.2,192.168.150.10
5. hostapd config
in terminal type: sudo gedit /etc/hostapd.conf
and add those lines
Code:
# Define interface
interface=wlan0
# Select driver
driver=nl80211
# Set access point name
ssid=myhotspot
# Set access point harware mode to 802.11g
hw_mode=g
# Set WIFI channel (can be easily changed)
channel=6
# Enable WPA2 only (1 for WPA, 2 for WPA2, 3 for WPA + WPA2)
wpa=2
wpa_passphrase=mypassword
You can change ssid name and password for anything you want here. Current config will create hotspot named myhotspot with mypassword password.
6. Now create anywhere you want a file named start.sh
edit it with any text editor like this:
Code:
#!/bin/bash
# Start
# Configure IP address for WLAN
sudo ifconfig wlan0 192.168.150.1
# Start DHCP/DNS server
sudo service dnsmasq restart
# Enable routing
sudo sysctl net.ipv4.ip_forward=1
# Enable NAT
sudo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
# Run access point daemon
sudo hostapd /etc/hostapd.conf
# Stop
# Disable NAT
sudo iptables -D POSTROUTING -t nat -o ppp0 -j MASQUERADE
# Disable routing
sudo sysctl net.ipv4.ip_forward=0
# Disable DHCP/DNS server
sudo service dnsmasq stop
sudo service hostapd stop
You will probably need to change ppp0 in this to eth0 (or any other number which refers to your wired connection.
7. Last step. Now you can start your hotspot by starting our script. just run it using sudo sh
for me it looks like this sudo sh /home/ogyct/Desktop/start.sh because I have it on my desktop
I am not sure who is the author of this guide, I only translated it to english. But anyway if this helped, hit the thanks button. Good day
Click to expand...
Click to collapse
Thank you.
Its worked successfully in Xperia J.

Worked in Linux Mint v15 (based on Ubuntu 13.04)
johnp

A little update, I am glad if this guide helped. but in case it didn't try this one http://www.webupd8.org/2013/06/how-to-set-up-wireless-hotspot-access.html. I didn't check this myself, but that script seems to be smart.

Related

[Q] XDMCP connection

Does anybody know of an app with which I can remotely control an UX desktop(XDMCP connection).
thank you
Is xdmcp a must? If not, android-vnc should do the job
Sent from my HDfied HTC Desire
I tried android vnc but I could not connect.
Thread moved to Q&A.
Connect androidvnc to linux xdmcp with multi user access via xinetd
I have finally accomplished this in Linux Mint 13
Step 1: install tightvncserver
sudo apt-get install tightvncserver
Step 2: install xinetd if not already installed
sudo apt-get install xinetd
Step 3: configure xinetd
sudo gedit /etc/xinetd.d/vnc-1
paste this into editor and save
service vnc-1
{
disable = no
socket_type =stream
protocol =tcp
wait =no
user =nobody
server =/usr/bin/Xvnc
server_args = :1 -inetd -query localhost -geometry 1280x800 -depth 16 -once -rfbport 5901
# the server_args value may need -securitytypes=none
# to stop the remote vncviewer being prompted for a vnc
# password instead of the MDM Login prompt.
}
Step 4: Add the service
paste this at the bottom of the list above the #Local Services mark
vnc-1 5901/tcp # vnc session 1
Step 5: Configure xdmcp on host computer
under the menu -> Administration -> Login Window
under general tab uncheck Disable multiple logins for a single user
under remote tab select same as local
then hit the button saying configure xdmcp
make sure there it is check marked
under security tab uncheck deny tcp connections to Xserver
and in permissions i would allow all access
reboot and connect your vnc client

[Q] Problem with OpenVPN (interface stays down; clears routing table)

Been trying to get OpenVPN to work properly and have not had much luck.
Here are my specs.
HTC Incredible
Virtuous v3.1.0
2.6.32-Hydra-ssuv-v05
OpenVPN binary has been installed. I have also install busybox and then softlinked ifconfig and route to the commands the same way CM6 has it.
I was able to get OpenVPN to work properly within CM6 without much hassle. I have found battery life and experience better for me with Virtuous ROM so I went back to it.
When I launch the connection to establish the VPN session it connects but I am not able to work within the network. I was not able to communicate even with the VPN server.
I ran a netcfg and discovered that tap0 was down. I brought it up but its routing table was empty. I filled it in and was able to communicate with the VPN server and my advertised networks. If I drop my VPN connection, tap0 goes down and the routing table is cleared.
The VPN server works. It works with my other boxes and worked with this phone under CM6.
Does anyone have any ideas on fixing this issue? It makes my job much easier and I really do not want to go back to CM6. Thank you and I look forward to an answer.
Well, still looking for a good solution to the above problem. I have created a simple script to fix the routing table.
#!/system/bin/sh
## Script to fix routing
netcfg tap0 up
ifconfig tap0 192.168.x.x 255.255.255.x
route add -net 192.168.x.x netmask 255.255.255.x gw 192.168.x.x dev tap0
DNS doesn't work either right now but I can live with that temporarily.
If anyone has any ideas I would greatly appreciate it.
Still having problems with OpenVPN. It works with the script I wrote but personally I believe it should be able to do it without the script. I would greatly appreciate any feedback, even if it is just to point me in the right direction.
Here is logcat for OpenVPN
D/OpenVPNDaemonEnabler( 9595): Received OpenVPN daemon state changed from Unknown to Disabled
D/OpenVPNDaemonEnabler( 9595): Received OpenVPN network state changed from Connected to Exiting
E/OpenVPN-DaemonMonitor[/sdcard/openvpn/albatross-client.conf]-mgmt( 9595): attaching to OpenVPN daemon: /127.0.0.1:41079 - Connection refused
D/OpenVPNDaemonEnabler( 9595): Received OpenVPN daemon state changed from Unknown to Startup
D/OpenVPN-DaemonMonitor[/sdcard/openvpn/albatross-client.conf]-daemon( 9595): invoking command line: /system/xbin/openvpn --cd '/sdcard/openvpn' --config 'albatross-client.conf' --writepid '/data/data/de.schaeuffelhut.android.openvpn/files/com.d/_sdcard_openvpn_albatross-client.conf-pid' --script-security 1 --management 127.0.0.1 40158 --management-query-passwords
D/OpenVPNDaemonEnabler( 9595): Received OpenVPN daemon state changed from Unknown to Disabled
D/su ( 9894): 10075 de.schaeuffelhut.android.openvpn executing 0 /system/bin/sh using shell /system/bin/sh : sh
D/OpenVPN-DaemonMonitor[/sdcard/openvpn/albatross-client.conf]-daemon-stdout( 9595): Sat Nov 20 22:07:27 2010 OpenVPN 2.1.1 i686-pc-linux-gnu [SSL] [LZO2] [EPOLL] built on Feb 2 2010
D/OpenVPN-DaemonMonitor[/sdcard/openvpn/albatross-client.conf]-daemon-stdout( 9595): Sat Nov 20 22:07:27 2010 NOTE: OpenVPN 2.1 requires '--script-security 2' or higher to call user-defined scripts or executables
V/OpenVPN-DaemonMonitor[/sdcard/openvpn/albatross-client.conf]-mgmt( 9595): Successfully attached to OpenVPN monitor port
D/OpenVPNDaemonEnabler( 9595): Received OpenVPN daemon state changed from Unknown to Enabled
D/OpenVPNDaemonEnabler( 9595): Received OpenVPN network state changed from Unknown to Connecting
D/OpenVPN-DaemonMonitor[/sdcard/openvpn/albatross-client.conf]-mgmt( 9595): >INFO:OpenVPN Management Interface Version 1 -- type 'help' for more info
D/OpenVPNDaemonEnabler( 9595): Received OpenVPN network state changed from Connecting to Unknown
D/OpenVPNDaemonEnabler( 9595): Received OpenVPN network state changed from Unknown to Wait
D/OpenVPNDaemonEnabler( 9595): Received OpenVPN network state changed from Wait to Auth
D/OpenVPNDaemonEnabler( 9595): Received OpenVPN network state changed from Auth to Get Config
D/OpenVPNDaemonEnabler( 9595): Received OpenVPN network state changed from Get Config to Connected
D/su ( 9917): 10075 de.schaeuffelhut.android.openvpn executing 0 /system/bin/sh using shell /system/bin/sh : sh
D/su ( 9920): 10075 de.schaeuffelhut.android.openvpn executing 0 /system/bin/sh using shell /system/bin/sh : sh
Based on what I see, it looks like OpenVPN is attempting to use loopback for its connection. By the time the whole process is completed, Tap0 is still down and not up and it takes my script to re-enable.
I have placed this discussion on Android Forums as well and have not gotten any response. I am sure there is someone a lot smarter than me that can at least point me in the right direction. Thank you!

[SOLVED] OpenVPN Full Tunnel

Short Version:
Got an OpenVPN server on my NAS. GN connects & works fine; remote resources are reachable. I now want to know how I can route all traffic through the tunnel. (Is this possible?)
Long Version:
For those times when I'm traveling (domestically and internationally) and/or using a questionable Internet connection, I'd like to secure the connection.
I've got a [stock] rooted GN running Jelly Bean with BusyBox installed. My NAS has two built-in VPN solutions one of which being OpenVPN so I got that setup which created an .ovpn file containing the following configuration:
Code:
dev tun
tls-client
remote YOUR_SERVER_IP 1194
# The "float" tells OpenVPN to accept authenticated packets from any address,
# not only the address which was specified in the --remote option.
# This is useful when you are connecting to a peer which holds a dynamic address
# such as a dial-in user or DHCP client.
# (Please refer to the manual of OpenVPN for more information.)
#float
# If redirect-gateway is enabled, the client will redirect it's
# default network gateway through the VPN.
# It means the VPN connection will firstly connect to the VPN Server
# and then to the internet.
# (Please refer to the manual of OpenVPN for more information.)
#redirect-gateway
# dhcp-option DNS: To set primary domain name server address.
# Repeat this option to set secondary DNS server addresses.
#dhcp-option DNS DNS_IP_ADDRESS
pull
proto udp
script-security 2
ca ca.crt
comp-lzo
reneg-sec 0
auth-user-pass
After installing OpenVPN Installer & OpenVPN Settings, I had to manually symlink busybox, ifconfig, and route from /system/bin to /system/xbin in order for OpenVPN to run properly.
Code:
#Note: In an attempt to be thorough, and for any Googlers or forum searchers (+1)...
#First I had to mount /system as read/write via:
mount -o -rw,remount /system
#Then create the symlinks via:
ln -s /system/bin/busybox /system/xbin/busybox
ln -s /system/bin/ifconfig /system/xbin/ifconfig
ln -s /system/bin/route /system/xbin/route
#Then remount /system as read-only via:
mount -o ro,remount /system
Once all of the above was setup, I initiated the connection, successfully authenticated, and was able to reach remote resources without issue.
What I would like to do at this point is get it setup so that I can have a second profile that routes all traffic through the VPN. I assume its a client-side configuration change but I really don't know at this juncture.
Many thanks!
Doesn't CyanogenMod ROM have native OpenVPN support? I think the OpenVPN client on CM has an option to route all traffic through the VPN. I think for what you want to do you should need a custom ROM or kernel that supports iptables.
iptables is a system file that allows the system to redirect network traffic usually for apps like tethering, firewalls, and proxies.
Sent from my Galaxy Nexus using Tapatalk 2
Thanks for taking the time to reply KemikalElite.
I've got BusyBox 1.20.2 installed and I do have an iptables binary (v1.4.11.1). With solutions like Hotspot Shield VPN that don't require root yet supports encryption for all traffic, I figured root + OpenVPN + BusyBox + iptables would be sufficient.
My initial assumption was that I would need to make some changes to my OpenVPN configuration to encrypt & route all traffic through the tunnel. But maybe I've been thinking about this all wrong and its less about OpenVPN and more about running a custom script once connected to route everything through the tunnel; and vice versa when I disconnect to restore the original configuration.
Perhaps I should be scouring OpenVPN forums?
Phylum said:
Thanks for taking the time to reply KemikalElite.
I've got BusyBox 1.20.2 installed and I do have an iptables binary (v1.4.11.1). With solutions like Hotspot Shield VPN that don't require root yet supports encryption for all traffic, I figured root + OpenVPN + BusyBox + iptables would be sufficient.
My initial assumption was that I would need to make some changes to my OpenVPN configuration to encrypt & route all traffic through the tunnel. But maybe I've been thinking about this all wrong and its less about OpenVPN and more about running a custom script once connected to route everything through the tunnel; and vice versa when I disconnect to restore the original configuration.
Perhaps I should be scouring OpenVPN forums?
Click to expand...
Click to collapse
You have the tun module as well right?
code.google.com/p/android-openvpn-settings/issues/list
Check through some of those issues. Something did say that the DNS servers may need to be manually set.
OpenVPN is so complex because of the config options. I find it easier to use native PPTP connections since there's no config only authentication and it routes all traffic automatically.
Sent from my Galaxy Nexus using Tapatalk 2
You need to enter "redirect-gateway" into your ovpn config file.... Just remove the # in the your config
Thanks for the reply ZiCoN!
I should have mentioned this sooner - terribly sorry for omitting this.
Once I got the VPN connected, I did the old 'what is my ip' to verify the route. It was still using the provider's network, but I could reach my NAS and other remote devices in the 192.168.x.x range - so the VPN itself was working. After reading the mini explanation in the config file I enabled 'redirect-gateway' and after reconnecting I could no longer access the Internet. I checked the OpenVPN Manual I added 'def1' after the 'redirect-gateway' statement, reconnected but still no go: I can no longer access the Internet. Remote resources are still accessible in both scenarios.
KemikalElite said:
You have the tun module as well right?
code.google.com/p/android-openvpn-settings/issues/list
Check through some of those issues. Something did say that the DNS servers may need to be manually set.
OpenVPN is so complex because of the config options. I find it easier to use native PPTP connections since there's no config only authentication and it routes all traffic automatically.
Sent from my Galaxy Nexus using Tapatalk 2
Click to expand...
Click to collapse
I somehow missed this when drafting my last reply. I think you're right about it being a DNS problem. I made a change to the config file (adding a few lines for 'dhcp-option DNS x.x.x.x') and within OpenVPN used the 'Fix DNS' button.
Thanks all for your time, thoughts, opinions and instructions!
Phylum said:
Thanks for the reply ZiCoN!
I should have mentioned this sooner - terribly sorry for omitting this.
Once I got the VPN connected, I did the old 'what is my ip' to verify the route. It was still using the provider's network, but I could reach my NAS and other remote devices in the 192.168.x.x range - so the VPN itself was working. After reading the mini explanation in the config file I enabled 'redirect-gateway' and after reconnecting I could no longer access the Internet. I checked the OpenVPN Manual I added 'def1' after the 'redirect-gateway' statement, reconnected but still no go: I can no longer access the Internet. Remote resources are still accessible in both scenarios.
Click to expand...
Click to collapse
You probably need to allow traffic to route back along the vpn film the internet. On your gateway, route vpn addresses to the VPN server and make sure forwarding is enabled on the vpn server.
Questions go in Q&A
Read forum rules and stickies before posting
Thread moved
FNM

How do you specify a mac address for wlan0 on CM 12.1?

Is there a way to "permanently" set the mac address of wlan0 to something of my choosing? I have been able to do this temporarily through ADB and with busybox, but it does not always work. I want to have a specific mac address on wlan0 for when I use my phone as a hotspot for portable gaming devices. I have google's this, and it seems at least in previous versions of CM, this was stored in a file and could be changed, but I cannot find that file on the build I am running (CM 12.1-20150705-NIGHTLY). Does anyone know how to do this? Currently, I have to enable the hotspot, use ADB cli like:
# busybox ifconfig wlan0 down
# busybox ifconfig hw ether 00:11:22:33:44:55
# busybox ifconfig wlan0 up
# busybox ip link show wlan0
If I check the mac address after this, sometimes it changes, sometimes it does not. And sometimes when "ip link" reports the changed mac, it is not really changed (I check with other devices and they still see the old mac). But it does work... sometimes (rarely.. but I have had it working). I'd really like to make this more permanent.
I have looked in /data/misc/wifi but I don't see any nvram file in there anymore where I think you used to be able to set it.
This thread may help you. http://forum.xda-developers.com/showthread.php?t=2286440 I haven't tried it myself but a friend of mine said it worked for him.

VPN + Wifi Tethering = Extremely Slow

I have a vpn service that I connect to on a regular basis. I want to wifi tether to two other android devices with this VPN connection. However, when I have the VPN connected and wifi tether on my G4, the clients connect at a VERY slow rate (>1 kb/s). I can't even pull up a Google in Chrome because it's so slow.
I have seen on the interwebs that I need to run some iptables commands like so...
Code:
iptables -t filter -F FORWARD
iptables -t nat -F POSTROUTING
iptables -t filter -A FORWARD -j ACCEPT
iptables -t nat -A POSTROUTING -j MASQUERADE
But this has no effect. I think these procedures might be a little outdated since we are on 5.1. Does anyone know of a VPN+Tether procedure that works on our G4's?
Bump
Solved!
NOTE: This required root access
1. Install WiFi Tether Router from the Play Store ($2.80)
2. Configure WiFi Tether Router like so:
Code:
Interface wlan0
Method 2
Channel 1
Encryption wpa2-psk (Don't forget to set password)
"No Firmware Reload" <- UNCHECKED
3. Connect to your VPN (I used the stock G4 settings)
4. Enable Wifi Tether Router (Asks for Root)
5. Enjoy!
All clients that connect to your G4 via Wifi Tether Router should now be within the VPN. You can check this by going to http://whatismyipaddress.com/

Categories

Resources