mirror of
https://github.com/pcvolkmer/docker-wireguard-boringtun.git
synced 2025-07-05 00:32:55 +00:00
Use dnsmasq and configure dns server config for clients
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>.
This commit is contained in:
24
scripts/hosts.sh
Executable file
24
scripts/hosts.sh
Executable file
@ -0,0 +1,24 @@
|
||||
#!/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
|
Reference in New Issue
Block a user