layer3: move from fixed address to fixed hostname
Add "local.fff.community" hostname that resolves to the local router. All possible addresses are made available to provide multiple fallbacks: - client ipv4 and ipv6 addresses - peer_ip and peer_ip6 addresses - fdff::1/64 on first boot and after factory reset The moment any ipv6 network is configured, all occurrences of the fixed fdff::/64 network are removed. Fixes #76 Signed-off-by: Johannes Kimmel <fff@bareminimum.eu>
This commit is contained in:
parent
3147a33c52
commit
493208b00b
|
@ -1,7 +1,7 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=fff-dhcp
|
||||
PKG_RELEASE:=5
|
||||
PKG_RELEASE:=6
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
# load uci functions
|
||||
. /lib/functions.sh
|
||||
|
||||
configure() {
|
||||
## dns
|
||||
uci -q del dhcp.@dnsmasq[0].server
|
||||
|
@ -10,6 +13,48 @@ configure() {
|
|||
else
|
||||
echo "WARNING: No DNS servers set!"
|
||||
fi
|
||||
|
||||
# remove all domain autogenerated entries
|
||||
remove_domains() {
|
||||
local name="$1"
|
||||
|
||||
case $(uci -q get dhcp."$name".addedbyautoconfig) in
|
||||
/etc/layer3.d/35-dns | /etc/uci-defaults/90-fff-dhcp)
|
||||
uci -q del dhcp."$name" ;;
|
||||
esac
|
||||
}
|
||||
config_load dhcp
|
||||
config_foreach remove_domains domain
|
||||
|
||||
local dnsips
|
||||
local have_dns=false
|
||||
|
||||
# gather all ips belonging to the router
|
||||
dnsips=$(
|
||||
uci -q batch <<- EOF | cut -d / -f1 | sort -u
|
||||
get network.client.ip6addr
|
||||
get network.client.ipaddr
|
||||
get gateway.@gateway[0].peer_ip
|
||||
get gateway.@gateway[0].peer_ip6
|
||||
EOF
|
||||
)
|
||||
|
||||
for ip in $dnsips; do
|
||||
ip=$(echo "$ip" | cut -d / -f1)
|
||||
case "$ip" in
|
||||
fe80*) continue ;;
|
||||
esac
|
||||
|
||||
have_dns=true
|
||||
uci -q add dhcp domain > /dev/null
|
||||
uci -q set dhcp.@domain[-1].ip="$ip"
|
||||
uci -q set dhcp.@domain[-1].name="local.fff.community"
|
||||
uci -q set dhcp.@domain[-1].addedbyautoconfig="/etc/layer3.d/35-dns"
|
||||
done
|
||||
|
||||
if ! $have_dns; then
|
||||
echo "WARNING: No valid device ip available for local DNS."
|
||||
fi
|
||||
}
|
||||
|
||||
apply() {
|
||||
|
|
|
@ -27,6 +27,11 @@ uci batch >/dev/null <<EOF
|
|||
set dhcp.client=dhcp
|
||||
set dhcp.client.interface='client'
|
||||
set dhcp.client.leasetime='1h'
|
||||
|
||||
add dhcp domain
|
||||
set dhcp.@domain[-1].ip="fdff::1"
|
||||
set dhcp.@domain[-1].name="local.fff.community"
|
||||
set dhcp.@domain[-1].addedbyautoconfig="/etc/uci-defaults/90-fff-dhcp"
|
||||
EOF
|
||||
|
||||
uci commit dhcp
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=fff-layer3-config
|
||||
PKG_RELEASE:=6
|
||||
PKG_RELEASE:=7
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
|
|
|
@ -19,14 +19,10 @@ configure() {
|
|||
uci set network.client.ip4table='fff'
|
||||
|
||||
# ip6addr
|
||||
#remove old ip6addr
|
||||
for ip in $(uci get network.client.ip6addr); do
|
||||
if echo "$ip" | grep -v -e "fdff:" -e "fe80::1/64" > /dev/null; then
|
||||
uci del_list network.client.ip6addr="$ip"
|
||||
fi
|
||||
done
|
||||
#set new ip6addr
|
||||
if ip6addr=$(uci -q get gateway.@client[0].ip6addr); then
|
||||
#remove old ip6addr
|
||||
uci delete network.client.ip6addr
|
||||
for ip in $ip6addr; do
|
||||
uci add_list network.client.ip6addr=$ip
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue