I was following the documentation on https://openwrt.org/docs/guide-user/services/dns/adguard-home and after installing AGH there is a script starting with:
# Get the first IPv4 and IPv6 Address of router and store them in following variables for use during the script.
NET_ADDR=$(/sbin/ip -o -4 addr list br-lan | awk 'NR==1{ split($4, ip_addr, "/"); print ip_addr[1]; exit }')
NET_ADDR6=$(/sbin/ip -o -6 addr list br-lan scope global | awk '$4 ~ /^fd|^fc/ { split($4, ip_addr, "/"); print ip_addr[1]; exit }')
echo "Router IPv4 : ""${NET_ADDR}"
echo "Router IPv6 : ""${NET_ADDR6}"
Immediately I see an issue here, since the echos are returning empty for both variables when I run it in my router SSH as root:
root@OpenWrt:~# NET_ADDR=$(/sbin/ip -o -4 addr list br-lan | awk 'NR==1{ split($4, ip_addr, "/"); print ip_addr[1]; exit }')
root@OpenWrt:~# NET_ADDR6=$(/sbin/ip -o -6 addr list br-lan scope global | awk '$4 ~ /^fd|^fc/ { split($4, ip_addr, "/"); prin
t ip_addr[1]; exit }')
er IPv6 : ""${NET_ADDR6}"root@OpenWrt:~# echo "Router IPv4 : ""${NET_ADDR}"
Router IPv4 :
root@OpenWrt:~# echo "Router IPv6 : ""${NET_ADDR6}"
Router IPv6 :
Of course, when I run the rest, and then try to execute dnsmasq, it is now failing:
root@OpenWrt:~# dnsmasq -k -C /var/etc/dnsmasq.conf.cfg01411c 2>&1
dnsmasq: bad IP address at line 57 of /var/etc/dnsmasq.conf.cfg01411c
If I check line 57 of my config file (/var/etc/dnsmasq.conf.cfg01411c), it is:
dhcp-option=lan,3,
Is there a better command to get the IPv4 and IPv6 on the router so we can update the documentation? Otherwise it will break other people’s config as well.