firmware/src/packages/fff/fff-layer3-snat/files/etc/layer3.d/33-snat.conf

35 lines
818 B
Plaintext

configure() {
# first we delete the snat config
uci -q del network.client.fff_snat
uci -q del network.client.fff_snat_sourceip
if [ "$(uci -q get gateway.@client[0].snat)" = '1' ]; then
# first check the config is plausible
if ! routerip=$(uci -q get gateway.meta.router_ip); then
echo "ERROR: No router_ip set, which is required for SNAT!"
return 1
fi
if ! uci -q get gateway.@client[0].ipaddr >/dev/null; then
echo "ERROR: No ipaddr set, which is required for SNAT!"
return 1
fi
# keep only the first IP
routerip=${routerip%% *}
# keep only the IP without the CIDR
routerip=${routerip%%/*}
# We set the snat config
uci set network.client.fff_snat=1
uci set network.client.fff_snat_sourceip=$routerip
fi
}
apply() {
uci commit network
}
revert() {
uci revert network
}