2019-05-13 23:30:48 +02:00
|
|
|
# load board specific properties
|
|
|
|
BOARD="$(uci get board.model.name)"
|
|
|
|
. /etc/network.$BOARD
|
|
|
|
|
|
|
|
|
|
|
|
configure() {
|
|
|
|
# ipaddr
|
|
|
|
#remove old ipaddr
|
2020-12-18 20:49:01 +01:00
|
|
|
uci -q del network.client.ipaddr
|
2019-05-13 23:30:48 +02:00
|
|
|
#set new ipaddr
|
|
|
|
if ipaddr=$(uci -q get gateway.@client[0].ipaddr); then
|
|
|
|
for ip in $ipaddr; do
|
2020-12-18 20:49:01 +01:00
|
|
|
uci add_list network.client.ipaddr=$ip
|
2019-05-13 23:30:48 +02:00
|
|
|
done
|
|
|
|
else
|
|
|
|
echo "WARNING: No client ipaddr set!"
|
|
|
|
fi
|
|
|
|
#put interface routes from set addresses into fff table
|
2020-12-18 20:49:01 +01:00
|
|
|
uci set network.client.ip4table='fff'
|
2019-05-13 23:30:48 +02:00
|
|
|
|
|
|
|
# ip6addr
|
|
|
|
#remove old ip6addr
|
2021-12-21 07:31:58 +01:00
|
|
|
for ip in $(uci -q get network.client.ip6addr); do
|
2019-05-13 23:30:48 +02:00
|
|
|
if echo "$ip" | grep -v -e "fdff:" -e "fe80::1/64" > /dev/null; then
|
2020-12-18 20:49:01 +01:00
|
|
|
uci del_list network.client.ip6addr="$ip"
|
2019-05-13 23:30:48 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
#set new ip6addr
|
|
|
|
if ip6addr=$(uci -q get gateway.@client[0].ip6addr); then
|
|
|
|
for ip in $ip6addr; do
|
2020-12-18 20:49:01 +01:00
|
|
|
uci add_list network.client.ip6addr=$ip
|
2019-05-13 23:30:48 +02:00
|
|
|
done
|
|
|
|
else
|
|
|
|
echo "WARNING: No client ip6addr set!"
|
|
|
|
fi
|
|
|
|
#put interface routes from set addresses into fff table
|
2020-12-18 20:49:01 +01:00
|
|
|
uci set network.client.ip6table='fff'
|
2019-05-13 23:30:48 +02:00
|
|
|
|
|
|
|
# dhcp
|
2020-12-18 20:49:01 +01:00
|
|
|
uci -q del dhcp.client.start
|
|
|
|
uci -q del dhcp.client.limit
|
2019-05-13 23:30:48 +02:00
|
|
|
if dhcp_start=$(uci -q get gateway.@client[0].dhcp_start); then
|
2020-12-18 20:49:01 +01:00
|
|
|
uci set dhcp.client=dhcp
|
|
|
|
uci set dhcp.client.interface=client
|
|
|
|
uci set dhcp.client.start=$dhcp_start
|
|
|
|
uci set dhcp.client.limit=$(uci -q get gateway.@client[0].dhcp_limit)
|
2019-05-13 23:30:48 +02:00
|
|
|
else
|
|
|
|
echo "WARNING: No DHCP range start and/or limit set!"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# set interface
|
|
|
|
#remove all eth interfaces
|
2021-02-12 03:39:47 +01:00
|
|
|
ifaces=$(uci get network.client.ifname | sed 's/\beth[^ ]* *//g' | sed 's/\bswitch[^ ]* *//g')
|
2019-05-13 23:30:48 +02:00
|
|
|
if vlan=$(uci -q get gateway.@client[0].vlan); then
|
2020-12-18 20:49:01 +01:00
|
|
|
uci set network.client.ifname="${SWITCHDEV}.$vlan $ifaces"
|
2019-05-13 23:30:48 +02:00
|
|
|
elif iface=$(uci -q get gateway.@client[0].iface); then
|
2020-12-18 20:49:01 +01:00
|
|
|
uci set network.client.ifname="$iface $ifaces"
|
2019-05-13 23:30:48 +02:00
|
|
|
else
|
|
|
|
echo "WARNING: No Interface for client specified"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
apply() {
|
|
|
|
uci commit network
|
|
|
|
uci commit dhcp
|
|
|
|
}
|
|
|
|
|
|
|
|
revert() {
|
|
|
|
uci revert network
|
|
|
|
uci revert dhcp
|
|
|
|
}
|