1. New Jail
13.1 release
DHCP
VNET
Berkeley Packet Filter
ipv6 disabled
+ allow_raw_sockets
ip6.saddrsel disabled
+ allow_tun
2. Jail installed
3. System tunables
if_wg_load YES LOADER yes
wireguard_enable YES RC yes
wireguard_interfaces wg0 RC yes
4.
https://www.cyberciti.biz/faq/how-to-install-a-wireguard-vpn-client-in-a-freebsd-jail/
starting jail
registered on router
jail shell
pkg update ok
pkg upgrade ok
cat /etc/devfs.rules
cat: /etc/devfs.rules: No such file or directory
nano /etc/devfs.rules
add include $devfsrules_hide_all
add include $devfsrules_unhide_basic
add include $devfsrules_unhide_login
add path 'tun*' unhide
add path 'bpf*' unhide
add path zfs unhide
saved
pkg search wireguard
pkg install wireguard
root@QBB:~ # pkg install wireguard
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 5 package(s) will be affected (of 0 checked):
New packages to be INSTALLED:
bash: 5.2.15
readline: 8.2.1
wireguard: 2,1
wireguard-kmod: 0.0.20220615_1
wireguard-tools: 1.0.20210914_1
Number of packages to be installed: 5
The process will require 11 MiB more space.
2 MiB to be downloaded.
Proceed with this action? [y/N]: y
[QBB] [1/5] Fetching wireguard-2,1.pkg: 100% 1 KiB 1.5kB/s 00:01
[QBB] [2/5] Fetching wireguard-tools-1.0.20210914_1.pkg: 68% 40 KiB 41.0kB/s[QBB] [2/5] Fetching wireguard-tools-1.0.20210914_1.pkg: 100% 58 KiB 59.6kB/s 00:01
[QBB] [3/5] Fetching readline-8.2.1.pkg: 100% 371 KiB 379.7kB/s 00:01
[QBB] [4/5] Fetching bash-5.2.15.pkg: 100% 2 MiB 1.7MB/s 00:01
[QBB] [5/5] Fetching wireguard-kmod-0.0.20220615_1.pkg: 100% 39 KiB 39.6kB/s 00:01
Checking integrity... done (0 conflicting)
[QBB] [1/5] Installing readline-8.2.1...
[QBB] [1/5] Extracting readline-8.2.1: 100%
[QBB] [2/5] Installing bash-5.2.15...
[QBB] [2/5] Extracting bash-5.2.15: 100%
[QBB] [3/5] Installing wireguard-tools-1.0.20210914_1...
[QBB] [3/5] Extracting wireguard-tools-1.0.20210914_1: 100%
[QBB] [4/5] Installing wireguard-kmod-0.0.20220615_1...
[QBB] [4/5] Extracting wireguard-kmod-0.0.20220615_1: 100%
[QBB] [5/5] Installing wireguard-2,1...
[QBB] [5/5] Extracting wireguard-2,1: 100%
=====
some bla bla bla
5. wg0.conf
root@QBB:~ # cd /usr/local/etc/wireguard/
root@QBB:/usr/local/etc/wireguard # umask 077; wg genkey | tee privatekey-remote-ln-sg-vpn | wg pubkey > publickey-remote-ln-sg-vpn
root@QBB:/usr/local/etc/wireguard # ls -l
total 17
-rw------- 1 root wheel 45 Aug 27 11:34 privatekey-remote-ln-sg-vpn
-rw------- 1 root wheel 45 Aug 27 11:34 publickey-remote-ln-sg-vpn
root@QBB:/usr/local/etc/wireguard # cat privatekey-remote-ln-sg-vpn publickey-remote-ln-sg-vpn
key=
key=
nano /usr/local/etc/wireguard/wg0.conf
[Interface]
PrivateKey = key=
Address = 172.x.x.x/24
DNS = 192.168.1.1
[Peer]
PublicKey = key=
AllowedIPs = 192.168.1.0/24, 0.0.0.0/1, 128.0.0.0/1, 172.x.x.x/24
Endpoint = server:port
PersistentKeepalive = 3600
6. Turn on WireGuard VPN client service
sysrc wireguard_interfaces="wg0"
wireguard_interfaces: -> wg0
sysrc wireguard_enable="YES"
wireguard_enable: -> YES
~ # service wireguard start
[#] ifconfig wg create name wg0
[!] Missing WireGuard kernel support (ifconfig: SIOCIFCREATE2: Invalid argument). Falling back to slow userspace implementation.
[#] wireguard-go wg0
/usr/local/bin/wg-quick: line 33: wireguard-go: command not found
[#] ifconfig wg0 destroy
ifconfig: interface wg0 does not exist
7. so is it
pkg install wireguard wireguard-go libqrencode
ok
[QBB] [1/3] Installing png-1.6.39...
[QBB] [1/3] Extracting png-1.6.39: 100%
[QBB] [2/3] Installing libqrencode-4.1.1...
[QBB] [2/3] Extracting libqrencode-4.1.1: 100%
[QBB] [3/3] Installing wireguard-go-0.0.20220316_14,1...
[QBB] [3/3] Extracting wireguard-go-0.0.20220316_14,1: 100%
root@QBB:~ # service wireguard start
[#] ifconfig wg create name wg0
[!] Missing WireGuard kernel support (ifconfig: SIOCIFCREATE2: Invalid argument). Falling back to slow userspace implementation.
[#] wireguard-go wg0
┌──────────────────────────────────────────────────────┐
│ │
│ Running wireguard-go is not required because this │
│ kernel has first class support for WireGuard. For │
│ information on installing the kernel module, │
│ please visit: │
│
https://www.wireguard.com/install/ │
│ │
└──────────────────────────────────────────────────────┘
[#] wg setconf wg0 /dev/stdin
Warning: AllowedIP has nonzero host part: 172.x.x.x/24
[#] ifconfig wg0 inet 172.x.x.x/24 alias
[#] ifconfig wg0 mtu 1420
[#] ifconfig wg0 up
[#] resolvconf -a wg0 -x
[#] route -q -n add -inet 192.168.1.0/32 -interface wg0
[#] route -q -n add -inet 172.x.x.0/32 -interface wg0
[#] route -q -n add -inet 192.168.1.0/24 -interface wg0
[#] route -q -n add -inet 128.0.0.0/1 -interface wg0
[#] route -q -n add -inet 0.0.0.0/1 -interface wg0
[+] Backgrounding route monitor
interface: wg0
public key: key=
private key: (hidden)
listening port: port
peer: key=
endpoint: server
allowed ips: 192.168.1.0/24, 172.x.x.0/32, 192.168.1.0/32, 0.0.0.0/1, 128.0.0.0/1
latest handshake: 2 minutes, 51 seconds ago
transfer: 4.43 KiB received, 7.03 GiB sent ///// here is always a lot of GiB
persistent keepaliv
root@QBB:~ # ps aux | grep wireguard
root 99270 0.0 0.1 884204 84896 21 IJ 11:50 8:29.20 wireguard-go wg0
root 99430 0.0 0.0 12920 2408 21 S+J 11:55 0:00.00 grep wireguard
root@QBB:~ # ping -c 1 172.x.x.1 /// remote server
PING 172.x.x.1 (172.x.x.1): 56 data bytes
--- 172.x.x.1 ping statistics ---
1 packets transmitted, 0 packets received, 100.0% packet loss
root@QBB:~ # ping -c 1 192.168.1.1 //remote router
PING 192.168.1.1 (192.168.1.1): 56 data bytes
--- 192.168.1.1 ping statistics ---
1 packets transmitted, 0 packets received, 100.0% packet loss
root@QBB:~ # ping -c 1 192.168.2.1 //router
PING 192.168.2.1 (192.168.2.1): 56 data bytes
64 bytes from 192.168.2.1: icmp_seq=0 ttl=64 time=0.622 ms
--- 192.168.2.1 ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.622/0.622/0.622/0.000 ms
root@QBB:~ # ifconfig wg0
wg0: flags=8043<UP,BROADCAST,RUNNING,MULTICAST> metric 0 mtu 1420
options=80000<LINKSTATE>
inet 172.x.x.4 netmask 0xffffff00 broadcast 172.x.x.255
groups: tun
nd6 options=109<PERFORMNUD,IFDISABLED,NO_DAD>
Opened by PID 99270
root@QBB:~ #
8. See routing info on your FreeBSD:
root@nas[~]# netstat -f inet -r -n
Routing tables
Internet:
Destination Gateway Flags Netif Expire
default 192.168.2.1 UGS re0
127.0.0.1 link#6 UH lo0
192.168.2.0/24 link#1 U re0
192.168.2.138 link#1 UHS lo0
9.
if i try to use a plugin-jail, installation can not be finished due
"failed to creat temporary file if_wg.ko"