1

Note:- I've found out that to achieve what I want, there is a simpler, more flexible way than reverse tethering. If you are ever in my situation, read the answer below.

I reverse tether internet from laptop via USB, and wan't to share it further by creating an Hotspot on my rooted android phone.

I get internet not just on my browser, but everywhere including Play Store and Whatsapp, when I reverse thether it from my laptop via USB.

The only issue is that when I start a WiFi hotspot on my phone so that other devices can share this internet, they don't get internet. How do I fix this?

Here is the commands I used to set up my phone to accept internet from my laptop:

ifconfig rndis0 10.42.0.2 netmask 255.255.255.0
route add default gw 10.42.0.1 dev rndis0
ifconfig ccmni0 0.0.0.0

Where ccmni0 is my Mobile Data interface and rndis0 is the interface from which I get internet.

Why I want to do this is irrelevant to the question, but read on if you want to.

The reason for doing all this is that me and my room mate has to share a single LAN cable. Both of us run linux and have Broadcom WiFi cards, whose linux drivers don't allow you to create an AP from the laptop. I have linux only, while my friend uses linux only at times. When he is on Windows he creates a WiFi AP from his laptop using connectify. But when he is on linux, I want to temporarily create a hotspot via by mobile to share the internet.

  • You can use Connectify software to use your Laptop to create wifi-hotspot so that other devices including your mobile phone can access internet. – Lucky Aug 13 '15 at 13:09
  • @Lucky, if you read the question again, I am using Linux for which connectify is not available. But that is not the problem. You don't even need an external software to create a hotspot in linux. The problem with that is that is that, as I said, my driver does not support creating APs. – daltonfury42 Aug 13 '15 at 13:30
1

Although this does not specifically answer my question, I solved my problem. What I wanted to do is to share my internet with my friend via WiFi using my android mobile because my Linux powered laptop doesn't have driver support for creating WiFi APs. Broadcom sucks!

I use my mobile phone to create a WiFi network(via hotspot), connect my laptop (source of internet) and other devices that require internet to the network. Now I configure my laptop to be a gateway and configure other devices to use my laptop as gateway.

Here is the guide I followed. Lucky for me, I run Arch Linux. But this should work even if you are on some other linux distro like Ubuntu. So here it goes:

  1. Start hotspot on your mobile and connect the laptop which has internet and the device which needs internet connection.

  2. Create a script named start-gateway.sh with the following content.

    #!/bin/bash
    sysctl net.ipv4.ip_forward=1 
    iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE 
    iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
    

The script assumes that the interface which has internet is eth0 and you need to forward packets from wlan0 (your WiFi interface) to your Ethernet connection. So please confirm if these are the names of the interfaces from ifconfig output.

  1. Make the script executable and you are done:

    chmod u+x start-gateway.sh

Whenever you need to start the gateway, execute the script with root privileges when connected to the WiFi:

sudo ./start-gateway.sh

Now all you have to do to get internet on other devices connected to the WiFi is to set the manually set IP configuration on those devices, giving the gateway as the IP address of your new gateway. Remember that by default the gateway will be the phone which is hosting the WiFi network(which has no internet), and you need to change the gateway to the one you have created.

  • How can I give "the gateway as the IP address of your new gateway"? Please explain maybe how to do it on Windows. – brijs Jan 26 '17 at 10:57
  • @brijs In you windows machine the "Default Gateway" should be set to the IP of the machine which has internet. (The machine on which you ran the script) – daltonfury42 Jan 26 '17 at 13:35
1

Posting as an answer to @daltonfury42 as I do not have enough reputation to do that under his answer.
I also have the following adapter:
:~$ lspci -nn -d 14e4:
08:00.0 Network controller [0280]: Broadcom Corporation BCM43142 802.11b/g/n [14e4:4365] (rev 01)
I was trying to create access point (AP) from my laptop but as the author states: "Broadcom sucks!"

My 2 cents of worth in this comment is what it took me a lot of time to do - set the correct DNS and gateway settings.
My setup:

  • Laptop (connected to internet via LAN cable) [Dell Vostro 3560, Ubuntu 16.04 LTS)
  • Tablet (serving as an access point / hotspot. Both the laptop and the smartphone should be connected to this hotspot) [Samsung Galaxy Note 10.1 GT-N8000, Android 4.4.2]
  • Smartphone (which should receive the internet access) [Lenovo Vibe P1a42, Android 6.0.1]

Now to elaborate on: "Now all you have to do to get internet on other devices connected to the WiFi is to set the manually set IP configuration on those devices, giving the gateway as the IP address of your new gateway. Remember that by default the gateway will be the phone which is hosting the WiFi network(which has no internet), and you need to change the gateway to the one you have created."

On my smartphone I connected to the hotspot / Tablet via wi-fi. After you have connected to the hotspot, initially you have no internet. You need to edit the newly created connection's details on the smartphone as following:

  • "IP Settings" - change from the dropdown from "DHCP" to "Static".
  • Leave the "IP Address" untouched (we will reuse it)
  • Change the gateway to the IP address of the laptop's (server) WLAN interface IP. You can find it after you run "ifconfig" in the terminal on the laptop.
  • For DNS you can use any of the following addresses: "8.8.8.8", "8.8.4.4", "185.121.177.177", "185.121.177.53" (more info on: https://wiki.archlinux.org/index.php/Resolv.conf)

Just tap on OK and your smartphone now should be using the correct gateway and DNS settings and you should have internet.
I hope this will save other people some time :)

0

Android phones are designed to manage one WiFi connection at a time. If you have connected your phone to the laptop and want the phone to serve as a hotspot, it would have to manage two WiFi connections (one to the laptop, one as hotspot). This is not possible out-of-the-box. There is, however, an app called FQRouter2 for rooted Android devices which claims to be able to do just that.

More information can be found here, for example.

Update: I have seen your comment.

The problem seems to be that the mobile is not able to route the traffic properly from its WiFi connection to the USB connection.

This raises the question why you do not use the laptop directly as a hotspot. This feature is available in Ubuntu's network settings. However, problems have been reported with Android mobile devices. They do not recognize Ubuntu's built-in hotspot.

Here is how to solve that:

At first, install ap-hotspot:

sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install ap-hotspot

Once ap-hotspot is installed, the further steps should be rather easy. ap-hotspot is controlled via command-line. To start the hotspot (there will be a configuration procedure at very first start)

sudo ap-hotspot start

To (re-)configure the hotspot:

sudo ap-hotspot configure

To stop the hotspot:

sudo ap-hotspot stop

A detailed description of ap-hotspot can be found here. It is also very interesting to read through the comments on that page.

Kind regards.

  • Sorry for not being clear in the question, but I reverse tether internet from laptop via USB, and wan't to share it via WiFi. So this issue does not affect me. – daltonfury42 Aug 13 '15 at 12:20
  • Again this answer is completely useless as it does not answer the question(if you want to suggest an alternative, leave a comment). I've mentioned that I don't have driver support for creating APs from linux. – daltonfury42 Aug 25 '15 at 17:01

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.