I have installed Raspbian OS and enabled vnc through lan cable.(headless setup)[there is no internet on my LAN] both PC & Pi are connected to my router. When I connect my Raspberry Pi's (wifi) to a mobile hotspot (my phone) Raspberry Pi is connected to phone's wifi hotspot but internet is not available on the Pi.

But when I remove the lan cable and only connect the Pi's wifi to phone's hotspot internet seems to be working fine.

How can I setup to use my Pi's wifi (internet access) to download files and store it on a local NAS server(through LAN)?

Any help would be appreciated as i'm new to Linux

  • There should be no problem with the pi connecting to the internet first time. Are you trying to connect the pi to your network (LAN) and wifi hotspot at the same time? There could be a conflict of IP addresses between your hotspot and LAN which can cause problems. Commented Mar 8, 2018 at 21:31
  • No there can not be a address conflict, the WiFi and LAN has different MAC addresses! It is a matter of routing and metrics.
    – MatsK
    Commented Mar 9, 2018 at 7:27
  • MAC addresses are always unique unless you spoof them. And totally unrelated in this context. They should never be confused with IP addresses. And don't confuse them with Linux network devices. Having 2 IP addresses in the same IP subnet but different physical networks causes much hilarity and is supprisingly common on 192.168.1.x. though you might be correct about the default gateway being the issue Commented Mar 9, 2018 at 8:01
  • Please post the output from route -n
    – MatsK
    Commented Mar 9, 2018 at 14:51

2 Answers 2


When you have two interfaces connected the routing table is deciding what interface to send out the trafic through.check the routing table with:

route -n

By removing the default gateway (example 192.168.nnn.nnn) from the LAN configuration, your routing table for (Internet) there will be no rute to internet trough the LAN only via WiFi.

sudo route delete default gateway 192.168.nnn.nnn

The other way is to change the metric for the route so that the route via LAN has a higher metric than the one for the WiFi.

To make the router taböle permanent check out How to make a change to the routing table persist?

  • Removing the route to LAN that is without internet, that is the only viable solution.
    – MatsK
    Commented Mar 9, 2018 at 14:50
  • ... assuming that's the problem yes. However your use of English wasn't clear. I've proposed an edit to clarify. Commented Mar 9, 2018 at 16:25

This is modified version of MatsK answer. First confirm your default gateway is through the ethernet with just plain route. It will probably include this:

default  gateway  UG  0   0   0  eth0

First remove that with sudo route del default. Then, if the phone's hotspot IP is, use:

sudo route add default gw dev wlan0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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