router.firewall.nat replaces the dnat/toPort/hairpin fields of the filter rules. Filter rules gain natOnly, and may use wan with log and rate limit in the web UI. The Firewall page edits the NAT table and can add the matching allow rule. Settings schema 1 (migrations/1.jq) converts old forwards. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeFqV9dZrK6nipHkPfyM4F
29 lines
1.6 KiB
Bash
29 lines
1.6 KiB
Bash
# The web UI on your own machine, with sample settings, leases and your real
|
|
# interface counters. Templates and CSS are re-read on every request: edit,
|
|
# reload the browser. (Pings need root and fail here; applying does nothing.)
|
|
root=$(git rev-parse --show-toplevel)
|
|
dir=$(mktemp -d)
|
|
trap 'rm -rf "$dir"' EXIT
|
|
mkdir -p "$dir/config"
|
|
wan=$(ip -j route show default 2>/dev/null | jq -r '.[0].dev // empty')
|
|
lan=$(ip -j link show 2>/dev/null | jq -r --arg wan "$wan" '[.[] | select(.link_type == "ether" and .ifname != $wan) | .ifname][0] // "eth1"')
|
|
cat > "$dir/config/settings.json" <<JSON
|
|
{"version": 1, "system": {"hostName": "dev"},
|
|
"router": {"wan": {"interface": "${wan:-eth0}", "ipv4": {"type": "dhcp"}},
|
|
"lans": {"lan": {"interface": "$lan", "internet": true, "ipv4": {"address": "192.168.10.1"},
|
|
"dhcp": {"pool": {"start": "192.168.10.100", "end": "192.168.10.200"}}}}}}
|
|
JSON
|
|
now=$(date +%s)
|
|
cat > "$dir/leases" <<LEASES
|
|
address,hwaddr,client_id,valid_lifetime,expire,subnet_id,fqdn_fwd,fqdn_rev,hostname,state,user_context,pool_id
|
|
192.168.10.101,52:54:00:12:34:56,,3600,$((now + 3000)),1,0,0,laptop,0,,0
|
|
192.168.10.120,52:54:00:aa:bb:cc,,3600,$((now + 1200)),1,0,0,phone,0,,0
|
|
LEASES
|
|
echo '{"version": "0.0.0-dev", "serial": 1, "schema": 1}' > "$dir/router-release"
|
|
cd "$root/pkgs/router-webui"
|
|
echo devpassword1 | go run . passwd "$dir/webui-password"
|
|
echo
|
|
echo " https://127.0.0.1:8443 password: devpassword1 (the certificate is self-signed)"
|
|
echo
|
|
exec go run . -listen 127.0.0.1:8443 -config "$dir/config" -state "$dir" -leases "$dir/leases" -assets .
|