Jump to content
Not connected, Your IP: 3.16.49.213
LakeWorthB

Anyone use AirVPN wih gluetun?

Recommended Posts

It's clearly described in the wiki.

Example for Wireguard (replace xxx with your wg.conf generated by AirVPN):

docker run -d --name gluetun --cap-add=NET_ADMIN \
-e VPN_SERVICE_PROVIDER=custom \
-e VPN_TYPE=wireguard \
-e VPN_ENDPOINT_IP=xxx.xxx.xxx.xxx \
-e VPN_ENDPOINT_PORT=xxxx \
-e DNS_ADDRESS=xxx.xxx.xxx.xxx \
-e FIREWALL_VPN_INPUT_PORTS=xxxxx \  <-- For AirVPN port forwarding (has to match your port(s) below)
-p xxxxx:xxxxx \ <-- For AirVPN port forwarding (Port your container would normally expose).
-e WIREGUARD_PUBLIC_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxx \
-e WIREGUARD_PRIVATE_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxx \
-e WIREGUARD_PRESHARED_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxx \
-e WIREGUARD_ADDRESSES="xx.xxx.xxx.xxx/xx" \
qmcgaw/gluetun:latest

Now attach your container to it by using --network=container:gluetun, e.g:
docker run -it --rm --network=container:gluetun ubuntu

Do not expose the port on the container as you will get a conflict. Gluetuns firewall will automatically forward it.

Btw: The latest push tonight has an error. So you want to use mcgaw/gluetun:v3.28 instead of qmcgaw/gluetun:latest.
 

Share this post


Link to post

I also use this script I made for wireguard automation.. might help somebody, this automatically 'randomizes' (gets new) IP and randomizes exposed port
(from list of ports you define in variable and of course you have reserved in your account)

This should be in (docker-compose related) `.env` file

AIRVPN_WG_PRIVATE_KEY=xxxxxxxxxxxxxxxxxxxx
AIRVPN_WG_PRESHARED_KEY=xxxxxxxxxxxxxxxxxxxxxx
AIRVPN_WG_ADDRESSES=x.x.x.x/32,x:x:x:x:x:x:x:x/128
AIRVPN_PEER_PORT=xxxxx
 
AIRVPN_DEVICE_ID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
AIRVPN_SERVER_NAMES=xxxxx xxxxx
AIRVPN_COUNTRIES=xxxxx
AIRVPN_CUNTRY_CODE=xx
AIRVPN_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
AIRVPN_PORTS=xxxx xxxx xxxxx xxxxx xxxxx xxxxx xxxx xxxx xxxx xxxx xxxx xxxxx

And this is `docker-compose.yml` part:
  gluetun:
    image: qmcgaw/gluetun
    container_name: gluetun
    ports:
      - 8888:8888/tcp # HTTPPROXY
    sysctls:
      - net.ipv6.conf.all.disable_ipv6=0
    cap_add:
      - NET_ADMIN
    environment:
      - TZ=Europe/Amsterdam
      - HTTPPROXY=on
      - HTTPPROXY_STEALTH=on
      - VPN_TYPE=wireguard
      - VPN_SERVICE_PROVIDER=airvpn
      - SERVER_NAMES=${AIRVPN_SERVER_NAMES}
      - SERVER_COUNTRIES=${AIRVPN_COUNTRIES}
      - FIREWALL_VPN_INPUT_PORTS=${AIRVPN_PEER_PORT}
      - WIREGUARD_ADDRESSES=${AIRVPN_WG_ADDRESSES}
      - WIREGUARD_PRIVATE_KEY=${AIRVPN_WG_PRIVATE_KEY}
      - WIREGUARD_PRESHARED_KEY=${AIRVPN_WG_PRESHARED_KEY}
    volumes:
      - /volume1/docker/gluetun:/gluetun
    devices:
      - /dev/net/tun:/dev/net/tun
    restart: always
    mem_limit: 1024m
    memswap_limit: 1024m

Finally put this part to `.bashrc` (or alternative), `source .bashrc` then execute 'rand' function
(change path to your env file as well as docker compose file)
* you should have `jq`, `awk`, `sed`, `curl` and `shuf` binaries available.
 
export DOCKER_ENV_FILE=/volume1/docker/.env
export DOCKER_COMPOSE_FILE=/volume1/docker/docker-compose.yml
rand () {
    CURRENT_DEVICE_ID=$(awk -F '=' '/AIRVPN_DEVICE_ID/ {print $2}' $DOCKER_ENV_FILE)
    AIRVPN_API_KEY=$(awk -F '=' '/AIRVPN_API_KEY/ {print $2}' $DOCKER_ENV_FILE)
    AIRVPN_CUNTRY_CODE=$(awk -F '=' '/AIRVPN_CUNTRY_CODE/ {print $2}' $DOCKER_ENV_FILE)
    AIRVPN_PORTS=$(awk -F '=' '/AIRVPN_PORTS/ {print $2}' $DOCKER_ENV_FILE)
    [ ! -f $CURRENT_DEVICE_ID ] && \
    curl -s -H "API-KEY:$AIRVPN_API_KEY" "https://airvpn.org/api/disconnect/?device=$CURRENT_DEVICE_ID" && sleep 1 && \
    curl -s -H "API-KEY:$AIRVPN_API_KEY" "https://airvpn.org/api/devices/?action=delete&id=$CURRENT_DEVICE_ID" && sleep 1
    AIRVPN_DEVICE_ID=$(curl -s -H "API-KEY:$AIRVPN_API_KEY" "https://airvpn.org/api/devices/?action=add" | jq -r .id[0:50]) && sleep 10
    CONFIG_FILE=$(curl -s -H "API-KEY:$AIRVPN_API_KEY" "https://airvpn.org/api/generator/?protocols=wireguard_3_udp_1637&servers=${AIRVPN_CUNTRY_CODE}&system=linux&device_id=New%20device")
    AIRVPN_WG_ADDRESSES=$(awk '/Address/ {print $3$4}' <<<$CONFIG_FILE)
    AIRVPN_WG_PRESHARED_KEY=$(awk '/PresharedKey/ {print $3}' <<<$CONFIG_FILE)
    AIRVPN_WG_PRIVATE_KEY=$(awk '/PrivateKey/ {print $3}' <<<$CONFIG_FILE)
    AIRVPN_PEER_PORT=$(shuf -n1 -e $AIRVPN_PORTS)
    sed -i 's#^AIRVPN_WG_ADDRESSES=.*$#AIRVPN_WG_ADDRESSES='"$AIRVPN_WG_ADDRESSES"'#g' $DOCKER_ENV_FILE
    sed -i 's#^AIRVPN_WG_PRESHARED_KEY=.*$#AIRVPN_WG_PRESHARED_KEY='"$AIRVPN_WG_PRESHARED_KEY"'#g' $DOCKER_ENV_FILE
    sed -i 's#^AIRVPN_WG_PRIVATE_KEY=.*$#AIRVPN_WG_PRIVATE_KEY='"$AIRVPN_WG_PRIVATE_KEY"'#g' $DOCKER_ENV_FILE
    sed -i 's#^AIRVPN_PEER_PORT=.*$#AIRVPN_PEER_PORT='"$AIRVPN_PEER_PORT"'#g' $DOCKER_ENV_FILE
    sed -i 's#^AIRVPN_DEVICE_ID=.*$#AIRVPN_DEVICE_ID='"$AIRVPN_DEVICE_ID"'#g' $DOCKER_ENV_FILE
    docker-compose  --env-file $DOCKER_ENV_FILE -f $DOCKER_COMPOSE_FILE up --detach --quiet-pull --remove-orphans
}

There is a single limitation, you can only have a single "New device" named device on your account, this gets re-cycled (current deleted and new created) by the script.
This is because we can't set device name via API so I am forced to use the default "New device" name while calling API to generate a new config.
Oh and the api calls must go without using VPN, because understandably, its killing the connection so you'd be unable to finish the process.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Security Check
    Play CAPTCHA Audio
    Refresh Image

×
×
  • Create New...