#!/bin/bash SOURCE=${BASH_SOURCE[0]} while [ -L "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink DIR=$(cd -P "$(dirname "$SOURCE")" >/dev/null 2>&1 && pwd) SOURCE=$(readlink "$SOURCE") [[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located done DIR=$(cd -P "$(dirname "$SOURCE")" >/dev/null 2>&1 && pwd) if [[ -f "$DIR/../../config/nat-config.sh" ]]; then . "$DIR/../../config/nat-config.sh" else echo "$DIR/../../config/nat-config.sh missing!" exit 1 fi if [ "$(id -u)" -ne 0 ]; then echo 'This script must be run as root.' >&2 exit 1 fi . "$DIR/get-dhcp-dns.sh" # ============================================================================== PRIVATE_LAN_IP="192.168.2.1" BRIDGED_CLIENT_IP="192.168.2.2" # Configure the wired interface with the bridge IP address ifconfig $ETH_IFACE $PRIVATE_LAN_IP netmask 255.255.255.0 up # Mirror the DNS servers to the private LAN DHCP_DNS=($(get_dns_servers "$WLAN_IFACE")) if [ -n "$DHCP_DNS" ]; then dns_servers_config="" for server in "${DHCP_DNS[@]}"; do dns_servers_config+="server=$server"$'\n' done dhcp_opt_6_config="dhcp-option=6" for server in "${DHCP_DNS[@]}"; do dhcp_opt_6_config+=",$server" done echo "Mirrored WLAN DHCP DNS servers: ${DHCP_DNS[*]}" else dns_servers_config="""server=1.1.1.1 server=1.0.0.1""" dhcp_opt_6_config="" fi # Also mirror DNS domain DHCP_DNS_DOMAIN=$(get_dns_domain $WLAN_IFACE) if [ -n "$DHCP_DNS_DOMAIN" ]; then dns_domain_config="domain=$DHCP_DNS_DOMAIN" echo "Mirrored WLAN DHCP DNS domain: $DHCP_DNS_DOMAIN" else dns_domain_config="" fi cat >/etc/dnsmasq.conf <