# DNS for Alpine 5G Router The 5G modem gets DNS from the carrier (e.g. via `AT+CGCONTRDP=1`). The router and LAN clients need working DNS. ## Option 1: Use carrier DNS (automatic) When 5G is up, you can put the carrier DNS in `/etc/resolv.conf` so the router itself uses it. CYTA example: ``` nameserver 195.14.130.220 nameserver 195.14.154.100 ``` To automate: in `connect-5g.sh` or a post-up script, if `DNS_SERVERS` is set in `/etc/5g-router.conf`, write it to `/etc/resolv.conf` after configuring the interface. Example in config: ``` DNS_SERVERS="195.14.130.220,195.14.154.100" ``` A one-liner to apply (run after 5G is up): ```sh echo "nameserver 195.14.130.220" > /etc/resolv.conf echo "nameserver 195.14.154.100" >> /etc/resolv.conf ``` ## Option 2: dnsmasq (LAN DHCP + DNS) dnsmasq can provide DHCP for LAN and act as DNS forwarder. Install and enable: ```bash apk add dnsmasq rc-update add dnsmasq default ``` Example `/etc/dnsmasq.conf`: ``` interface=eth0.100 dhcp-range=192.168.1.100,192.168.1.200,255.255.255.0,12h dhcp-option=6,192.168.1.1 ``` Then the router (192.168.1.1) must resolve DNS. Either: - Set `/etc/resolv.conf` on the router to carrier or public DNS (8.8.8.8, 1.1.1.1), or - Configure dnsmasq to use upstream servers: `server=195.14.130.220` and `server=195.14.154.100` (or 8.8.8.8). So: **router** gets DNS from carrier or public; **LAN clients** get DHCP and DNS from dnsmasq (which forwards to those servers). ## Option 3: Public DNS only Ignore carrier DNS and use public resolvers on the router: ```bash echo "nameserver 8.8.8.8" > /etc/resolv.conf echo "nameserver 1.1.1.1" >> /etc/resolv.conf ``` Ensure `ip_forward` and NAT are set so LAN clients use the router and thus the same DNS path. ## Summary | Role | DNS source | |------------|--------------------------------------| | Router | `/etc/resolv.conf` (carrier or 8.8.8.8) | | LAN clients| dnsmasq (option 6 = router) or router as gateway + same resolv | After changing DNS, restart dnsmasq if used: `service dnsmasq restart`.