How to Share VPN Internet as a Wi-Fi Hotspot on Linux?

Hello everyone,

I’m looking for a way to share my internet, which is connected via VPN, as a Wi-Fi hotspot on Linux (endeavor Linux). My goal is to share the VPN internet with other devices, such as my mobile phone, through a Wi-Fi hotspot.

Here are the details:

My wireless interface is wlan0.
My VPN is active on the ppp0 interface.
When I run the create_ap command, I encounter errors like “invalid arithmetic operator” and “Your adapter can not transmit to channel 0”.
Question: What methods are available to share VPN internet as a Wi-Fi hotspot?

I’d appreciate it if anyone with experience in this area could offer some help.

I’m not aware of your entire network set up, but it sounds like it would be easier to set up the VPN on your router and then connect to it on wifi with your phone and let it route the traffic through the VPN. If that’s not an option, it’s like that what you are trying to do is possible (assuming you have the right hardware), but it’s not something I’ve ever done myself.

1 Like

Network Manager. Create or edit a connection, then change the mode to Hotspot.

More info here: https://nixsanctuary.com/how-to-share-vpn-connection-using-ethernet-and-wi-fi-on-linux/
And here: https://www.linuxquestions.org/questions/linux-networking-3/how-to-set-up-vpn-hotspot-in-linux-4175724729/
Here too: https://protonvpn.com/blog/share-vpn-connection

Read the comments at the end too.

The problem is that I create something like this, but when I click connect, it disconnects my main internet on my laptop, which is connected via Wi-Fi.

I have neither expertise in nor experience with this, so read the links I posted for more info.

1 Like

Hi, I searched and found a video on YouTube:

It shows a program used on Linux, and it’s from here:

Just a note: if you install it and it doesn’t connect, try changing the channel on your Wi-Fi. For me, it was channel 6.
Also, make sure to turn off the firewall. However, if you find a way to make it work without turning off the firewall, I’d really appreciate it if you could let me know.


Firewall solution:

To solve this, I searched through this link and found these solutions:

I’ll summarize it for you to make it easier:

sudo firewall-cmd --add-service=dhcp
sudo firewall-cmd --add-service=dns
sudo firewall-cmd --add-masquerade

sudo firewall-cmd -q --direct --add-rule ipv4 nat POSTROUTING 0 -o $wifi_iface -j MASQUERADE
sudo firewall-cmd -q --direct --add-rule ipv4 filter FORWARD 0 -i $internet_iface -o $wifi_iface -j ACCEPT
sudo firewall-cmd -q --direct --add-rule ipv4 filter FORWARD 0 -i $wifi_iface -o $internet_iface -m state --state RELATED,ESTABLISHED -j ACCEPT

Just replace $internet_iface and $wifi_iface with your own interfaces.

Also, there was an issue where internet sharing wasn’t allowed, so you need to use this:

sudo firewall-cmd --zone=FedoraWorkstation --add-masquerade
sudo firewall-cmd --zone=trusted --add-masquerade
sudo firewall-cmd --zone=trusted --add-interface=ap0

Thank you!

Additionally, if your ISP-provided hardware doesn’t support this you can set up your own router using an Intel NUC or similar x86_64-based “mini PCs”: https://wiki.futo.org/index.php/Introduction_to_a_Self_Managed_Life:_a_13_hour_%26_28_minute_presentation_by_FUTO_software#Building_Our_Own_Router

There are also options like Open WRT available for ARM-based hardware like a raspberry pi. Using a production machine as a router, while possible, is not ideal in the long term. From a power-consumption perspective, you’d be better off configuring your VPN at a router level and running off that.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.