[Q] Problem with OpenVPN (interface stays down; clears routing table) - Droid Incredible Q&A, Help & Troubleshooting

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!

Related

The Connection refused problem with transplantation of wifi

I write a android program to control wifi with java code.The app catch the necessary informations like 'ssid' or 'password',and send them to the 'wpa' to start the wifi network.There are some native methods to achieve functional,and the app call them with JNI.
At first,when calling the wifi_start_supplicant(in wifi.c) method there are some logs show " Cannot set RW to "/data/misc/wifi/wpa_supplicant.conf': Permission denied '.First I just give the wpa_supplicant.conf 777 permission,but the error was still happened.Then I all the folder on the Path 777 permission,the error disappeared after that.
But there's another error came: Failed to start supplicant daemon. No such file or directory.Then I search the source code of android 4.0.1.r1,and find that there's a code segment(in wifi.c):pi = __system_property_find(SUPP_PROP_NAME);and the SUPP_PROP_NAME is " init.svc.wpa_supplicant ".I found the init.svc.wpa_supplicant is a service,so I use the adb shell to set it "running" with command "setprop init.svc.wpa_supplicant 'running'"before I run the program.After this step the error was disappear.
But there's a new error came,logs show: Unable to open connection to supplicant on "/data/system/wpa_supplicant/wlan0": Connection refused.And I find some ways to solve this problem on the link:
blog.linuxconsulting.ro/2010/04/porting-wifi-drivers-to-android. html
I follow all the steps on this link,except so change about the wifi.c,because compiled the wifi.c will get a libhardware_legacy.so,and this so file will crash my phone while it push into /system/lib.
I try both android private socket and unix standard socket to connect to supplicant,but all I try just had a same result: Unable to open connection to supplicant on "/data/system/wpa_supplicant/wlan0": Connection refused
In this step I make sure the wap_supplicant and dhcpcd were starting from init.rc with the interface of wlan0,and setprop the wifi.interface as "wlan0".I had seen the file in /proc/net/dev,and I sure the wlan0 is mark on the file(dev).
Above is all my work and procedure with my transplantation of wifi,the problem of"Unable to open connection to supplicant .... Connection refused " is still confused me,is there some ways can solve that?
Thanks a lot anyway!
Any updates
Hi, were you able to find the cause of this problem. I am facing the similar issue now.
Thanks

[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

[GUIDE] Making infrastructure wifi hotspot on ubuntu 12.04/12.10

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.

[Q] OpenVPN Connect setup

Hi
I've got a paid VPN from ProXPN and I'm trying to set it up on my HTC One X using the official OpenVPN Connect app.
Copied my *.ovpn, *.crt and *.key files over from my laptop to the device, but get the following error:
"Error Parsing OpenVPN profile : ProXPN.ovpn : option_error: remote option not specified"
Does anyone know what I'm doing wrong, please?
Thanks
Rob
P.S. Not a huge issue if I can't get it working, as I'll just use the built-in VPN via pptp, but hopefully I'll be able to sort this out.
Rushey_Platt said:
Hi
I've got a paid VPN from ProXPN and I'm trying to set it up on my HTC One X using the official OpenVPN Connect app.
Copied my *.ovpn, *.crt and *.key files over from my laptop to the device, but get the following error:
"Error Parsing OpenVPN profile : ProXPN.ovpn : option_error: remote option not specified"
Does anyone know what I'm doing wrong, please?
Thanks
Rob
P.S. Not a huge issue if I can't get it working, as I'll just use the built-in VPN via pptp, but hopefully I'll be able to sort this out.
Click to expand...
Click to collapse
Judging by the error message I would say that your config file contains a typo or the line that specifies the remote address to connect to is missing or misformed.
http://openvpn.net/index.php/open-source/documentation/manuals/65-openvpn-20x-manpage.html
# The hostname/IP and port of the server.
# You can have multiple remote entries
# to load balance between the servers.
remote my-server-1 1194
Click to expand...
Click to collapse
And http://openvpn.net/index.php/open-source/documentation/howto.html#examples
Obviously you cannot copy paste the examples . Can you not get a ready made ovpn config file from those ProXPN dudes?
If this config file contains no sensitive information you could post it here for a quick syntax check?
pakjebakmeel said:
If this config file contains no sensitive information you could post it here for a quick syntax check?
Click to expand...
Click to collapse
I don't think any of this is sensitive (hopefuly!) so here it is:
Code:
client
dev tun
proto tcp
resolv-retry infinite
nobind
persist-key
persist-tun
ca ssl/ca.crt
cert ssl/client.crt
key ssl/client.key
cipher BF-CBC
keysize 512
comp-lzo
verb 4
mute 5
tun-mtu 1500
mssfix 1450
auth-user-pass
reneg-sec 0
route-method exe
route-delay 1 10
route-metric 512
route 0.0.0.0 0.0.0.0
# If you are connecting through an
# HTTP proxy to reach the actual OpenVPN
# server, put the proxy server/IP and
# port number here. See the man page
# if your proxy server requires
# authentication.
;http-proxy-retry # retry on connection failure
;http-proxy [proxy server] [proxy port #]
So yes, you're missing the 'remote' statement in your config file.. Client doesn't know to which server it has to connect if this line is omitted.
That explains.
Also, this config looks like a config for a Windows client. Can you not just use a prefab config file for linux?
Think this is what you're on about: http://www.proxpn.com/ ?
I don't know this service but maybe use something like this: http://downgoat.net/2013/04/20/proxpn-openvpn-on-linux-configuration/
client
dev tun
proto tcp
remote uk.proxpn.com 443
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert client.crt
key client.key
cipher BF-CBC
keysize 512
comp-lzo
verb 3
mute 5
tun-mtu 1500
mssfix 1450
auth-user-pass
reneg-sec 0
redirect-gateway def1
Click to expand...
Click to collapse
Also, it uses this config to connect to VPN but you still need to provide a username and password because of the auth-user-pass statement. I've not seen this option in my Android client but maybe it appears on the connection preferences when it sees this statement? Or maybe it will ask you upon connecting.. Not sure but try this and see if you get an option to configure username and pass or whether it asks you upon connecting..
Make sure the ca.crt, client.crt and client.key files are in the same folder as the ovpn config file. I use /sdcard/openvpn.
If you get stuck enable logging on the connection and post that. (AFTER YOU HAVE REMOVED ANY SENSITIVE INFORMATION).
Great, thanks, that tip enabled me to successfully import the linux-based profile.
After import I was indeed asked for a username and password, and then it connected to ProXPN. However, it then got stuck in some sort of connect / disconnect loop, with the disconnect message disappearing so fast I can't actually read what it says!
Rob
Rushey_Platt said:
Great, thanks, that tip enabled me to successfully import the linux-based profile.
After import I was indeed asked for a username and password, and then it connected to ProXPN. However, it then got stuck in some sort of connect / disconnect loop, with the disconnect message disappearing so fast I can't actually read what it says!
Rob
Click to expand...
Click to collapse
Enable logging, that's what it's for.
Some loops are terminating because of session invalidated; others because of a transport error.
Rushey_Platt said:
Some loops are terminating because of session invalidated; others because of a transport error.
Click to expand...
Click to collapse
Maybe if you post the full log file we can see what's happening. As I don't know what the correct settings should be for this provider it makes it harder to troubleshoot.

Permanent tun0 interface mtu

Hello,
I had a problem - when I connect through VPN to the office I couldn't open some intranet pages, I understood where the problem come from - from the MTU of the tu0 interface.
So I changed the MTU via this command: "ifconfig tun0 mtu 1360", so everything is OK, but when I disconnect and reconnect the VPN - the MTU of the tun0 interface is again 1500, this is because ifconfig change the mtu in /sys/devices/virtual/net/tun0/mtu, but when vpn is disconnected this folder is removed and when connect again - new folder is created might be from template of preset of settings.
So my question is where can I change mtu of the tun0 interface so that it will be permanent even after restart.
Thanks in Advance!

Categories

Resources