What makes us different from other similar websites? › Forums › Tech › Guide: Sharing Android Phone VPN to Linux PC
Tagged: android, Guide, Hotspot, How to, Internet, Linux, Mobile, Network Configuration, Privacy, Proxy, Security, Tutorial, VPN, VPN Sharing, Xubuntu
- This topic has 0 replies, 1 voice, and was last updated 1 month, 3 weeks ago by
thumbtak.
-
AuthorPosts
-
July 10, 2025 at 11:14 am #8139
thumbtak
ModeratorGuide: Sharing Android Phone VPN to Linux PC via Proxy
Ever wanted to share your phone’s VPN connection with your Linux computer, perhaps for privacy on public Wi-Fi or to access geo-restricted content? While direct sharing isn’t usually possible, you can achieve this by setting up a proxy server on your Android phone and configuring your Linux machine to use it. This guide focuses on using an app like “VPN Share” on Android to route its traffic through this proxy.
Disclaimer: This method routes your computer’s internet traffic through your phone. Expect some potential performance overhead and increased battery drain on your phone. Not all applications may fully respect proxy settings.
—
Part 1: Setting up the VPN Share & Hotspot on your Android Phone
1. Install “VPN Share” app:
- On your Android phone, download and install “VPN Share” from the Google Play Store.
- Link: VPN Share on Google Play
- (Alternative: Every Proxy on Google Play can also work similarly).
2. Activate your Phone’s VPN:
- Before proceeding, ensure your phone’s main VPN is active and connected. This is crucial, as “VPN Share” will route traffic through this existing VPN tunnel.
3. Start Phone Hotspot:
- Go to your phone’s Settings > Network & internet > Hotspot & tethering > Wi-Fi hotspot.
- Turn on the Wi-Fi hotspot. Make a note of the Hotspot Name (SSID) and Password.
4. Configure VPN Share:
- Open the “VPN Share” app.
- Find and enable the option to “Start Server” or “Share VPN Over Hotspot”.
- The app will display a Local IP Address (e.g.,
192.168.x.x
or172.x.x.x
) and a Port Number (e.g.,8080
,8888
). Write these two pieces of information down carefully!
—
Part 2: Configuring your Computer
Since Some graphical network settings don’t offer direct manual proxy configuration per connection, we’ll use system-wide environment variables.
1. Connect Computer to Phone Hotspot:
- On your computer, connect to the Wi-Fi hotspot network you just created on your phone (using the SSID and password you noted).
2. Set System-Wide Proxy Environment Variables:
- Open a terminal (
Ctrl + Alt + T
). - Edit the
/etc/environment
file (this sets variables for all users and processes upon login). Since this is a system file, you’ll usesudo
withmousepad
(or any text editor) to open it with administrative privileges:
$ sudo mousepad /etc/environment
- At the end of the file, add the following lines. Replace
YOUR_PHONE_IP
andYOUR_PROXY_PORT
with the IP and Port from the “VPN Share” app!http_proxy="http://YOUR_PHONE_IP:YOUR_PROXY_PORT/" https_proxy="http://YOUR_PHONE_IP:YOUR_PROXY_PORT/" ftp_proxy="http://YOUR_PHONE_IP:YOUR_PROXY_PORT/" HTTP_PROXY="http://YOUR_PHONE_IP:YOUR_PROXY_PORT/" HTTPS_PROXY="http://YOUR_PHONE_IP:YOUR_PROXY_PORT/" FTP_PROXY="http://YOUR_PHONE_IP:YOUR_PROXY_PORT/"
- Save the file (usually
Ctrl + S
in Mousepad) and close the editor.
3. Configure Proxy for
apt
(Package Manager):apt
needs its own proxy configuration. Create a new file:
$ sudo mousepad /etc/apt/apt.conf.d/99proxy
- Add these lines (again, replace with your IP and Port):
Acquire::http::Proxy "http://YOUR_PHONE_IP:YOUR_PROXY_PORT/"; Acquire::https::Proxy "https://YOUR_PHONE_IP:YOUR_PROXY_PORT/"; Acquire::ftp::Proxy "ftp://YOUR_PHONE_IP:YOUR_PROXY_PORT/";
- Save the file and close the editor.
4. Apply Changes (Crucial!):
- You must log out of your Xubuntu session and log back in, or reboot your computer, for these system-wide changes to take effect.
5. Verify:
- After logging back in, open a web browser on your Linux machine and visit
https://www.whatismyip.com/
. - The IP address shown should be the exact same public IP address that your phone displays when its VPN is active. This confirms your computer’s traffic is going through your phone’s VPN!
—
Part 3: How to Reverse/Remove the Proxy Settings (Crucial!)
When you no longer want to route your computer’s traffic through your phone’s proxy, you must undo these changes. Simply disconnecting your phone or turning off the app will lead to your computer losing internet access because it will still be trying to reach a non-existent proxy.
Choose one of these methods to reverse the changes:
Option A: Completely Remove Proxy Settings (Recommended for a clean slate)
1. Remove Proxy from
/etc/environment
:- Open a terminal:
$ sudo mousepad /etc/environment
- Delete the
http_proxy
,https_proxy
,ftp_proxy
(both lowercase and uppercase) lines you added. - Save and close the editor.
2. Remove Proxy for
apt
:- Delete the
apt
proxy configuration file. This command will directly remove the file:
$ sudo rm /etc/apt/apt.conf.d/99proxy
(If you named the file something other than99proxy
, use that name instead.)
3. Apply Changes:
- Reboot your computer.
Option B: Comment Out Proxy Settings (Good if you might re-enable later)
1. Comment Out Proxy in
/etc/environment
:- Open a terminal:
$ sudo mousepad /etc/environment
- Add a
#
(hash symbol) at the beginning of each proxy line:#http_proxy="http://YOUR_PHONE_IP:YOUR_PROXY_PORT/" #https_proxy="http://YOUR_PHONE_IP:YOUR_PROXY_PORT/" #ftp_proxy="http://YOUR_PHONE_IP:YOUR_PROXY_PORT/" #HTTP_PROXY="http://YOUR_PHONE_IP:YOUR_PROXY_PORT/" #HTTPS_PROXY="http://YOUR_PHONE_IP:YOUR_PROXY_PORT/" #FTP_PROXY="http://YOUR_PHONE_IP:YOUR_PROXY_PORT/"
- Save and close the editor.
2. Comment Out Proxy for
apt
:- Open the
apt
proxy file:
$ sudo mousepad /etc/apt/apt.conf.d/99proxy
- Add
//
(two forward slashes) at the beginning of each proxy line:// Acquire::http::Proxy "http://YOUR_PHONE_IP:YOUR_PROXY_PORT/"; // Acquire::https::Proxy "https://YOUR_PHONE_IP:YOUR_PROXY_PORT/"; // Acquire::ftp::Proxy "ftp://YOUR_PHONE_IP:YOUR_PROXY_PORT/";
- Save and close the editor.
3. Apply Changes:
- Reboot your computer.
After disabling, verify your internet access works normally and that
whatismyip.com
shows your regular public IP. Don’t forget to also stop the “VPN Share” app on your phone and disable your phone’s hotspot/VPN if you’re done with them!-
This topic was modified 1 month, 3 weeks ago by
thumbtak. Reason: Make sure that when you remove (or commenting out) the settings, to do a full reboot. Log out and login will leave some connections left over
-
AuthorPosts
- You must be logged in to reply to this topic.