We use a VPN to securely connect to the JaiaBots for development and testing.
Wireguard is a simple and fast modern VPN. By using a VPN to send traffic between the jaiabots and various dev machines, we can easily connect behind NAT routers and provide a secure virtual LAN.
We're using AWS EC2 for hosting the server; other providers will likely be similar.
I used the standard Ubuntu 20.04 server image (Ubuntu Server 20.04 LTS (HVM), SSD Volume Type - ami-03d5c68bab01f3496 (64-bit x86)
) in EC2, using a t3.micro instance type with 8GB disk space. I associated the Elastic IP address 52.36.157.57 (which has been assigned the domain name of vpn.jaia.tech
) to the machine.
On a server (e.g. cloud machine), we configure:
sudo apt install wireguard
sudo -i cd /etc/wireguard umask 077; wg genkey | tee privatekey | wg pubkey > publickey
/etc/wireguard/wg_jaia.conf
: [Interface] # VPN Address for server Address = 172.20.11.1/24 # VPN Server Port ListenPort = 51820 # PrivateKey (contents of /etc/wireguard/privatekey) PrivateKey = ... # Note that this configuration uses NAT to make the VPN traffic appear to the rest of the Virtual Private Cloud (VPC) as if its coming from the VPN instance; this avoids the need for disabling the source/destination check or updating routing tables in EC2. # update eth0 to the actual internet interface PostUp = iptables -w 60 -A FORWARD -i wg_jaia -j ACCEPT; iptables -w 60 -t nat -A POSTROUTING -o eth0 -j MASQUERADE PostDown = iptables -w 60 -D FORWARD -i wg_jaia -j ACCEPT; iptables -w 60 -t nat -D POSTROUTING -o eth0 -j MASQUERADE
sudo ufw allow 51820/udp
sudo systemctl enable wg-quick@wg_jaia
sudo systemctl start wg-quick@wg_jaia
wg_jaia
interface: sudo wg sudo ip a show wg_jaia
/etc/sysctl.conf
and then reboot (or sysctl -p
): net.ipv4.ip_forward = 1
On the client (jaiabot, dev machines, etc.) side, we need to configure:
sudo apt install wireguard
sudo -i cd /etc/wireguard/ umask 077; wg genkey | tee privatekey | wg pubkey > publickey
/etc/wireguard/wg_jaia.conf
: [Interface] # from /etc/wireguard/privatekey on client PrivateKey = ... # this client's VPN IP address Address = 172.20.11.XXX [Peer] # Server public key (from /etc/wireguard/publickey on server) PublicKey = quIp0ErbKXgzbws0juC0YaI2FLmLHVpo8j4ChgTmjXI= # Allowed private IPs AllowedIPs = 172.20.11.0/24 # Server IP and port Endpoint = vpn.jaia.tech:51820 # Keep connection alive (required for behind NAT routers) PersistentKeepalive = 25
/etc/wireguard/wg_jaia.conf
: [Peer] # client VPN public key (from /etc/wireguard/publickey on client) PublicKey = ... # client VPN IP address AllowedIPs = 172.20.11.XXX/32
sudo systemctl restart wg-quick@wg_jaia
sudo wg-quick up wg_jaia
ping 172.20.11.1
sudo systemctl enable wg-quick@wg_jaia
MacOS has a GUI wireguard that requires a slightly different approach summarized below
We are rolling out fleet specific VPN connections that follow this pattern:
vpn.jaia.tech
, UDP port 51821 + fleet id
(e.g. 51821
for fleet 0, 51822
for fleet 1, etc.).172.23.xxx.0/24
where xxx is the fleet id. The server will always be 172.23.xxx.1
.172.23.xxx.yyy/24
where xxx is the fleet id, and yyy is 100 + bot_id (e.g. 172.23.1.101
for bot 1 on fleet 1).172.23.xxx.zzz/24
where xxx is the fleet id, and zzz is 10 + bot_id (e.g. 172.23.2.10 for hub 0 on fleet 2).The existing VPN on vpn.jaia.tech:51820 (subnet 172.20.11.0/24
) will continue to maintained for testing.