rego-tunnel: parameterize net + add DHCP static lease
Some checks failed
Test / test (push) Has been cancelled
Some checks failed
Test / test (push) Has been cancelled
This commit is contained in:
34
apps/rego-tunnel/build/start-dnsmasq.sh
Normal file
34
apps/rego-tunnel/build/start-dnsmasq.sh
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
BRIDGE_NAME="${BRIDGE_NAME:-br-rego-vpn}"
|
||||
BRIDGE_CIDR="${BRIDGE_CIDR:-100.100.0.1/24}"
|
||||
VM_NET_IP="${VM_NET_IP:-100.100.0.2}"
|
||||
VM_MAC="${VM_MAC:-52:54:00:12:34:56}"
|
||||
|
||||
LEASE_TIME="${LEASE_TIME:-12h}"
|
||||
DNS_SERVERS="${DNS_SERVERS:-1.1.1.1,8.8.8.8}"
|
||||
|
||||
GATEWAY_IP="${BRIDGE_CIDR%%/*}"
|
||||
|
||||
mkdir -p /etc/dnsmasq.d
|
||||
|
||||
cat > /etc/dnsmasq.d/rego.conf <<EOF
|
||||
interface=${BRIDGE_NAME}
|
||||
bind-interfaces
|
||||
except-interface=lo
|
||||
|
||||
dhcp-authoritative
|
||||
log-dhcp
|
||||
|
||||
dhcp-range=${VM_NET_IP},${VM_NET_IP},${LEASE_TIME}
|
||||
dhcp-option=option:router,${GATEWAY_IP}
|
||||
dhcp-option=option:dns-server,${DNS_SERVERS}
|
||||
|
||||
# Static lease for the VM
|
||||
# (VM must use DHCP for this to take effect)
|
||||
dhcp-host=${VM_MAC},${VM_NET_IP}
|
||||
EOF
|
||||
|
||||
echo "[rego-tunnel] dnsmasq on ${BRIDGE_NAME} gateway=${GATEWAY_IP} lease ${VM_MAC} -> ${VM_NET_IP}"
|
||||
exec dnsmasq --no-daemon --conf-file=/etc/dnsmasq.d/rego.conf
|
||||
Reference in New Issue
Block a user