how to turn softether vpn into a vpn router
Posted: Wed Mar 15, 2023 9:00 am
I have been holding this question in mind for the past few months.
It annoys me each time I connect my phone to the home modem WiFi I have to turn on a VPN (on my phone) to check sites/apps have been blocked or for privacy.
If we have a "raspberry pi box" we can connect to it via its network port, setup a VPN server on it, share the internet via pi WiFi access point; the most convenient way of having Internet over a VPN which is 24/7 up and running.
The funny part is that a pi here (Iran) is more expensive than a PC (e.g HP ProDesk G4 :| :| :| )
YouTube videos by Rob Braxman
How to Install a VPN Router
Why You Need a VPN Router
Long story short, my idea is using
- my PC (Windows or Linux)
- a SE server (not SE client)
- my modem (a home modem-router)
and when I connect my phone to the modem WiFi I should have been connected to the remote VPN server.
Two scenarios to make this fun work
First
- two HUBs one for internal net and one for external net
- a cascade connection in second HUB #2 to a remote SE server
- a Bridge for HUB #1 in home SE server
- inter HUB communication with L3 switch
Second
- two HUBs one for internal net and one for external net
- two Local Bridge for each HUB, first HUB a network adopter, second HUB a tap device
- a cascade connection from HUB #2 to remote SE server
- using IP route or maybe iproute PBC (Policy Based Routing)
Still I am learning L2 Switch so I tried the second scenario.
some clarification
1. Why I use a VM not the home PC?
because I needed to add a second network adopter. With iproute2 tools did not work
2. How I assign IP address from SE server Hub #1 my phone?
Using network adopter connected to HUB #1 via Bridging
NOTE:
Even though I guessed that connecting to home WiFi directly , the modem will handle the traffic not any of PCs on the LAN but it was worth the try.
Lets go
########## configuration ##########
Home VPN server on a VM
Hubs:
- SW0
- SW1
SW0
- network: 192.168.30.0/24
- DNCP + DNS
- No NAT
- default gateway 192.168.30.1 over Local Bridge via a network adopter no a tap device
NOTE:
I added second network adopter to a VM in order to advertise IP addresses of SW0 (network 192.168.30.0/24).
So when my a phone is connected to home WiFi gets IP from SW0 hub not from modem DHCP
SW1
- no SecureNAT
- cascade connection to a remote server
- a tap device (tap_sw1) IP: 192.168.100.3 (part of remote SE server network)
Remote SE server
- network: 192.168.100.0/24
- DHCP + DNS
- No NAT
- default gateway 192.168.100.1 over Local Bridge via a tap device (tap_vpn)
my Phone connected to home WiFi
- no VPN client
- got IP and DNS server address from home SE server SW0 (network 192.168.30.0/24)
- phone IP: 192.168.30.10
home SE server ip route
two routes added for
- vm network adopter 192.168.30.0/24
- tap_sw1 192.168.100.3/24
home SE server ip table
remote SE server ip route
- "aaa.bbb.ccc.ddd" is the remote SE server public IP address, gateway, etc
- 192.168.30.0/24 via 192.168.100.3 dev tap_vpn is for accessing gateway from the phone
- 192.168.100.0/24 dev tap_vpn is for Local Bridge a tap device
remote SE server ip table
my phone ip route
my phone ip addr
phone can ping home SE server gateway
phone can ping remote SE server gateway
phone can ping the Internet
Up to this point everything works fine :) but the phone IP address is my modem public IP address :(
NOTE:
Even though I guessed that connecting to home WiFi directly , the modem will handle the traffic not any of PCs on the LAN but it was worth the try.
Q.1 Can we make this work?
Q.2 How?
Regards
It annoys me each time I connect my phone to the home modem WiFi I have to turn on a VPN (on my phone) to check sites/apps have been blocked or for privacy.
If we have a "raspberry pi box" we can connect to it via its network port, setup a VPN server on it, share the internet via pi WiFi access point; the most convenient way of having Internet over a VPN which is 24/7 up and running.
The funny part is that a pi here (Iran) is more expensive than a PC (e.g HP ProDesk G4 :| :| :| )
YouTube videos by Rob Braxman
How to Install a VPN Router
Why You Need a VPN Router
Long story short, my idea is using
- my PC (Windows or Linux)
- a SE server (not SE client)
- my modem (a home modem-router)
and when I connect my phone to the modem WiFi I should have been connected to the remote VPN server.
Two scenarios to make this fun work
First
- two HUBs one for internal net and one for external net
- a cascade connection in second HUB #2 to a remote SE server
- a Bridge for HUB #1 in home SE server
- inter HUB communication with L3 switch
Second
- two HUBs one for internal net and one for external net
- two Local Bridge for each HUB, first HUB a network adopter, second HUB a tap device
- a cascade connection from HUB #2 to remote SE server
- using IP route or maybe iproute PBC (Policy Based Routing)
Still I am learning L2 Switch so I tried the second scenario.
some clarification
1. Why I use a VM not the home PC?
because I needed to add a second network adopter. With iproute2 tools did not work
2. How I assign IP address from SE server Hub #1 my phone?
Using network adopter connected to HUB #1 via Bridging
NOTE:
Even though I guessed that connecting to home WiFi directly , the modem will handle the traffic not any of PCs on the LAN but it was worth the try.
Lets go
########## configuration ##########
Home VPN server on a VM
Hubs:
- SW0
- SW1
SW0
- network: 192.168.30.0/24
- DNCP + DNS
- No NAT
- default gateway 192.168.30.1 over Local Bridge via a network adopter no a tap device
NOTE:
I added second network adopter to a VM in order to advertise IP addresses of SW0 (network 192.168.30.0/24).
So when my a phone is connected to home WiFi gets IP from SW0 hub not from modem DHCP
SW1
- no SecureNAT
- cascade connection to a remote server
- a tap device (tap_sw1) IP: 192.168.100.3 (part of remote SE server network)
Remote SE server
- network: 192.168.100.0/24
- DHCP + DNS
- No NAT
- default gateway 192.168.100.1 over Local Bridge via a tap device (tap_vpn)
my Phone connected to home WiFi
- no VPN client
- got IP and DNS server address from home SE server SW0 (network 192.168.30.0/24)
- phone IP: 192.168.30.10
home SE server ip route
Code: Select all
ip route show
default via 192.168.1.1 dev ens192 onlink
192.168.1.0/24 dev ens192 proto kernel scope link src 192.168.1.32
192.168.30.0/24 dev ens224 proto kernel scope link src 192.168.30.1
192.168.100.0/24 dev tap_sw1 proto kernel scope link src 192.168.100.3
- vm network adopter 192.168.30.0/24
- tap_sw1 192.168.100.3/24
home SE server ip table
Code: Select all
iptables -t nat -S
-P PREROUTING ACCEPT
-P INPUT ACCEPT
-P OUTPUT ACCEPT
-P POSTROUTING ACCEPT
-A POSTROUTING -s 192.168.30.0/24 ! -d 192.168.30.0/24 -o ens192 -j SNAT --to-source 192.168.1.32
remote SE server ip route
Code: Select all
ip route show
default via aaa.bbb.ccc.1 dev ens192 onlink
192.168.30.0/24 via 192.168.100.3 dev tap_vpn
192.168.100.0/24 dev tap_vpn proto kernel scope link src 192.168.100.1
aaa.bbb.ccc.0/24 dev ens192 proto kernel scope link src aaa.bbb.ccc.ddd
- 192.168.30.0/24 via 192.168.100.3 dev tap_vpn is for accessing gateway from the phone
- 192.168.100.0/24 dev tap_vpn is for Local Bridge a tap device
remote SE server ip table
Code: Select all
iptables -t nat -S
-P PREROUTING ACCEPT
-P INPUT ACCEPT
-P OUTPUT ACCEPT
-P POSTROUTING ACCEPT
-A POSTROUTING -s 192.168.100.0/24 ! -d 192.168.100.0/24 -o ens192 -j SNAT --to-source aaa.bbb.ccc.ddd
my phone ip route
Code: Select all
ip route show
103.11.119.148/30 dev rmnet_data5 proto kernel scope link src 103.11.119.150
192.168.30.0/24 dev wlan0 proto kernel scope link src 192.168.30.10
Code: Select all
ip -br a | tail -n 4
rmnet_data3@rmnet_ipa0 DOWN
wlan0 UP 192.168.30.10/24 fe80::2470:44ff:fe7c:dad0/64
swlan0 DOWN
p2p0 DOWN
wifi-aware0 DOWN
Code: Select all
ping -c4 192.168.30.1
PING 192.168.30.1 (192.168.30.1) 56(84) bytes of data.
64 bytes from 192.168.30.1: icmp_seq=1 ttl=64 time=17.0 ms
64 bytes from 192.168.30.1: icmp_seq=2 ttl=64 time=18.8 ms
64 bytes from 192.168.30.1: icmp_seq=3 ttl=64 time=18.1 ms
64 bytes from 192.168.30.1: icmp_seq=4 ttl=64 time=17.4 ms
phone can ping remote SE server gateway
Code: Select all
ping -c4 192.168.100.1
PING 192.168.100.1 (192.168.100.1) 56(84) bytes of data.
64 bytes from 192.168.100.1: icmp_seq=1 ttl=63 time=141 ms
64 bytes from 192.168.100.1: icmp_seq=2 ttl=63 time=184 ms
64 bytes from 192.168.100.1: icmp_seq=3 ttl=63 time=85.7 ms
64 bytes from 192.168.100.1: icmp_seq=4 ttl=63 time=127 ms
Code: Select all
ping -c4 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=114 time=182 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=114 time=204 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=114 time=227 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=114 time=147 ms
NOTE:
Even though I guessed that connecting to home WiFi directly , the modem will handle the traffic not any of PCs on the LAN but it was worth the try.
Q.1 Can we make this work?
Q.2 How?
Regards