mirror of
https://github.com/pcvolkmer/docker-wireguard-boringtun.git
synced 2025-04-19 13:26:50 +00:00
This will add a DNS config to the client configurations pointing to the wireguard server. With this configuration, all DNS requests are sent through the VPN and are no longer answered by the local DNS server. Each client now has a hostname like <device>-client<id>.
24 lines
774 B
Bash
Executable File
24 lines
774 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Prepare and cleanup hosts file
|
|
mkdir hosts.d 2>/dev/null
|
|
echo -n "" > hosts.d/wg
|
|
|
|
NETWORK=$(cat $DEVICE.conf | grep Address | sed 's/Address = //g; s/\.[0-9\/]*,.*$//g')
|
|
NETWORK6=$(cat $DEVICE.conf | grep Address | sed 's/Address = //g; s/^.*, //g; s/\:[0-9a-f\/]*$//g')
|
|
|
|
# Print hosts file
|
|
echo "# IPv4 clients" >> hosts.d/wg
|
|
echo "$NETWORK.1 $DEVICE-server" >> hosts.d/wg
|
|
for i in {1..240}; do
|
|
if [ -f "$DEVICE-client_$i.conf" ]; then
|
|
echo "$NETWORK.$(($i+10)) $DEVICE-client$i" >> hosts.d/wg
|
|
fi
|
|
done
|
|
echo "# IPv6 clients" >> hosts.d/wg
|
|
echo "$NETWORK6:1 $DEVICE-server" >> hosts.d/wg
|
|
for i in {1..240}; do
|
|
if [ -f "$DEVICE-client_$i.conf" ]; then
|
|
echo "$NETWORK6:$(printf "%x" $(($i+10))) $DEVICE-client$i" >> hosts.d/wg
|
|
fi
|
|
done |