Goal
I want to use the VPN on device where I cannot install the VPN app (a PC). First thing first I thought using a hotspot on an Android device where the VPN app is installed but this would require rooting the device and seem more complicated. Alternatively I thought to use a PC with Ubuntu.
HW Configuration and network interfaces
My Ubuntu version is 20.04 where I could install the VPN app and with a netcard that supports AP mode: by doing
iw list | grep "Supported interface modes" -A 8
I get
Supported interface modes:
* IBSS
* managed
* AP
* monitor
* mesh point
* P2P-client
* P2P-GO
* P2P-device
which should be good.
Following this approach I connected my Ubuntu PC through the ethernet: since it has to work as hotspot, I thought the WiFi cannot be used for the connection.
With the ethernet connected, the WiFi on, the VPN active I have these interfaces printed out by ifconfig:
br-d742a0998419: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.18.0.1 netmask 255.255.0.0 broadcast 172.18.255.255
ether 02:42:2c:05:10:b4 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:13:6a:d8:33 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enx00e14c680262: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.212 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fdfe:2240:60dc:0:4b25:12c1:c09d:1c71 prefixlen 64 scopeid 0x0<global>
inet6 fdfe:2240:60dc:0:b579:b773:e1b8:c6be prefixlen 64 scopeid 0x0<global>
inet6 fe80::df1a:1668:93e7:5f5f prefixlen 64 scopeid 0x20<link>
ether 00:e1:4c:68:02:62 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 48365 bytes 5679092 (5.6 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 48365 bytes 5679092 (5.6 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp58s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 9c:b6:d0:f3:d8:43 txqueuelen 1000 (Ethernet)
RX packets 1737031 bytes 1495439235 (1.4 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 588528 bytes 126263920 (126.2 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Existing answers
I was following this answer which used hostapd and /etc/netowork/interfaces. The latter howevr is obsolete and was replaced by netplan.
Hostapd configuration
First I installed hostapd and I've created the file /etc/hostapd.conf with this entry
interface=wlp58s0
driver=nl80211
ssid=MyVPNHotSpot
hw_mode=g
channel=6
wmm_enabled=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=ThisIsNotAPassword
wpa_key_mgmt=WPA-PSK WPA-EAP WPA-PSK-SHA256 WPA-EAP-SHA256
rsn_pairwise=CCMP
where for the interface I have used the wifi one returned by ifconfig, the ssid I am assuming the new one that the resulting hotspot will have, and the same for the passphrase.
netplan configuration
In modern Ubuntu versions, /etc/network/interfaces has been replaced by the netplan.
The answer set the following interface in /etc/network/interfaces
auto wlan0
iface wlan0 inet static
hostapd /etc/hostapd/hostapd.conf
address 192.168.0.1
netmask 255.255.255.0
In my netplan.yaml I set:
network:
version: 2
renderer: NetworkManager
wifis:
wlan0:
addresses:
- 192.168.0.1/24
But I do not know how to specify the line hostapd /etc/hostapd/hostapd.conf that was in the original file.
Results
Now on my device I see the available WiFi connection MyVPNHotSopt, but when I insert the password specified in the wpa_passphrase field of the hostapd.conf, it's not connecting: what am I doing wrong?