Dawnline 0.20.0
Build packages / CI (push) Blocked by required conditions
Build packages / Version (push) Waiting to run
CI / Web (format, types, tests, bundles) (push) Blocked by required conditions
CI / ShellCheck (push) Blocked by required conditions
CI / Backend (Go: vet, tests, a real ubusd and uhttpd) (push) Blocked by required conditions
CI / Package files (push) Blocked by required conditions

- **Backend rewritten in Go.** One daemon, `dawnlined`, replaces the whole ucode backend: the rpcd plugin, the agent, the CLI and the updater. The package no longer depends on ucode.
- **Per-architecture builds.** The release carries the backend for arm64, ARMv7, mips, mipsle and amd64; the router fetches its own after the package is installed and checks its sha256. Dawnline does not run on other architectures (older ARM, 32-bit x86, RISC-V).
- **Faster on the router.** A firewall sync takes 0.06 s instead of 0.9 s; a full apply takes about 300 ms. The portal is served by the daemon itself, without a CGI process per request.
- **Live pages.** The admin and the portal follow a live stream from the router instead of re-fetching the whole state every 30 seconds.
- **Admin redesigned in the portal's style.** Three sections (Overview · Log · Settings); a server is a page of its own with People, Places and Settings; a device opens as a dialog over its person.
- **Changes wait for «Apply».** Every setting, and a person's access, is staged in one dock before it reaches the router.
- **Configuration rollout.** After a change that makes devices fetch their configuration again, the admin shows how many have fetched it and who has not. Every setting shows beforehand (⟳N) how many devices it will touch.
- **Waiting for a decision.** Overview and People put first the people who need one (access ended, limit reached, a device that does not connect), each with its one action a tap away.
- **Bulk actions on people.** «Select» (or a long press on a card) picks several people to extend by a month, pause or resume at once.
- **Undo.** An action done from a card or a request is undone from its toast.
- **Update dialogs redesigned.** An update is one view from its question to its result; Dawnline's own update runs in it like every other, and the page reloads itself once the new version answers. Other versions are a list, each with its notes and Install on a page of its own.
- **Site to site: networks behind a router.** A router connected as a device can have networks behind it (up to eight, /16 to /30): the server routes them and applies the router's access to them. A network that shares addresses with a tunnel, the router's own networks or another site is refused by name.
- **Routers from the portal.** People can add a router and name its networks on their own page; the admin accepts or declines with a reason, or lets them through without asking.
- **Check access and Health know the networks behind routers.**
- **Usage limits reworked.** A monthly limit no longer follows the calendar. A person's month starts with their first traffic and ends a month later; the next one starts only when they connect again, so time away uses up none of it. Before, everyone's limit reset on the 1st.
- Extra data lasts until that person's month ends; «Reset usage» starts the month anew.
- A limit is for a month or for the whole term; the admin and the portal show when it resets.
- Charts that said «this month» show the last 30 days.
- After the update nobody loses what was counted: the month that was running becomes the person's first and ends on the 1st.
- **Access by time of day removed.** The Hours limit is gone from the admin, the portal and the backend; saved hours are dropped.
- **Expiry simplified.** An end date always stops access, with a heads-up three days before; the per-person choice is gone.
- **No false disconnects from sleeping phones.** A phone or a tablet stays online through ten minutes of silence.
- **Mobile Safari fixes.** Pressing a control no longer sends the page to its top; tab tracks that do not fit scroll; switches animate after a press.
This commit is contained in:
Aemeath committed 2026-11-13 09:43:50 +03:00
1 parent f8130e39a8
commit ac90575b0b
788 files changed
+139244 -41720

No files matched your search

+238
View File
@@ -0,0 +1,238 @@
package apply
import (
"fmt"
"os"
"strconv"
"strings"
"time"
"github.com/tickcount/luci-app-dawnline/backend/awg"
"github.com/tickcount/luci-app-dawnline/backend/files"
"github.com/tickcount/luci-app-dawnline/backend/i18n"
"github.com/tickcount/luci-app-dawnline/backend/model"
"github.com/tickcount/luci-app-dawnline/backend/usage"
)
// The full apply (dawnline.apply apply): the settings turned into router state. Network interfaces, the
// firewall, the home-like path and the Home-only resolver, the reply table, then the runtime sync with the
// access table rebuilt. One lock ("apply") for all of it, the settings read inside it, so a rebuild and a
// runtime sync never interleave and the last one to run works from the newest settings.
// Full is what a full apply came to.
type Full struct {
Network, Firewall bool
// LikeHome is true while the home-like path is up, false when nobody wants it, or why it cannot be:
// {error: a sentence in the admin's language}.
LikeHome any
Peers map[string]string
Warning string
}
// uc writes a value as ucode's "%J" does: the agent compares the signature as text.
func uc(v any) string {
switch x := v.(type) {
case nil:
return "null"
case bool:
return strconv.FormatBool(x)
case string:
return strconv.Quote(x)
case []string:
if len(x) == 0 {
return "[ ]"
}
q := make([]string, len(x))
for i, s := range x {
q[i] = strconv.Quote(s)
}
return "[ " + strings.Join(q, ", ") + " ]"
case []any:
if len(x) == 0 {
return "[ ]"
}
q := make([]string, len(x))
for i, s := range x {
q[i] = uc(s)
}
return "[ " + strings.Join(q, ", ") + " ]"
case [][2]any:
if len(x) == 0 {
return "{ }"
}
q := make([]string, len(x))
for i, kv := range x {
q[i] = strconv.Quote(kv[0].(string)) + ": " + uc(kv[1])
}
return "{ " + strings.Join(q, ", ") + " }"
}
return "null"
}
func orNull(s string) any {
if s == "" {
return nil
}
return s
}
// NetSignature is everything on the router that Dawnline's state is derived from: WAN and LAN, the home
// networks and zones of each server, the netns address and the LAN's DNS (dawnline.apply net_signature).
// An apply is due again when it changes (LAN renumbered, interface added, bridge recreated, DHCP DNS changed).
func (r *Router) NetSignature(m *model.Model) string {
snap := r.Snapshot()
var servers [][2]any
for _, id := range m.ServerIDs() {
wan, home, nets, zones := snap.ServerNet(m.Servers[id])
homes := []any{}
for _, h := range home {
homes = append(homes, [][2]any{{"dev", h.Dev}, {"auto", h.Auto}, {"nets", append([]string{}, h.Nets...)}, {"zone", orNull(h.Zone)}, {"missing", h.Missing}})
}
servers = append(servers, [2]any{id, [][2]any{
{"wan", [][2]any{{"dev", orNull(wan.Dev)}, {"auto", wan.Auto}, {"zone", wan.Zone}, {"missing", wan.Missing}}},
{"home", homes}, {"nets", append([]string{}, nets...)}, {"zones", append([]string{}, zones...)}}})
}
var addrs any
if lan := snap.Devices[snap.LAN]; lan != nil {
addrs = append([]string{}, lan.Addrs...)
}
active, address, known, _ := r.likeHome()
var loop any
if active {
loop = orNull(address)
}
return uc([][2]any{{"wan", orNull(snap.WAN)}, {"lan", orNull(snap.LAN)}, {"addrs", addrs}, {"servers", servers},
{"dns", orNull(r.lanDNS(snap, known))}, {"loop", loop}})
}
// loopErrorText says why the home-like path is off, in the reader's language (dawnline.loop error_text).
func loopErrorText(e map[string]any, t *i18n.Catalog) string {
switch e["code"] {
case "no_lan":
return t.T("No LAN detected.")
case "not_bridge":
return fmt.Sprintf(t.T("%s is not a bridge, so Dawnline cannot join the LAN as a device."), e["dev"])
case "no_ipv4":
return fmt.Sprintf(t.T("%s has no IPv4 address."), e["dev"])
case "no_address":
return fmt.Sprintf(t.T("No free address on %s."), e["net"])
case "no_transit":
return t.T("No free link-local range for the internal link.")
case "no_table":
return t.T("No free routing table.")
}
return fmt.Sprintf(t.T("Setup failed: %s"), e["detail"])
}
func count(n int, one, many string) string {
if n == 1 {
return "1 " + one
}
return strconv.Itoa(n) + " " + many
}
// Apply is the full apply. load reads the settings anew (with the LAN address kept for the home-like
// path) once the lock is held; tools tells whether amneziawg-tools is there, caps what this AmneziaWG runs.
func (r *Router) Apply(load func() (*model.Model, string, error), u *usage.Usage, t *i18n.Catalog, tools bool, caps awg.Caps) Full {
t0 := time.Now()
r.say("debug", "apply", "applying the configuration")
step := func(name string, fn func() string) {
at := time.Now()
what := fn()
if what != "" {
what = " · " + what
}
r.say("debug", "apply", fmt.Sprintf("%s done in %d ms%s", name, time.Since(at).Milliseconds(), what))
}
changed := func(x bool) string {
if x {
return "changed"
}
return "unchanged"
}
unlock := files.Lock(r.RunDir, "apply")
m, saved, err := load()
if err != nil {
unlock()
r.say("error", "apply", "the settings could not be read: nothing was applied · "+err.Error())
return Full{Warning: err.Error(), LikeHome: false}
}
var out Full
var lp Loop
var s Result
step("network (netifd)", func() string { out.Network = r.Netifd(m, tools, caps); return changed(out.Network) })
step("firewall (fw4)", func() string { out.Firewall = r.Fw(m); return changed(out.Firewall) })
step("internet like a home device", func() string { lp = r.LoopEnsure(m, saved, true); return "" })
step("resolver for Home-only devices", func() string { r.SyncResolver(m); return "" })
step("reply routes", func() string { r.ReplyRoutes(m); return "" })
step("access rules and devices", func() string { s = r.sync(m, u, time.Now().Unix(), true, t); return "" })
os.MkdirAll(r.RunDir, 0o755)
os.WriteFile(r.RunDir+"/net.sig", []byte(r.NetSignature(m)), 0o644)
present := s.Table != "" && r.Present()
unlock()
// the address is kept once the lock is released: the settings' own lock is never taken inside it
if lp.Plan != nil && lp.Plan.Address != "" && lp.Plan.Address != saved && r.Remember != nil {
r.Remember(lp.Plan.Address)
}
took := fmt.Sprintf("configuration applied in %d ms · %s, %s, %s", time.Since(t0).Milliseconds(),
count(len(m.Servers), "server", "servers"), count(len(m.People), "person", "people"), count(len(m.Devices), "device", "devices"))
// the same as the warning, for syslog: in English whatever the admin's language
var facts []string
if s.Table != "" {
if present {
facts = append(facts, "access rules not updated, the previous ones stay: "+s.Table)
} else {
facts = append(facts, "access rules not loaded, no device loaded: "+s.Table)
}
}
for _, id := range m.ServerIDs() {
if res, has := s.Peers[id]; has && res != "ok" && res != "down" {
facts = append(facts, m.Servers[id].Name+": devices not loaded: "+res)
}
}
if len(facts) > 0 {
r.say("warn", "apply", took+" · "+strings.Join(facts, " · "))
} else {
r.say("info", "apply", took)
}
out.Peers, out.Warning = s.Peers, s.Warning
out.LikeHome = !lp.Off
if lp.Error != nil {
note := LoopErrorNote(lp.Error)
if lp.Error["code"] == "setup" {
note = fmt.Sprintf("Setup failed: %v", lp.Error["detail"])
}
r.say("warn", "apply", "internet like a home device: "+note)
out.LikeHome = map[string]any{"error": loopErrorText(lp.Error, t)}
}
return out
}
// NetChanged tells whether the router's networks differ from what the last apply worked from.
func (r *Router) NetChanged(m *model.Model) bool {
was, err := os.ReadFile(r.RunDir + "/net.sig")
return err != nil || string(was) != r.NetSignature(m)
}
// Teardown removes everything Dawnline made on the router (dawnline.apply teardown): the home-like path,
// the resolver's configuration, every tunnel interface and firewall section of ours, the reply table, the
// access table and the device names. m is the settings as they stand; nothing of them is written here.
func (r *Router) Teardown(m *model.Model) {
defer files.Lock(r.RunDir, "apply")()
var ifnames []string
for _, id := range m.ServerIDs() {
ifnames = append(ifnames, m.Servers[id].Ifname)
}
r.LoopRemove(ifnames)
os.Remove(r.varEtc() + "/dawnline-dns.conf")
// as with no server and no portal: what is ours is then nobody's, and goes
bare := m.WithoutServers()
bare.Settings.PortalEnabled = false
r.Netifd(bare, true, awg.Caps{})
r.Fw(bare)
r.ReplyRoutes(bare)
r.Exec("nft", "delete", "table", "inet", "dawnline")
os.Remove(r.HostsFile)
os.Remove(r.RunDir + "/net.sig")
r.Exec("killall", "-HUP", "dnsmasq")
}
+243
View File
@@ -0,0 +1,243 @@
package apply
import (
"encoding/json"
"os"
"strings"
"testing"
"github.com/tickcount/luci-app-dawnline/backend/awg"
"github.com/tickcount/luci-app-dawnline/backend/model"
"github.com/tickcount/luci-app-dawnline/backend/netview"
"github.com/tickcount/luci-app-dawnline/backend/uci"
)
// The network signature is ucode's own text: its agent applies again when the two differ (testdata/sig.uc).
func TestNetSignatureAsUcode(t *testing.T) {
raw, err := os.ReadFile("testdata/sig.json")
if err != nil {
t.Fatal(err)
}
var g struct {
Sigs []string `json:"sigs"`
}
if err := json.Unmarshal(raw, &g); err != nil || len(g.Sigs) != 3 {
t.Fatal("the golden is not as expected")
}
raw, err = os.ReadFile("../netview/testdata/trace.json")
if err != nil {
t.Fatal(err)
}
var router struct {
Routes json.RawMessage `json:"routes"`
Addrs json.RawMessage `json:"addrs"`
Firewall string `json:"firewall"`
Links map[string]netview.Link `json:"links"`
}
if err := json.Unmarshal(raw, &router); err != nil {
t.Fatal(err)
}
fw, _ := uci.Parse(router.Firewall)
dir := t.TempDir()
r := &Router{RunDir: dir, Snapshot: func() *netview.Snapshot {
return netview.Take(netview.Sources{Routes: func() []byte { return router.Routes }, Addrs: func() []byte { return router.Addrs },
Links: func() map[string]netview.Link { return router.Links }, Zones: func() netview.Zones { return netview.ZonesOf(fw) }})
}}
text, _ := os.ReadFile("../access/testdata/access.uci")
c, err := uci.Parse(string(text))
if err != nil {
t.Fatal(err)
}
for i, want := range g.Sigs {
switch i {
case 1:
c.SetList("home", "lan_device", []string{"dlhome", "nope0", "lanp1"})
c.Set("cabin", "auto_lan", "1")
c.Set("open", "auto_wan", "0")
c.Set("open", "wan_device", "wg9")
case 2:
c.Set("open", "wan_device", "gone7")
c.SetList("open", "lan_device", []string{"gone8"})
c.Set("cabin", "lan_zone", "lan")
}
m := model.Load(c, nil)
if got := r.NetSignature(m); got != want {
t.Errorf("signature %d:\n%s\n--- ucode:\n%s", i, got, want)
}
if i == 0 {
if !r.NetChanged(m) {
t.Error("no signature kept, and nothing is due")
}
os.WriteFile(dir+"/net.sig", []byte(want), 0o644)
if r.NetChanged(m) {
t.Error("an apply is due with the networks as they were")
}
} else if !r.NetChanged(m) {
t.Error("the networks changed, and no apply is due")
}
}
}
// A plan of the full apply changes nothing: after a real apply of the same settings it finds nothing to
// do, and after a change it names the lines and the commands, with the router's own files as they were.
func TestApplyPlanChangesNothing(t *testing.T) {
raw, _ := os.ReadFile("../netview/testdata/trace.json")
var router struct {
Routes json.RawMessage `json:"routes"`
Addrs json.RawMessage `json:"addrs"`
Firewall string `json:"firewall"`
Links map[string]netview.Link `json:"links"`
}
if err := json.Unmarshal(raw, &router); err != nil {
t.Fatal(err)
}
dir := t.TempDir()
network, _ := os.ReadFile("testdata/network.uci")
os.WriteFile(dir+"/network", network, 0o644)
os.WriteFile(dir+"/firewall", []byte(router.Firewall), 0o644)
var ran []string
r := &Router{RunDir: dir + "/run", VarEtc: dir + "/etc", ResolverPid: dir + "/pid", SysNet: dir + "/sys", NetnsDir: dir + "/netns", Leases: dir + "/leases",
Network: dir + "/network", Firewall: dir + "/firewall", HostsFile: dir + "/hosts",
Exec: func(name string, args ...string) (string, int) {
line := name + " " + strings.Join(args, " ")
if !asks(name, args) {
ran = append(ran, line)
}
if strings.HasPrefix(line, "nft list") {
return "", 1
}
return "", 0
}}
r.Snapshot = func() *netview.Snapshot {
text, _ := os.ReadFile(dir + "/firewall")
fw, _ := uci.Parse(string(text))
return netview.Take(netview.Sources{Routes: func() []byte { return router.Routes }, Addrs: func() []byte { return router.Addrs },
Links: func() map[string]netview.Link { return router.Links }, Zones: func() netview.Zones { return netview.ZonesOf(fw) }})
}
text, _ := os.ReadFile("../access/testdata/access.uci")
c, _ := uci.Parse(string(text))
// nobody like a home device here: that path has its own test, with a router to answer it
for _, id := range []string{"home", "cabin", "open"} {
c.Set(id, "lan_like", "0")
}
load := func() *model.Model {
var blocked map[string]any
if raw, err := os.ReadFile(dir + "/run/netifd-blocked.json"); err == nil {
json.Unmarshal(raw, &blocked)
}
return model.Load(c, blocked)
}
caps := awg.Caps{V2: true, V3: true}
m := load()
r.Netifd(m, true, caps)
r.Fw(m)
r.LoopEnsure(m, "", true)
r.SyncResolver(m)
r.ReplyRoutes(m)
os.WriteFile(dir+"/run/net.sig", []byte(r.NetSignature(m)), 0o644)
keep := func() string {
out := ""
for _, f := range []string{"/network", "/firewall", "/run/netifd-blocked.json", "/run/loop.json", "/run/iface-intent.json", "/etc/dawnline-dns.conf", "/run/net.sig"} {
raw, _ := os.ReadFile(dir + f)
out += f + "\n" + string(raw) + "\n"
}
return out
}
before := keep()
ran = nil
plan := r.ApplyPlan(load(), "", true, caps)
js, _ := json.Marshal(plan)
if plan["network"] != false || plan["firewall"] != false || plan["resolver"] != false || plan["signature"] != true ||
len(plan["would_run"].([]string)) != 0 || len(plan["network_lines"].([]string)) != 0 || plan["like_home"] != "off" {
t.Errorf("something to do right after an apply: %s", js)
}
// a port moved: the plan says so, and the router is as it was
c.Set("home", "port", "4999")
plan = r.ApplyPlan(load(), "", true, caps)
js, _ = json.Marshal(plan)
if plan["network"] != true || plan["firewall"] != true {
t.Errorf("a moved port changes nothing: %s", js)
}
lines := strings.Join(plan["network_lines"].([]string), "\n") + "\n" + strings.Join(plan["firewall_lines"].([]string), "\n")
if !strings.Contains(lines, "- \toption listen_port '4500'") || !strings.Contains(lines, "+ \toption listen_port '4999'") || !strings.Contains(lines, "+ \toption dest_port '4999'") {
t.Errorf("the lines of the change:\n%s", lines)
}
would := strings.Join(plan["would_run"].([]string), "; ")
if !strings.Contains(would, "ubus call network reload") || !strings.Contains(would, "ifup dawn0") || !strings.Contains(would, "fw4 -q reload") {
t.Errorf("the commands of the change: %s", would)
}
if strings.Contains(string(js), "aaaaaaaa") {
t.Error("a key in the plan")
}
if keep() != before || len(ran) != 0 {
t.Errorf("the plan changed the router: ran %v", ran)
}
}
// A teardown leaves the router's network and firewall as they were before Dawnline: what is ours goes,
// what is not stays, an interface of someone else's under a tunnel's name too.
func TestTeardown(t *testing.T) {
raw, _ := os.ReadFile("../netview/testdata/trace.json")
var router struct {
Routes json.RawMessage `json:"routes"`
Addrs json.RawMessage `json:"addrs"`
Firewall string `json:"firewall"`
Links map[string]netview.Link `json:"links"`
}
if err := json.Unmarshal(raw, &router); err != nil {
t.Fatal(err)
}
dir := t.TempDir()
network, _ := os.ReadFile("testdata/network.uci")
os.WriteFile(dir+"/network", network, 0o644)
os.WriteFile(dir+"/firewall", []byte(router.Firewall), 0o644)
os.WriteFile(dir+"/hosts", []byte("10.77.0.2 phone.anna.vpn\n"), 0o644)
var ran []string
r := &Router{RunDir: dir + "/run", VarEtc: dir + "/etc", SysNet: dir + "/sys", NetnsDir: dir + "/netns", Leases: dir + "/leases",
Network: dir + "/network", Firewall: dir + "/firewall", HostsFile: dir + "/hosts",
Exec: func(name string, args ...string) (string, int) {
if !asks(name, args) {
ran = append(ran, name+" "+strings.Join(args, " "))
}
return "", 0
}}
r.Snapshot = func() *netview.Snapshot {
text, _ := os.ReadFile(dir + "/firewall")
fw, _ := uci.Parse(string(text))
return netview.Take(netview.Sources{Routes: func() []byte { return router.Routes }, Addrs: func() []byte { return router.Addrs },
Links: func() map[string]netview.Link { return router.Links }, Zones: func() netview.Zones { return netview.ZonesOf(fw) }})
}
text, _ := os.ReadFile("../access/testdata/access.uci")
c, _ := uci.Parse(string(text))
m := model.Load(c, nil)
r.Netifd(m, true, awg.Caps{V2: true, V3: true})
r.Fw(m)
os.WriteFile(dir+"/run/net.sig", []byte("x"), 0o644)
if now, _ := os.ReadFile(dir + "/firewall"); !strings.Contains(string(now), "dawnline_home_zone") {
t.Fatal("nothing was set up to take down")
}
ran = nil
r.Teardown(model.Load(c, nil))
as := func(text []byte) string { c, _ := uci.Parse(string(text)); return c.Format() }
if now, _ := os.ReadFile(dir + "/network"); string(now) != as(network) {
t.Errorf("the network configuration after:\n%s", now)
}
if now, _ := os.ReadFile(dir + "/firewall"); string(now) != as([]byte(router.Firewall)) {
t.Errorf("the firewall after:\n%s", now)
}
for _, f := range []string{"/hosts", "/run/net.sig"} {
if _, err := os.Stat(dir + f); err == nil {
t.Errorf("%s stays", f)
}
}
did := strings.Join(ran, "; ")
for _, want := range []string{"ifdown dawn0", "ifdown dawn1", "ubus call network reload", "fw4 -q reload", "nft delete table inet dawnline", "killall -HUP dnsmasq"} {
if !strings.Contains(did, want) {
t.Errorf("%s was not run: %s", want, did)
}
}
if strings.Contains(did, "ifdown dawn2") || strings.Contains(did, "ifup") {
t.Errorf("more than ours was touched: %s", did)
}
}
+139
View File
@@ -0,0 +1,139 @@
package apply
import (
"os"
"regexp"
"strings"
"github.com/tickcount/luci-app-dawnline/backend/awg"
"github.com/tickcount/luci-app-dawnline/backend/model"
)
// A full apply with nothing applied: every step runs on copies of the files it would write, the commands
// that only ask the router something are run, and the ones that would change it are noted instead. For
// holding Go's apply to what a router runs now: after the ucode backend applied, it must find nothing to do.
var (
asksOnly = regexp.MustCompile(`^ip (-n dawnline )?(-j |-4 |-6 )*(neigh|link|rule|route|addr) show\b[^;|&]*( 2>/dev/null)?$`)
secret = regexp.MustCompile(`((private|preshared|protection)_?key) '[^']*'`)
)
func asks(name string, args []string) bool {
line := strings.Join(args, " ")
switch name {
case "sh":
return len(args) == 2 && args[0] == "-c" && asksOnly.MatchString(args[1])
case "ip":
return asksOnly.MatchString("ip " + line)
case "nft":
return len(args) > 0 && args[0] == "list"
case "ubus":
return len(args) == 3 && args[0] == "call" && strings.HasPrefix(args[1], "network.interface.") && args[2] == "status"
}
return false
}
// changes is the lines two texts differ in ("-" gone, "+" new), keys never shown.
func changes(was, now string) []string {
out := []string{}
if was == now {
return out
}
count := map[string]int{}
for _, l := range strings.Split(was, "\n") {
count[l]++
}
var added []string
for _, l := range strings.Split(now, "\n") {
if count[l] > 0 {
count[l]--
} else {
added = append(added, l)
}
}
for _, l := range strings.Split(was, "\n") {
if count[l] > 0 {
count[l]--
out = append(out, "- "+secret.ReplaceAllString(l, "$1 '***'"))
}
}
for _, l := range added {
out = append(out, "+ "+secret.ReplaceAllString(l, "$1 '***'"))
}
return out
}
// ApplyPlan is what a full apply would do now, with nothing done: which files would change (their lines),
// which commands would be run, what the home-like path would come to. The runtime sync is Plan's.
func (r *Router) ApplyPlan(m *model.Model, saved string, tools bool, caps awg.Caps) map[string]any {
dir, err := os.MkdirTemp("", "dawnline-plan-")
if err != nil {
return map[string]any{"error": err.Error()}
}
defer os.RemoveAll(dir)
read := func(path string) string {
raw, _ := os.ReadFile(path)
return string(raw)
}
etc := r.varEtc()
os.MkdirAll(dir+"/run", 0o755)
os.MkdirAll(dir+"/etc", 0o755)
for _, f := range []string{"netifd-blocked.json", "netifd-no-awg", "iface-intent.json", "loop.json", "reply.nft", "net.sig"} {
if raw, err := os.ReadFile(r.RunDir + "/" + f); err == nil {
os.WriteFile(dir+"/run/"+f, raw, 0o600)
}
}
for _, f := range []string{"dawnline-dns.conf", "dawnline-dns.resolv", "dawnline-ns.nft"} {
if raw, err := os.ReadFile(etc + "/" + f); err == nil {
os.WriteFile(dir+"/etc/"+f, raw, 0o600)
}
}
os.WriteFile(dir+"/network", []byte(read(r.Network)), 0o600)
os.WriteFile(dir+"/firewall", []byte(read(r.Firewall)), 0o600)
would := []string{}
d := *r
d.RunDir, d.VarEtc, d.Network, d.Firewall, d.Log, d.Remember, d.dry = dir+"/run", dir+"/etc", dir+"/network", dir+"/firewall", nil, nil, true
d.ResolverPid = r.resolverPid()
d.Exec = func(name string, args ...string) (string, int) {
if asks(name, args) {
return r.Exec(name, args...)
}
line := name + " " + strings.Join(args, " ")
if name == "sh" && len(args) == 2 {
line = args[1]
}
would = append(would, strings.ReplaceAll(line, dir+"/etc", etc))
return "", 0
}
out := map[string]any{}
out["network"] = d.Netifd(m, tools, caps)
out["network_lines"] = changes(read(r.Network), read(dir+"/network"))
out["firewall"] = d.Fw(m)
out["firewall_lines"] = changes(read(r.Firewall), read(dir+"/firewall"))
at := len(would)
lp := d.LoopEnsure(m, saved, false)
switch {
case lp.Off:
out["like_home"] = "off"
case lp.Error != nil:
out["like_home"] = lp.Error
default:
out["like_home"] = lp.Plan
}
out["like_home_runs"] = append([]string{}, would[at:]...)
out["like_home_state"] = changes(read(r.RunDir+"/loop.json"), read(dir+"/run/loop.json"))
out["resolver"] = d.SyncResolver(m)
out["resolver_lines"] = append(changes(read(etc+"/dawnline-dns.conf"), read(dir+"/etc/dawnline-dns.conf")),
changes(read(etc+"/dawnline-dns.resolv"), read(dir+"/etc/dawnline-dns.resolv"))...)
at = len(would)
d.ReplyRoutes(m)
out["reply_runs"] = append([]string{}, would[at:]...)
out["reply_lines"] = changes(read(r.RunDir+"/reply.nft"), read(dir+"/run/reply.nft"))
sig := r.NetSignature(m)
out["signature"] = sig == read(r.RunDir+"/net.sig")
if sig != read(r.RunDir+"/net.sig") {
out["signature_now"], out["signature_kept"] = sig, read(r.RunDir+"/net.sig")
}
out["would_run"] = would
return out
}
+250
View File
@@ -0,0 +1,250 @@
package apply
import (
"fmt"
"os"
"regexp"
"strconv"
"strings"
"github.com/tickcount/luci-app-dawnline/backend/ipnet"
"github.com/tickcount/luci-app-dawnline/backend/model"
"github.com/tickcount/luci-app-dawnline/backend/uci"
"github.com/tickcount/luci-app-dawnline/backend/view"
)
// fw4 around the tunnels (dawnline.fw): each tunnel's zone, its forwardings to home and WAN, the WAN rules
// for the tunnels and the portal. Only sections named dawnline_* are ever changed.
const loopZone = "dl_loop"
var notWord = regexp.MustCompile(`[^A-Za-z0-9_]`)
// portalPortOK: never SSH, DNS or the LuCI web server's ports for the portal, whatever the settings say.
func portalPortOK(p int) bool {
return p >= 1 && p <= 65535 && p != 22 && p != 53 && p != 80 && p != 443
}
// portalHTTP tells whether the portal also answers plain HTTP: IP addresses have no certificate.
func portalHTTP(m *model.Model) bool {
for _, h := range view.PortalHosts(m) {
if _, is := ipnet.IP(h); is {
return true
}
}
return false
}
// firewall brings a firewall configuration in line with the servers and the portal; whether it changed,
// and what changed section by section (level, line) for the log.
func (r *Router) firewall(c *uci.Config, m *model.Model) (changed bool, notes [][2]string) {
want := map[string]bool{}
sec := func(name, kind string, opts ...opt) {
want[name] = true
created := false
if s := c.Section(name); s == nil || s.Type != kind {
c.DeleteSection(name)
c.Add(kind, name)
created = true
}
var diff []opt
for _, o := range opts {
if put(c, name, o) {
diff = append(diff, o)
}
}
switch {
case created:
changed = true
notes = append(notes, [2]string{"info", fmt.Sprintf("%s %s: created · %s", kind, name, optsText(opts))})
case len(diff) > 0:
changed = true
notes = append(notes, [2]string{"info", fmt.Sprintf("%s %s: updated · %s", kind, name, optsText(diff))})
default:
notes = append(notes, [2]string{"debug", fmt.Sprintf("%s %s: unchanged", kind, name)})
}
}
snap := r.Snapshot()
portalZone := ""
wantLoop, anyLoop := false, false
// Where tunnel DNS is sent (dawnline.nft): into the netns for home names while any server runs "like a
// home device", and to the LAN's DNS for everyone else. A server that does not forward to those zones on
// its own gets a rule for port 53 alone.
for _, srv := range m.Servers {
anyLoop = anyLoop || (srv.LanLike && tunnelOK(srv))
}
_, _, known, _ := r.likeHome()
lanDNS := r.lanDNS(snap, known)
lanDNSZone := ""
if ip, ok := ipnet.IP(lanDNS); ok {
for _, name := range snap.Names() {
d := snap.Devices[name]
if d.Zone == "" || lanDNSZone != "" {
continue
}
for _, n := range d.Nets {
if c, ok := ipnet.Any(n); ok && c.Holds(ip) {
lanDNSZone = d.Zone
break
}
}
}
}
for _, id := range m.ServerIDs() {
srv := m.Servers[id]
if !tunnelOK(srv) {
continue
}
z := "dawnline_" + id
wan, _, _, zones := snap.ServerNet(srv)
if portalZone == "" {
portalZone = wan.Zone
}
if !srv.LanLike && anyLoop {
sec(z+"_loopdns", "rule", opt{key: "name", val: "Dawnline-" + srv.Ifname + "-names"}, opt{key: "src", val: srv.Ifname}, opt{key: "dest", val: loopZone},
opt{key: "proto", val: "tcp udp"}, opt{key: "dest_port", val: "53"}, opt{key: "target", val: "ACCEPT"})
}
reaches := false
for _, zone := range zones {
reaches = reaches || zone == lanDNSZone
}
if lanDNSZone != "" && lanDNSZone != srv.Ifname && !reaches {
sec(z+"_landns", "rule", opt{key: "name", val: "Dawnline-" + srv.Ifname + "-dns"}, opt{key: "src", val: srv.Ifname}, opt{key: "dest", val: lanDNSZone},
opt{key: "dest_ip", val: lanDNS}, opt{key: "proto", val: "tcp udp"}, opt{key: "dest_port", val: "53"}, opt{key: "target", val: "ACCEPT"})
}
// forward within the zone (device to device) is decided by the inet dawnline table
sec(z+"_zone", "zone", opt{key: "name", val: srv.Ifname}, opt{key: "network", list: []string{srv.Ifname}},
opt{key: "input", val: "ACCEPT"}, opt{key: "output", val: "ACCEPT"}, opt{key: "forward", val: "ACCEPT"})
// Access per person is enforced by the inet dawnline table; the zone only needs to be allowed to reach
// each home-network zone and WAN. The home network may open connections to the devices too (a router
// or a NAS on the tunnel); their answers pass the table as established.
for i, zone := range zones {
if zone == wan.Zone || zone == srv.Ifname {
continue
}
sfx := ""
if i > 0 {
sfx = "_" + notWord.ReplaceAllString(zone, "_")
}
sec(z+"_lan"+sfx, "forwarding", opt{key: "src", val: srv.Ifname}, opt{key: "dest", val: zone})
sec(z+"_from_lan"+sfx, "forwarding", opt{key: "src", val: zone}, opt{key: "dest", val: srv.Ifname})
}
sec(z+"_wan", "forwarding", opt{key: "src", val: srv.Ifname}, opt{key: "dest", val: wan.Zone})
if srv.LanLike {
sec(z+"_loop", "forwarding", opt{key: "src", val: srv.Ifname}, opt{key: "dest", val: loopZone})
wantLoop = true
}
off := opt{key: "enabled"}
if !srv.Enabled {
off.val = "0"
}
sec(z+"_port", "rule", opt{key: "name", val: "Dawnline-" + srv.Ifname}, opt{key: "src", val: wan.Zone}, opt{key: "proto", val: "udp"},
opt{key: "dest_port", val: strconv.Itoa(srv.Port)}, opt{key: "target", val: "ACCEPT"}, off)
}
outside := portalZone
if outside == "" {
outside = "wan"
}
// the link into the netns that re-enters the router from the LAN
if wantLoop {
sec("dawnline_loop", "zone", opt{key: "name", val: loopZone}, opt{key: "device", list: []string{"dlx0"}},
opt{key: "input", val: "REJECT"}, opt{key: "output", val: "ACCEPT"}, opt{key: "forward", val: "REJECT"})
// the Home-only resolver in the netns reaches its upstream DNS this way
sec("dawnline_loop_wan", "forwarding", opt{key: "src", val: loopZone}, opt{key: "dest", val: outside})
}
if s := m.Settings; s.PortalEnabled && portalPortOK(s.PortalPort) {
sec("dawnline_portal", "rule", opt{key: "name", val: "Dawnline-Portal"}, opt{key: "src", val: outside}, opt{key: "proto", val: "tcp"},
opt{key: "dest_port", val: strconv.Itoa(s.PortalPort)}, opt{key: "target", val: "ACCEPT"})
// IP addresses in links: plain HTTP next to the HTTPS port (80 and 443 stay with the LuCI web server)
if portalHTTP(m) && portalPortOK(s.PortalPort+1) {
sec("dawnline_portal_http", "rule", opt{key: "name", val: "Dawnline-Portal-HTTP"}, opt{key: "src", val: outside}, opt{key: "proto", val: "tcp"},
opt{key: "dest_port", val: strconv.Itoa(s.PortalPort + 1)}, opt{key: "target", val: "ACCEPT"})
}
}
var stale [][2]string
for _, s := range c.Sections {
if strings.HasPrefix(s.Name, "dawnline_") && !want[s.Name] {
stale = append(stale, [2]string{s.Name, s.Type})
}
}
for _, s := range stale {
notes = append(notes, [2]string{"info", fmt.Sprintf("%s %s: removed", s[1], s[0])})
c.DeleteSection(s[0])
changed = true
}
return changed, notes
}
func (r *Router) firewallConfig() (*uci.Config, bool) {
text, _ := os.ReadFile(r.Firewall)
c, err := uci.Parse(string(text))
if err != nil {
r.say("error", "firewall", r.Firewall+" does not parse: nothing was changed · "+err.Error())
return nil, false
}
return c, true
}
// FirewallDiffers tells whether the firewall configuration differs from what Dawnline wants; nothing is
// written (the watchdog's question).
func (r *Router) FirewallDiffers(m *model.Model) bool {
c, ok := r.firewallConfig()
if !ok {
return false
}
changed, _ := r.firewall(c, m)
return changed
}
// Fw brings fw4's configuration in line with the servers and the portal, and reloads fw4 when it
// changed; true when it did.
func (r *Router) Fw(m *model.Model) bool {
c, ok := r.firewallConfig()
if !ok {
return false
}
changed, notes := r.firewall(c, m)
for _, n := range notes {
r.say(n[0], "firewall", n[1])
}
if !changed {
return false
}
if err := commit(r.Firewall, c); err != nil {
r.say("error", "firewall", r.Firewall+" could not be written · "+err.Error())
return false
}
r.ack("firewall")
r.say("info", "firewall", "fw4 -q reload")
r.Exec("fw4", "-q", "reload")
return true
}
// FirewallDrift is what is wrong with Dawnline's firewall, for the watchdog (dawnline.fw drift): "" when
// nothing is; "off": fw4 is not running at all (not ours to start); "changed": the configuration lost or
// changed Dawnline's sections; "not loaded": fw4 runs without them.
func (r *Router) FirewallDrift(m *model.Model) string {
table, code := r.Exec("nft", "-t", "list", "table", "inet", "fw4")
if code != 0 || strings.Trim(table, " \t\r\n\v\f") == "" {
return "off"
}
if r.FirewallDiffers(m) {
return "changed"
}
// named rules show up in fw4's ruleset as comments
var names []string
for _, id := range m.ServerIDs() {
if srv := m.Servers[id]; srv.Enabled && tunnelOK(srv) {
names = append(names, "Dawnline-"+srv.Ifname)
}
}
if m.Settings.PortalEnabled {
names = append(names, "Dawnline-Portal")
}
for _, n := range names {
if !strings.Contains(table, n+`"`) {
return "not loaded"
}
}
return ""
}
+146
View File
@@ -0,0 +1,146 @@
package apply
import (
"encoding/json"
"os"
"strings"
"testing"
"github.com/tickcount/luci-app-dawnline/backend/model"
"github.com/tickcount/luci-app-dawnline/backend/netview"
"github.com/tickcount/luci-app-dawnline/backend/uci"
)
// The router's firewall configuration through a row of changes to access's household: after each, the file
// ucode's firewall sync leaves, whether it changed and what it ran (testdata/fw.uc).
func TestFirewallAsUcode(t *testing.T) {
raw, err := os.ReadFile("testdata/fw.json")
if err != nil {
t.Fatal(err)
}
var trace struct {
Steps []struct {
What string `json:"what"`
Dry bool `json:"dry"`
Changed bool `json:"changed"`
Before string `json:"before"`
Firewall string `json:"firewall"`
Cmds []string `json:"cmds"`
} `json:"steps"`
}
if err := json.Unmarshal(raw, &trace); err != nil {
t.Fatal(err)
}
if len(trace.Steps) != 11 {
t.Fatalf("%d steps", len(trace.Steps))
}
// the router the golden ran on: what its container said of itself (netview's golden, the same run)
raw, err = os.ReadFile("../netview/testdata/trace.json")
if err != nil {
t.Fatal(err)
}
var router struct {
Routes json.RawMessage `json:"routes"`
Addrs json.RawMessage `json:"addrs"`
Links map[string]netview.Link `json:"links"`
}
if err := json.Unmarshal(raw, &router); err != nil {
t.Fatal(err)
}
dir := t.TempDir()
os.WriteFile(dir+"/firewall", []byte(trace.Steps[0].Before), 0o644)
var cmds []string
r := &Router{RunDir: dir + "/run", Firewall: dir + "/firewall", Exec: func(name string, args ...string) (string, int) {
cmds = append(cmds, strings.Join(append([]string{name}, args...), " "))
return "", 0
}}
// as ucode's: the zones are read anew from the firewall as it stands
r.Snapshot = func() *netview.Snapshot {
text, _ := os.ReadFile(dir + "/firewall")
fw, _ := uci.Parse(string(text))
return netview.Take(netview.Sources{Routes: func() []byte { return router.Routes }, Addrs: func() []byte { return router.Addrs },
Links: func() map[string]netview.Link { return router.Links }, Zones: func() netview.Zones { return netview.ZonesOf(fw) }})
}
text, _ := os.ReadFile("../access/testdata/access.uci")
c, err := uci.Parse(string(text))
if err != nil {
t.Fatal(err)
}
for i, want := range trace.Steps {
switch i {
case 2:
c.Set("home", "port", "4501")
c.Set("cabin", "enabled", "0")
c.SetList("home", "lan_device", []string{"dlhome", "dlguest"})
case 3:
c.SetList("open", "lan_device", []string{"dlguest"})
case 4:
c.Set("settings", "portal_port", "443")
case 5:
c.Set("settings", "portal_port", "8443")
c.Delete("settings", "portal_alt")
case 6:
c.Set("home", "port", "4502")
case 7:
c.DeleteSection("cabin")
c.Set("home", "lan_like", "1")
case 8:
c.Set("home", "lan_like", "0")
c.Set("open", "lan_like", "0")
case 9:
text, _ := os.ReadFile(dir + "/firewall")
fw, _ := uci.Parse(string(text))
fw.DeleteSection("dawnline_home_zone")
fw.Add("rule", "dawnline_home_zone")
fw.Set("dawnline_home_zone", "name", "Not a zone")
fw.Add("forwarding", "dawnline_old_wan")
fw.Set("dawnline_old_wan", "src", "dawn9")
os.WriteFile(dir+"/firewall", []byte(fw.Format()), 0o644)
c.Set("settings", "portal_enabled", "0")
}
fail := func(what string, got, exp any) {
t.Errorf("step %d (%s): %s\n go: %v\n ucode: %v", i, want.What, what, got, exp)
}
if got, _ := os.ReadFile(dir + "/firewall"); string(got) != want.Before {
fail("the firewall the step starts from", string(got), want.Before)
}
cmds = nil
m := model.Load(c, nil)
var changed bool
if want.Dry {
changed = r.FirewallDiffers(m)
} else {
changed = r.Fw(m)
}
if changed != want.Changed {
fail("whether it changed", changed, want.Changed)
}
if got, _ := os.ReadFile(dir + "/firewall"); string(got) != want.Firewall {
g, w := strings.Split(string(got), "\n"), strings.Split(want.Firewall, "\n")
for n := 0; n < len(g) || n < len(w); n++ {
if n >= len(g) || n >= len(w) || g[n] != w[n] {
a, b := "(the end)", "(the end)"
if n < len(g) {
a = g[n]
}
if n < len(w) {
b = w[n]
}
fail("the firewall configuration, from a line on", a, b)
break
}
}
os.WriteFile(dir+"/firewall", []byte(want.Firewall), 0o644)
}
// the snapshot's own question to netifd is not the sync's
var ran []string
for _, l := range want.Cmds {
if l != "ubus call network.interface dump" {
ran = append(ran, l)
}
}
if strings.Join(cmds, "; ") != strings.Join(ran, "; ") {
fail("what was run", cmds, ran)
}
}
}
+201
View File
@@ -0,0 +1,201 @@
package apply
import (
"fmt"
"os"
"syscall"
"time"
"github.com/tickcount/luci-app-dawnline/backend/awg"
"github.com/tickcount/luci-app-dawnline/backend/files"
"github.com/tickcount/luci-app-dawnline/backend/health"
"github.com/tickcount/luci-app-dawnline/backend/i18n"
"github.com/tickcount/luci-app-dawnline/backend/model"
"github.com/tickcount/luci-app-dawnline/backend/servicelog"
"github.com/tickcount/luci-app-dawnline/backend/state"
"github.com/tickcount/luci-app-dawnline/backend/usage"
)
// The keeper is what holds the router to the settings between the admin's changes (the ucode agent's
// steps "Access rules", "Internet like a home device" and "Router"): once a minute it pushes devices and
// access sets when something moved, keeps the home-like path and the resolver in step, and applies
// everything again when the router's networks changed under it.
// resyncEvery is how long at most between two runtime syncs, whatever happened.
const resyncEvery = 600
// Keeper keeps one router. The zero value of what it remembers is "nothing seen yet".
type Keeper struct {
R *Router
// Load reads the settings anew, with the LAN address kept for the home-like path.
Load func() (*model.Model, string, error)
// Usage is the counters as the watcher has them; Dump what the tunnels hold right now.
Usage func() *usage.Usage
Dump func() (peers map[string]awg.Peer, reads map[string]string)
// Config is the settings' file: a change by anyone (a method, the CLI, a restore) is seen by its
// inode and time.
Config string
Tools func() bool
Caps func() awg.Caps
// Words is the catalog the log's sentences are written in (English).
Words *i18n.Catalog
states map[string]string
lastSync int64
peers map[string]string
conf string
seenConf bool
baseNet string
pending string
failed map[string]string
}
func (k *Keeper) step(who string, fn func()) {
defer func() {
if e := recover(); e != nil {
msg := fmt.Sprint(e)
if k.failed == nil {
k.failed = map[string]string{}
}
// a new failure in the service log, a repeat in syslog alone
if k.failed[who] != msg && k.R.Log != nil {
k.R.Log.Write("dawnline", "error", "failed: "+msg, "", who, servicelog.Extra{})
} else {
k.R.say("error", "keeper", who+": "+msg)
}
k.failed[who] = msg
return
}
delete(k.failed, who)
}()
fn()
}
func fileSig(path string) string {
st, err := os.Stat(path)
if err != nil {
return ""
}
ino := uint64(0)
if sys, is := st.Sys().(*syscall.Stat_t); is {
ino = uint64(sys.Ino)
}
return fmt.Sprintf("%d/%d", st.ModTime().UnixNano(), ino)
}
func sameStates(a, b map[string]string) bool {
if len(a) != len(b) {
return false
}
for k, v := range a {
if w, has := b[k]; !has || w != v {
return false
}
}
return true
}
// runtime pushes devices and access sets when people's states changed, the settings' file was written,
// the access table is gone (a flushed ruleset: the firewall alone would let every device reach
// everything, so the sync unloads them until it is back), a running tunnel holds other devices than it
// should, or every ten minutes anyway.
func (k *Keeper) runtime(m *model.Model, u *usage.Usage, now int64) {
states := map[string]string{}
for _, id := range m.PersonIDs() {
states[id] = state.Of(m, m.People[id], u, now)
}
// A running tunnel without all of its devices, or with ones it should not have: now, not up to ten
// minutes later. Only where the last sync took: a server that refuses its devices has said so.
if k.Dump != nil {
peers, reads := k.Dump()
for _, id := range m.ServerIDs() {
srv := m.Servers[id]
last := k.peers[id]
if reads[srv.Ifname] != awg.Read || (last != "" && last != "ok" && last != "down") {
continue
}
if d := health.PeerDiff(health.TunnelDevices(m, id, states), peers, srv.Ifname); d.Missing > 0 || d.Extra > 0 {
k.lastSync = 0
}
}
}
conf := fileSig(k.Config)
changed := k.states == nil || !sameStates(states, k.states) || (k.seenConf && conf != k.conf)
if changed || now-k.lastSync > resyncEvery || (len(m.Servers) > 0 && !k.R.Present()) {
k.peers = k.R.Sync(m, u, now, false, k.Words).Peers
k.lastSync = now
}
k.conf, k.seenConf, k.states = conf, true, states
}
// KeepLoop keeps the home-like path and the resolver in step. Cheap when nothing changed; the access
// table is rebuilt when the netns address appears, moves or goes away (the guard allows DNS to it).
func (r *Router) KeepLoop(m *model.Model, saved string, u *usage.Usage, now int64, t *i18n.Catalog) Loop {
unlock := files.Lock(r.RunDir, "apply")
where := func() string {
active, address, _, _ := r.likeHome()
if !active {
address = ""
}
return address + " " + r.ResolverTarget().Mode
}
before := where()
lp := r.LoopEnsure(m, saved, false)
r.SyncResolver(m)
r.ReplyRoutes(m)
if where() != before {
r.sync(m, u, now, true, t)
}
unlock()
if lp.Plan != nil && lp.Plan.Address != "" && lp.Plan.Address != saved && r.Remember != nil {
r.Remember(lp.Plan.Address)
}
return lp
}
// network applies everything again when the router's networks changed under us. Only a change seen on two
// ticks in a row (a bridge recreated or an interface restarting passes), against what the last apply used.
func (k *Keeper) network(m *model.Model, u *usage.Usage) {
sig := k.R.NetSignature(m)
applied := k.baseNet
if raw, err := os.ReadFile(k.R.RunDir + "/net.sig"); err == nil {
applied = string(raw)
}
if applied == "" || sig == applied {
if k.baseNet == "" {
k.baseNet = sig
}
k.pending = ""
return
}
if k.pending != sig {
k.pending = sig
return
}
k.pending = ""
if k.R.Log != nil {
k.R.Log.Write("dawnline", "info", "network changed - Dawnline set itself up again", "", "Router", servicelog.Extra{})
}
k.R.Apply(k.Load, u, k.Words, k.Tools(), k.Caps())
k.baseNet = sig
if raw, err := os.ReadFile(k.R.RunDir + "/net.sig"); err == nil {
k.baseNet = string(raw)
}
}
// Tick is one minute's keeping. Each step on its own: a failing one is logged and the others still run.
func (k *Keeper) Tick() {
m, saved, err := k.Load()
if err != nil {
k.R.say("error", "keeper", "the settings could not be read · "+err.Error())
return
}
u := k.Usage()
if u == nil {
return
}
now := time.Now().Unix()
k.step("Access rules", func() { k.runtime(m, u, now) })
k.step("Internet like a home device", func() { k.R.KeepLoop(m, saved, u, now, k.Words) })
k.step("Router", func() { k.network(m, u) })
}
+139
View File
@@ -0,0 +1,139 @@
package apply
import (
"encoding/json"
"os"
"strings"
"testing"
"time"
"github.com/tickcount/luci-app-dawnline/backend/awg"
"github.com/tickcount/luci-app-dawnline/backend/i18n"
"github.com/tickcount/luci-app-dawnline/backend/model"
"github.com/tickcount/luci-app-dawnline/backend/netview"
"github.com/tickcount/luci-app-dawnline/backend/uci"
"github.com/tickcount/luci-app-dawnline/backend/usage"
)
// The keeper syncs when something moved and not otherwise: the first time, when the settings' file was
// written, when the access table is gone; and it applies everything again only when the router's networks
// stay changed for two ticks.
func TestKeeper(t *testing.T) {
raw, _ := os.ReadFile("../netview/testdata/trace.json")
var router struct {
Routes json.RawMessage `json:"routes"`
Addrs json.RawMessage `json:"addrs"`
Firewall string `json:"firewall"`
Links map[string]netview.Link `json:"links"`
}
if err := json.Unmarshal(raw, &router); err != nil {
t.Fatal(err)
}
dir := t.TempDir()
network, _ := os.ReadFile("testdata/network.uci")
os.WriteFile(dir+"/network", network, 0o644)
os.WriteFile(dir+"/firewall", []byte(router.Firewall), 0o644)
text, _ := os.ReadFile("../access/testdata/access.uci")
c, _ := uci.Parse(string(text))
for _, id := range []string{"home", "cabin", "open"} {
c.Set(id, "lan_like", "0")
}
os.WriteFile(dir+"/dawnline", []byte(c.Format()), 0o600)
present := false
loads, reloads := 0, 0
addrs := router.Addrs
r := &Router{RunDir: dir + "/run", VarEtc: dir + "/etc", SysNet: dir + "/sys", NetnsDir: dir + "/netns", Leases: dir + "/leases",
Network: dir + "/network", Firewall: dir + "/firewall", HostsFile: dir + "/hosts",
Exec: func(name string, args ...string) (string, int) {
line := name + " " + strings.Join(args, " ")
switch {
case line == "nft list table inet dawnline":
if present {
return "", 0
}
return "", 1
case strings.HasPrefix(line, "nft list"):
return "", 1
case name == "nft" && args[0] == "-f":
script, _ := os.ReadFile(args[1])
if strings.HasPrefix(string(script), "flush set") && !present {
return "Error: No such file or directory", 1
}
loads++
present = true
case line == "fw4 -q reload":
reloads++
case name == "awg" && args[0] == "show":
return "", 1
}
return "", 0
}}
r.Snapshot = func() *netview.Snapshot {
text, _ := os.ReadFile(dir + "/firewall")
fw, _ := uci.Parse(string(text))
return netview.Take(netview.Sources{Routes: func() []byte { return router.Routes }, Addrs: func() []byte { return addrs },
Links: func() map[string]netview.Link { return router.Links }, Zones: func() netview.Zones { return netview.ZonesOf(fw) }})
}
u := &usage.Usage{}
k := &Keeper{R: r, Config: dir + "/dawnline", Words: i18n.Use("", ""), Usage: func() *usage.Usage { return u },
Tools: func() bool { return true }, Caps: func() awg.Caps { return awg.Caps{V2: true, V3: true} },
Load: func() (*model.Model, string, error) {
text, _ := os.ReadFile(dir + "/dawnline")
c, err := uci.Parse(string(text))
if err != nil {
return nil, "", err
}
return model.Load(c, nil), "", nil
}}
tick := func(what string, want int) {
t.Helper()
before := loads
k.Tick()
if loads-before != want {
t.Errorf("%s: the table was loaded %d times, not %d", what, loads-before, want)
}
}
tick("the first tick", 1)
tick("nothing moved", 0)
// the settings written by anyone: seen by the file itself
time.Sleep(5 * time.Millisecond)
os.WriteFile(dir+"/dawnline.new", []byte(c.Format()), 0o600)
os.Rename(dir+"/dawnline.new", dir+"/dawnline")
tick("the settings' file replaced", 1)
tick("and nothing since", 0)
// a flushed ruleset: the table is put back on the next tick
present = false
tick("the access table gone", 1)
if reloads != 0 {
t.Errorf("the firewall was reloaded %d times with the networks as they were", reloads)
}
// The router's networks: nothing kept of an apply yet, so the first look is the base. A change that
// passes within a tick sets nothing up again; one that stays does, once.
other := json.RawMessage(strings.ReplaceAll(string(router.Addrs), "192.168.77.1", "192.168.78.1"))
if string(other) == string(router.Addrs) {
t.Fatal("the router's addresses are not what this test changes")
}
addrs = other
k.Tick()
addrs = router.Addrs
k.Tick()
if _, err := os.Stat(dir + "/run/net.sig"); err == nil {
t.Error("a change that passed set everything up again")
}
addrs = other
k.Tick()
k.Tick()
sig, err := os.ReadFile(dir + "/run/net.sig")
if err != nil || !strings.Contains(string(sig), "192.168.78.1") {
t.Errorf("a change that stayed did not set everything up again: %s", sig)
}
if now, _ := os.ReadFile(dir + "/firewall"); !strings.Contains(string(now), "dawnline_home_zone") {
t.Error("the apply after the change left no firewall of ours")
}
before := reloads
k.Tick()
k.Tick()
if reloads != before {
t.Error("applied again with the networks as the last apply saw them")
}
}
+807
View File
@@ -0,0 +1,807 @@
package apply
import (
"encoding/json"
"fmt"
"os"
"path/filepath"
"reflect"
"strconv"
"strings"
"time"
"github.com/tickcount/luci-app-dawnline/backend/files"
"github.com/tickcount/luci-app-dawnline/backend/ipnet"
"github.com/tickcount/luci-app-dawnline/backend/model"
"github.com/tickcount/luci-app-dawnline/backend/servicelog"
"github.com/tickcount/luci-app-dawnline/backend/uci"
)
// "Like a home device" (dawnline.loop): tunnel clients' internet traffic enters the router from the LAN,
// so whatever handles LAN traffic there (proxies, DPI bypass, DNS filters, fw4's lan zone) handles it too.
//
// dawn0 ──policy route──▶ dlx0 ═veth═ dlx1 ┐ netns "dawnline" ┌ dll1 ═veth═ dll0 ── br-lan
// └── NAT to a LAN address ┘
//
// The netns is one more device on the LAN bridge with its own address (picked from the LAN's network above
// the DHCP pool) and its own MAC (hashed from the bridge's), the same each time it is made. Everything is
// derived from the router at run time. If the LAN is not a bridge or setup fails, the direct path stays and
// loop.json says why, as a code with its values.
const (
loopNS = "dawnline"
txRoot, txNS, lanRoot, lanNS = "dlx0", "dlx1", "dll0", "dll1"
prefLoopDNS, prefMain, prefLoop = 5205, 5210, 5290
loopWho = "Internet like a home device"
)
// LoopServer is one tunnel on the path: its networks that keep their direct route, and of those the ones
// behind people's routers (nil when there are none: the plan is compared with the one kept in loop.json),
// which the netns answers through the tunnel as it does the tunnel's own subnet.
type LoopServer struct {
Ifname string `json:"ifname"`
Subnet string `json:"subnet"`
Direct []string `json:"direct"`
Behind []string `json:"behind,omitempty"`
}
// LoopPlan is what should exist (dawnline.loop plan), kept in loop.json in ucode's own order of keys.
type LoopPlan struct {
Dev string `json:"dev"`
Gateway string `json:"gateway"`
Address string `json:"address"`
MAC string `json:"mac"`
Prefix int `json:"prefix"`
DNS string `json:"dns"`
Transit uint32 `json:"transit"`
TxRoot string `json:"tx_root"`
TxNS string `json:"tx_ns"`
Table int `json:"table"`
Servers []LoopServer `json:"servers"`
}
// Loop is what bringing the path to the settings came to: off (nobody wants it), a reason it cannot be
// (a code with its values), or the plan that is in place.
type Loop struct {
Off bool
Error map[string]any
Plan *LoopPlan
}
func (r *Router) sysNet() string {
if r.SysNet != "" {
return r.SysNet
}
return "/sys/class/net"
}
func (r *Router) netnsFile() string {
if r.NetnsDir != "" {
return r.NetnsDir + "/" + loopNS
}
return "/var/run/netns/" + loopNS
}
func (r *Router) linkThere(dev string) bool {
_, err := os.Stat(r.sysNet() + "/" + dev)
return err == nil
}
func (r *Router) nsThere() bool {
_, err := os.Stat(r.netnsFile())
return err == nil
}
// sh runs a shell command as ucode's sh(): what it said (both streams) and its exit code.
func (r *Router) sh(cmd string) (string, int) { return r.Exec("sh", "-c", cmd) }
// q quotes a word for the shell.
func q(s string) string { return "'" + strings.ReplaceAll(s, "'", `'\''`) + "'" }
func trimmed(s string) string { return strings.Trim(s, " \t\r\n\v\f") }
// run gives the commands that set the path up or take it down, each in the log as it is given; what failed,
// each with what it said.
func (r *Router) run(cmds []string) []string {
var errs []string
for _, c := range cmds {
r.say("info", "loop", "$ "+c)
}
for _, c := range cmds {
if out, code := r.sh(c); code != 0 {
errs = append(errs, c+": "+trimmed(out))
r.say("error", "loop", "failed: "+c+" · "+trimmed(out))
}
}
return errs
}
func (r *Router) loopLog(level, msg, detail string) {
if r.Log != nil {
r.Log.Write("dawnline", level, msg, detail, loopWho, servicelog.Extra{})
}
}
/* ---------- facts about the LAN ---------- */
type dhcpFacts struct {
pool *[2]uint32
dns string
statics []uint32
}
// dhcpOf is the DHCP pool, static leases and the DNS handed to LAN clients, for one netifd interface.
func (r *Router) dhcpOf(logical string, lan ipnet.Net) dhcpFacts {
var f dhcpFacts
raw, err := os.ReadFile(r.DHCP)
if err != nil {
return f
}
c, err := uci.Parse(string(raw))
if err != nil {
return f
}
for _, s := range c.OfType("dhcp") {
iface, _ := s.Get("interface")
if ignore, _ := s.Get("ignore"); iface != logical || ignore == "1" {
continue
}
num := func(key string, dflt float64) (float64, bool) {
v, has := s.Get(key)
if !has {
return dflt, true
}
return model.Number(v)
}
start, ok1 := num("start", 100)
limit, ok2 := num("limit", 150)
f.pool = nil
if ok1 && ok2 {
f.pool = &[2]uint32{lan.Base + uint32(int64(start)), lan.Base + uint32(int64(start)+int64(limit)) - 1}
}
v := s.Values["dhcp_option"]
opts := v.List
if !v.IsList && v.Str != "" {
opts = []string{v.Str}
}
for _, o := range opts {
if m := dnsOption.FindStringSubmatch(o); m != nil && f.dns == "" {
f.dns = m[2]
}
}
}
for _, s := range c.OfType("host") {
v, _ := s.Get("ip")
if ip, ok := ipnet.IP(v); ok {
f.statics = append(f.statics, ip)
}
}
return f
}
// usedAddresses is the addresses other devices are using right now (neighbour table and leases): each
// with the MAC that holds it ("": one is not known).
func (r *Router) usedAddresses(dev string) map[string]string {
used := map[string]string{}
if out, code := r.sh("ip -j -4 neigh show dev " + q(dev)); code == 0 {
var list []struct {
Dst string `json:"dst"`
Lladdr string `json:"lladdr"`
State []string `json:"state"`
}
if json.Unmarshal([]byte(trimmed(out)), &list) == nil {
for _, n := range list {
if n.Dst != "" && !has(n.State, "FAILED") && !has(n.State, "INCOMPLETE") {
used[n.Dst] = n.Lladdr
}
}
}
}
leases := r.Leases
if leases == "" {
leases = "/tmp/dhcp.leases"
}
raw, _ := os.ReadFile(leases)
for _, l := range strings.Split(string(raw), "\n") {
if f := strings.Split(l, " "); len(f) >= 3 {
used[f[2]] = f[1]
}
}
return used
}
func has(list []string, v string) bool {
for _, x := range list {
if x == v {
return true
}
}
return false
}
// ourMAC is the MAC the netns's LAN link has now; "" without the link.
func (r *Router) ourMAC() string {
out, code := r.sh("ip -n " + loopNS + " -j link show " + lanNS + " 2>/dev/null")
if code != 0 {
return ""
}
var list []struct {
Address string `json:"address"`
}
if json.Unmarshal([]byte(trimmed(out)), &list) != nil || len(list) == 0 {
return ""
}
return list[0].Address
}
func fnv1a(s string, h uint32) uint32 {
for i := 0; i < len(s); i++ {
h = (h ^ uint32(s[i])) * 16777619
}
return h
}
// LanMAC is the MAC for the netns's LAN link, from the bridge's: a locally administered unicast address
// hashed from it, so it is the same every time and differs between routers. Not the bridge's MAC with a
// bit flipped: radios and ports often get those.
func LanMAC(bridge string) string {
s := strings.ToLower(trimmed(bridge))
h1 := fnv1a("dawnline lan "+s, 0x811c9dc5)
h2 := fnv1a(s, h1)
return fmt.Sprintf("%02x:%02x:%02x:%02x:%02x:%02x", ((h1>>24)&0xfc)|0x02, (h1>>16)&0xff, (h1>>8)&0xff, h1&0xff, (h2>>24)&0xff, (h2>>16)&0xff)
}
// addressFree tells whether the netns may use a LAN address: a host of the network, not the router's, not
// a static lease, outside the DHCP pool and not held by another device (an entry with one of the MACs in
// mine is the netns itself, also from before it was made again).
func addressFree(ip, router uint32, lan ipnet.Net, f dhcpFacts, used map[string]string, mine []string) bool {
if ip <= lan.Base || uint64(ip) >= uint64(lan.Base)+lan.Size()-1 || ip == router {
return false
}
for _, s := range f.statics {
if s == ip {
return false
}
}
if f.pool != nil && ip >= f.pool[0] && ip <= f.pool[1] {
return false
}
u, held := used[ipnet.String(ip)]
return !held || (u != "" && has(mine, u))
}
// pickAddress is a LAN address for the netns: the saved one while it is free, otherwise the highest free
// host that does not answer.
func (r *Router) pickAddress(lan ipnet.Net, router uint32, f dhcpFacts, saved, dev string, mine []string) string {
used := r.usedAddresses(dev)
if sv, ok := ipnet.IP(saved); ok && addressFree(sv, router, lan, f, used, mine) {
return ipnet.String(sv)
}
for ip := lan.Base + uint32(lan.Size()) - 2; ip > lan.Base; ip-- {
if !addressFree(ip, router, lan, f, used, mine) {
continue
}
// last check: nobody answers on it
r.sh("ping -c 1 -W 1 -I " + q(dev) + " " + ipnet.String(ip))
if addressFree(ip, router, lan, f, r.usedAddresses(dev), mine) {
return ipnet.String(ip)
}
}
return ""
}
// pickTransit is a /30 in 169.254.0.0/16 that no route or address on the router overlaps.
func (r *Router) pickTransit() (uint32, bool) {
var busy []ipnet.Net
snap := r.Snapshot()
for _, d := range snap.Devices {
for _, n := range append(append([]string{}, d.Nets...), d.Addrs...) {
if c, ok := ipnet.Any(n); ok {
busy = append(busy, c)
}
}
}
for k := 77; k < 77+256; k++ {
base, _ := ipnet.IP(fmt.Sprintf("169.254.%d.0", k%256))
free := true
for _, c := range busy {
if uint64(base) < uint64(c.Base)+c.Size() && uint64(c.Base) < uint64(base)+4 {
free = false
break
}
}
if free {
return base, true
}
}
return 0, false
}
// pickTable is a routing table nobody else uses (ours holds a single route via the transit link).
func (r *Router) pickTable(saved int) (int, bool) {
free := func(t int) bool {
out, code := r.sh("ip -4 route show table " + strconv.Itoa(t))
said := trimmed(out)
if code != 0 || said == "" {
return true
}
return !strings.Contains(said, "\n") && strings.Contains(said, " dev "+txRoot)
}
if saved != 0 && free(saved) {
return saved, true
}
for t := 2077; t < 2177; t++ {
if free(t) {
return t, true
}
}
return 0, false
}
// LoopErrorNote is a reason the path is off, for the service log and syslog: English, like every log line.
func LoopErrorNote(e map[string]any) string {
switch e["code"] {
case "no_lan":
return "No LAN detected."
case "not_bridge":
return fmt.Sprintf("%v is not a bridge, so Dawnline cannot join the LAN as a device.", e["dev"])
case "no_ipv4":
return fmt.Sprintf("%v has no IPv4 address.", e["dev"])
case "no_address":
return fmt.Sprintf("No free address on %v.", e["net"])
case "no_transit":
return "No free link-local range for the internal link."
}
return "No free routing table."
}
/* ---------- plan ---------- */
type loopState struct {
Applied int64 `json:"applied"`
Plan *LoopPlan `json:"plan"`
Transit uint32 `json:"transit"`
Fast *bool `json:"fast"`
Error any `json:"error"`
Off bool `json:"off"`
}
func (r *Router) loopState() loopState {
var s loopState
files.ReadJSON(r.RunDir+"/loop.json", &s)
return s
}
// LoopPlanFor is what should exist for these settings; saved is the LAN address kept from before
// (settings.lan_address). Pure apart from reading the router (and one ping a candidate address).
func (r *Router) LoopPlanFor(m *model.Model, saved string) Loop {
var wanted []*model.Server
for _, id := range m.ServerIDs() {
if s := m.Servers[id]; tunnelOK(s) && s.Enabled && s.LanLike {
wanted = append(wanted, s)
}
}
if len(wanted) == 0 {
return Loop{Off: true}
}
snap := r.Snapshot()
dev := snap.LAN
d := snap.Devices[dev]
if dev == "" || d == nil {
return Loop{Error: map[string]any{"code": "no_lan"}}
}
if d.Kind != "bridge" {
return Loop{Error: map[string]any{"code": "not_bridge", "dev": dev}}
}
var lan ipnet.Net
var router uint32
ok := len(d.Addrs) > 0
if ok {
if lan, ok = ipnet.Subnet(d.Addrs[0]); ok {
router, ok = ipnet.IP(strings.SplitN(d.Addrs[0], "/", 2)[0])
}
}
if !ok {
return Loop{Error: map[string]any{"code": "no_ipv4", "dev": dev}}
}
facts := r.dhcpOf(d.Logical, lan)
bridge, _ := os.ReadFile(r.sysNet() + "/" + dev + "/address")
mac := LanMAC(string(bridge))
// the netns's MACs: the one it gets, and the one it has (a random one from an older version)
addr := r.pickAddress(lan, router, facts, saved, dev, []string{mac, r.ourMAC()})
if addr == "" {
return Loop{Error: map[string]any{"code": "no_address", "net": lan.String()}}
}
last := r.loopState()
tx, ok := r.pickTransit()
if !ok {
return Loop{Error: map[string]any{"code": "no_transit"}}
}
saw := 0
if last.Plan != nil {
saw = last.Plan.Table
}
table, ok := r.pickTable(saw)
if !ok {
return Loop{Error: map[string]any{"code": "no_table"}}
}
p := &LoopPlan{Dev: dev, Gateway: ipnet.String(router), Address: addr, MAC: mac, Prefix: lan.Prefix, DNS: facts.dns, Transit: tx,
TxRoot: ipnet.String(tx + 1), TxNS: ipnet.String(tx + 2), Table: table, Servers: []LoopServer{}}
if p.DNS == "" {
p.DNS = p.Gateway
}
// by the settings alone, whoever is loaded now: the path does not move with people's states
behind := snap.Behind(m)
for _, srv := range wanted {
_, _, nets, _ := snap.ServerNet(srv)
var sites []string
for _, id := range m.DeviceIDs() {
if p := m.People[m.Devices[id].Person]; p != nil && p.Server == srv.ID {
sites = append(sites, behind[id]...)
}
}
if sites != nil {
sites = ipnet.Collapse(sites)
}
p.Servers = append(p.Servers, LoopServer{Ifname: srv.Ifname, Subnet: srv.Subnet,
Direct: ipnet.Collapse(append(append([]string{srv.Subnet}, nets...), sites...)), Behind: sites})
}
return Loop{Plan: p}
}
/* ---------- apply ---------- */
// NSRules is the netns's nft script as text. With fast, a flowtable on the netns's own two links takes
// established TCP and UDP flows past conntrack and the forward hook here. Only dlx1 and dll1: the root
// namespace's links stay out, the guard there sees every packet.
func NSRules(p *LoopPlan, fast bool) string {
ft, add := "", ""
if fast {
ft = "\n\tflowtable ft {\n\t\thook ingress priority 0;\n\t\tdevices = { \"" + txNS + "\", \"" + lanNS + "\" };\n\t}"
add = "\n\t\tct state established meta l4proto { tcp, udp } flow add @ft"
}
return "table inet dawnline\ndelete table inet dawnline\ntable inet dawnline {" + ft + `
chain nat_pre {
type nat hook prerouting priority dstnat; policy accept;
iifname "` + txNS + `" ip daddr ` + p.Address + ` meta l4proto { tcp, udp } th dport 53 dnat ip to ` + p.DNS + `:53
}
chain nat_post {
type nat hook postrouting priority srcnat; policy accept;
oifname "` + lanNS + `" masquerade
}
chain filter_forward {
type filter hook forward priority filter; policy drop;` + add + `
ct state established,related accept
iifname "` + txNS + `" oifname "` + lanNS + `" accept
}
chain filter_input {
type filter hook input priority filter; policy drop;
ct state established,related accept
iifname "lo" accept
icmp type echo-request accept
iifname "` + txNS + `" meta l4proto { tcp, udp } th dport 53 accept
}
}
`
}
// loadNSRules loads the netns's rules, with the flowtable when the kernel takes it, else without (the path
// works either way): slow is why the flowtable failed, err why the rules without it failed too.
func (r *Router) loadNSRules(p *LoopPlan) (fast bool, slow, err string) {
os.MkdirAll(r.varEtc(), 0o755)
path := r.varEtc() + "/dawnline-ns.nft"
load := func(fast bool) string {
os.WriteFile(path, []byte(NSRules(p, fast)), 0o644)
if errs := r.run([]string{"ip netns exec " + loopNS + " nft -f " + path}); len(errs) > 0 {
return errs[0]
}
return ""
}
if slow = load(true); slow == "" {
return true, "", ""
}
return false, slow, load(false)
}
// LoopRule is one policy rule of the path (To "": all).
type LoopRule struct {
Pref int
Iif string
To string
Table string
}
// LoopRules is the policy rules a plan wants, in order. A server interface: DNS to the netns address
// through the netns, home networks and the tunnel network by main, the rest into the netns.
func LoopRules(p *LoopPlan) []LoopRule {
var out []LoopRule
if p == nil {
return out
}
table := strconv.Itoa(p.Table)
for _, s := range p.Servers {
out = append(out, LoopRule{prefLoopDNS, s.Ifname, p.Address + "/32", table})
for _, n := range s.Direct {
out = append(out, LoopRule{prefMain, s.Ifname, n, "main"})
}
out = append(out, LoopRule{prefLoop, s.Ifname, "", table})
}
return out
}
// IPRule is a policy rule as `ip -j -4 rule show` prints it.
type IPRule struct {
Priority int `json:"priority"`
Src string `json:"src"`
Srclen *int `json:"srclen"`
Dst string `json:"dst"`
Dstlen *int `json:"dstlen"`
Iif string `json:"iif"`
Table string `json:"table"`
Detached json.RawMessage `json:"iif_detached"`
}
// currentRules is our policy rules: in our priority band and bound to a Dawnline tunnel interface, or left
// behind by a removed tunnel (its interface is gone).
func (r *Router) currentRules(ifnames []string) []IPRule {
var out []IPRule
said, code := r.sh("ip -j -4 rule show")
if code != 0 {
return out
}
var all []IPRule
if json.Unmarshal([]byte(trimmed(said)), &all) != nil {
return out
}
for _, x := range all {
if x.Priority >= 5200 && x.Priority < 5300 && x.Iif != "" && (has(ifnames, x.Iif) || x.Detached != nil) {
out = append(out, x)
}
}
return out
}
// ruleNet is a source or destination as `ip -j rule` has it, or "" for all.
func ruleNet(addr string, n *int) string {
if addr == "" || addr == "all" {
return ""
}
if n != nil {
return addr + "/" + strconv.Itoa(*n)
}
return addr
}
func ruleKey(pref int, from, iif, to, table string) string {
// `ip -j rule` shows a /32 source or destination without its length
full := func(n string) string {
switch {
case n == "":
return "all"
case !strings.Contains(n, "/"):
return n + "/32"
}
return n
}
return fmt.Sprintf("%d %s %s %s %s", pref, full(from), iif, full(to), table)
}
func ruleDel(x IPRule) string {
cmd := "ip -4 rule del priority " + strconv.Itoa(x.Priority)
if from := ruleNet(x.Src, x.Srclen); from != "" {
cmd += " from " + from
}
cmd += " iif " + q(x.Iif)
if to := ruleNet(x.Dst, x.Dstlen); to != "" {
cmd += " to " + to
}
return cmd + " lookup " + x.Table
}
// RuleCmds is the commands that turn the rules there are into the ones a plan wants: the missing ones
// added first, then the ones no longer wanted removed, so a device's traffic never falls between two
// rules while others change. None when they are as wanted.
func RuleCmds(p *LoopPlan, current []IPRule) []string {
have, want := map[string]IPRule{}, map[string]bool{}
var order, cmds, twice []string
for _, x := range current {
k := ruleKey(x.Priority, ruleNet(x.Src, x.Srclen), x.Iif, ruleNet(x.Dst, x.Dstlen), x.Table)
if _, seen := have[k]; seen {
twice = append(twice, ruleDel(x))
} else {
order = append(order, k)
}
have[k] = x
}
for _, w := range LoopRules(p) {
k := ruleKey(w.Pref, "", w.Iif, w.To, w.Table)
if _, there := have[k]; !there && !want[k] {
cmd := "ip -4 rule add priority " + strconv.Itoa(w.Pref) + " iif " + q(w.Iif)
if w.To != "" {
cmd += " to " + w.To
}
cmds = append(cmds, cmd+" lookup "+w.Table)
}
want[k] = true
}
for _, k := range order {
if !want[k] {
cmds = append(cmds, ruleDel(have[k]))
}
}
// the same rule twice (one deletion removes one of them)
return append(cmds, twice...)
}
// LoopRemove takes away the netns, links and rules, and the router's neighbour entry for the netns.
func (r *Router) LoopRemove(ifnames []string) {
last := r.loopState().Plan
// read while the link is there: the entry is ours when it carries the netns's MAC
stale := false
if last != nil && last.Dev != "" {
held := r.usedAddresses(last.Dev)[last.Address]
stale = held != "" && (held == last.MAC || held == r.ourMAC())
}
var cmds []string
for _, x := range r.currentRules(ifnames) {
cmds = append(cmds, ruleDel(x))
}
if last != nil && last.Table != 0 {
cmds = append(cmds, "ip -4 route flush table "+strconv.Itoa(last.Table))
}
if r.linkThere(txRoot) {
cmds = append(cmds, "ip link del "+txRoot)
}
if r.linkThere(lanRoot) {
cmds = append(cmds, "ip link del "+lanRoot)
}
if r.nsThere() {
cmds = append(cmds, "ip netns del "+loopNS)
}
// left there, it would hold the address for a MAC nobody has
if stale {
cmds = append(cmds, "ip -4 neigh del "+q(last.Address)+" dev "+q(last.Dev))
}
r.run(cmds)
os.Remove(r.RunDir + "/loop.json")
}
func sameJSON(a, b any) bool {
x, _ := json.Marshal(a)
y, _ := json.Marshal(b)
return string(x) == string(y)
}
// LoopEnsure brings the path to the plan. Cheap when nothing changed: it compares with the last applied
// plan and only checks that links, bridge port and rules exist. saved is the LAN address kept from before.
func (r *Router) LoopEnsure(m *model.Model, saved string, force bool) Loop {
state := r.RunDir + "/loop.json"
var ifnames []string
for _, id := range m.ServerIDs() {
ifnames = append(ifnames, m.Servers[id].Ifname)
}
res := r.LoopPlanFor(m, saved)
if res.Plan == nil {
// read before the removal, which deletes it: the error is logged once, not every tick
was := r.loopState()
if was.Plan != nil || r.linkThere(txRoot) || r.linkThere(lanRoot) || len(r.currentRules(ifnames)) > 0 {
r.LoopRemove(ifnames)
}
os.MkdirAll(r.RunDir, 0o755)
var why any
if res.Error != nil {
why = res.Error
}
files.WriteJSON(state, map[string]any{"error": why, "off": res.Off}, 0o644)
if res.Error != nil && !sameJSON(res.Error, was.Error) {
r.loopLog("error", "is off", LoopErrorNote(res.Error))
}
return res
}
p := res.Plan
last := r.loopState()
same := !force && last.Applied != 0 && last.Plan != nil && reflect.DeepEqual(last.Plan, p)
master, _ := os.Readlink(r.sysNet() + "/" + lanRoot + "/master")
healthy := r.linkThere(txRoot) && r.linkThere(lanRoot) && r.nsThere() && master != "" && filepath.Base(master) == p.Dev
if same && healthy && len(RuleCmds(p, r.currentRules(ifnames))) == 0 {
return res
}
// A link made by an older version has a random MAC (its plan had none, so this runs once after an
// update): it gets the stable one.
remac := r.linkThere(lanRoot) && r.ourMAC() != p.MAC
var cmds []string
if !r.nsThere() {
cmds = append(cmds, "ip netns add "+loopNS)
}
if !r.linkThere(txRoot) {
cmds = append(cmds, "ip link add "+txRoot+" type veth peer name "+txNS+" netns "+loopNS)
}
if !r.linkThere(lanRoot) {
cmds = append(cmds, "ip link add "+lanRoot+" type veth peer name "+lanNS+" address "+p.MAC+" netns "+loopNS)
}
if remac {
cmds = append(cmds, "ip -n "+loopNS+" link set "+lanNS+" down", "ip -n "+loopNS+" link set "+lanNS+" address "+p.MAC)
}
errs := r.run(cmds)
n := "ip -n " + loopNS + " "
cmds = []string{
"ip addr flush dev " + txRoot,
"ip addr add " + p.TxRoot + "/30 dev " + txRoot,
"ip link set " + txRoot + " up",
"ip link set " + lanRoot + " master " + q(p.Dev),
"ip link set " + lanRoot + " up",
n + "link set lo up",
n + "addr flush dev " + txNS,
n + "addr add " + p.TxNS + "/30 dev " + txNS,
n + "link set " + txNS + " up",
n + "addr flush dev " + lanNS,
n + "addr add " + p.Address + "/" + strconv.Itoa(p.Prefix) + " dev " + lanNS,
n + "link set " + lanNS + " up",
n + "route replace default via " + p.Gateway + " dev " + lanNS,
// the resolver's own queries (from the transit address) go back out the transit link
n + "route replace default via " + p.TxRoot + " dev " + txNS + " table 100",
n + "rule del from " + p.TxNS + " lookup 100 2>/dev/null; " + n + "rule add from " + p.TxNS + " lookup 100",
"ip netns exec " + loopNS + " sh -c 'echo 1 > /proc/sys/net/ipv4/ip_forward; echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter; echo 0 > /proc/sys/net/ipv4/conf/default/rp_filter'",
"ip -4 route replace default via " + p.TxNS + " dev " + txRoot + " table " + strconv.Itoa(p.Table),
}
// the networks behind routers are answered through the tunnel too; the ones of the plan before go first
sites := false
for _, s := range p.Servers {
sites = sites || len(s.Behind) > 0
}
if last.Plan != nil {
for _, s := range last.Plan.Servers {
sites = sites || len(s.Behind) > 0
}
}
if sites {
cmds = append(cmds, n+"route flush proto "+routeProto+" 2>/dev/null || true")
}
for _, s := range p.Servers {
cmds = append(cmds, n+"route replace "+q(s.Subnet)+" via "+q(p.TxRoot)+" dev "+txNS)
for _, b := range s.Behind {
cmds = append(cmds, n+"route replace "+q(b)+" via "+q(p.TxRoot)+" dev "+txNS+" proto "+routeProto)
}
}
// the router knows the address by the old MAC: ask again now, not when the entry expires
if remac {
cmds = append(cmds, "ip -4 neigh flush to "+p.Address+" dev "+q(p.Dev))
}
errs = append(errs, r.run(cmds)...)
fast, slow, err := r.loadNSRules(p)
if err != "" {
errs = append(errs, err)
}
errs = append(errs, r.run(RuleCmds(p, r.currentRules(ifnames)))...)
if len(errs) > 0 {
why := map[string]any{"code": "setup", "detail": errs[0]}
if !sameJSON(r.loopState().Error, why) {
r.loopLog("error", "failed - internet goes out directly for now", errs[0])
}
r.LoopRemove(ifnames)
files.WriteJSON(state, map[string]any{"error": why}, 0o644)
return Loop{Error: why}
}
os.MkdirAll(r.RunDir, 0o755)
files.WriteJSON(state, loopState2{Applied: time.Now().Unix(), Plan: p, Transit: p.Transit, Fast: fast}, 0o644)
switch {
case last.Applied == 0 || last.Plan == nil || last.Plan.Dev != p.Dev || last.Plan.Address != p.Address:
r.loopLog("up", fmt.Sprintf("is on · traffic enters %s as %s", p.Dev, p.Address), "")
case !healthy:
r.loopLog("repair", fmt.Sprintf("was broken - set up again (%s as %s)", p.Dev, p.Address), "")
}
// once, not again on every apply while the module is still missing
if !fast && (last.Fast == nil || *last.Fast) {
r.loopLog("info", "runs without its fast path",
"Without kmod-nft-offload every packet on this path passes the firewall twice. Install it and restart Dawnline.\n"+slow)
}
return res
}
// loopState2 is loop.json while the path is up, in ucode's own order of keys.
type loopState2 struct {
Applied int64 `json:"applied"`
Plan *LoopPlan `json:"plan"`
Transit uint32 `json:"transit"`
Fast bool `json:"fast"`
}
+372
View File
@@ -0,0 +1,372 @@
package apply
import (
"encoding/json"
"os"
"reflect"
"strconv"
"strings"
"testing"
"github.com/tickcount/luci-app-dawnline/backend/model"
"github.com/tickcount/luci-app-dawnline/backend/netview"
"github.com/tickcount/luci-app-dawnline/backend/servicelog"
"github.com/tickcount/luci-app-dawnline/backend/uci"
)
type loopGolden struct {
Bridge string `json:"bridge"`
DHCP string `json:"dhcp"`
Steps []struct {
What string `json:"what"`
Force bool `json:"force"`
Result json.RawMessage `json:"result"`
State any `json:"state"`
NSRules string `json:"ns_rules"`
Log []map[string]any `json:"log"`
Ran []string `json:"ran"`
Failed []string `json:"failed"`
Pings []string `json:"pings"`
Sys struct {
Dlx0 bool `json:"dlx0"`
Dll0 bool `json:"dll0"`
Netns bool `json:"netns"`
} `json:"sys"`
} `json:"steps"`
Macs [][2]*string `json:"macs"`
Rules struct {
Plan *LoopPlan `json:"plan"`
Want []struct {
Pref int `json:"pref"`
Iif string `json:"iif"`
To *string `json:"to"`
Table string `json:"table"`
} `json:"want"`
Current []IPRule `json:"current"`
Cmds []string `json:"cmds"`
FromNothing []string `json:"from_nothing"`
ToNothing []string `json:"to_nothing"`
} `json:"rules"`
NSRules []string `json:"ns_rules"`
Notes []string `json:"notes"`
}
func loopTrace(t *testing.T) loopGolden {
raw, err := os.ReadFile("testdata/loop.json")
if err != nil {
t.Fatal(err)
}
var g loopGolden
if err := json.Unmarshal(raw, &g); err != nil {
t.Fatal(err)
}
return g
}
// The pure parts of the home-like path, on ucode's own answers (testdata/loop.uc).
func TestLoopPartsAsUcode(t *testing.T) {
g := loopTrace(t)
if len(g.Macs) != 5 {
t.Fatal("the golden is too small")
}
for _, m := range g.Macs {
in := ""
if m[0] != nil {
in = *m[0]
}
if got := LanMAC(in); got != *m[1] {
t.Errorf("the MAC from %q: %s, ucode %s", in, got, *m[1])
}
}
want := LoopRules(g.Rules.Plan)
if len(want) != len(g.Rules.Want) || len(want) == 0 {
t.Fatalf("%d rules, ucode %d", len(want), len(g.Rules.Want))
}
for i, w := range g.Rules.Want {
to := ""
if w.To != nil {
to = *w.To
}
if want[i] != (LoopRule{w.Pref, w.Iif, to, w.Table}) {
t.Errorf("rule %d: %v, ucode %v", i, want[i], w)
}
}
if len(LoopRules(nil)) != 0 {
t.Error("rules from no plan")
}
for _, c := range []struct {
what string
got []string
want []string
}{{"from what there is", RuleCmds(g.Rules.Plan, g.Rules.Current), g.Rules.Cmds}, {"from nothing", RuleCmds(g.Rules.Plan, nil), g.Rules.FromNothing},
{"to nothing", RuleCmds(&LoopPlan{}, g.Rules.Current), g.Rules.ToNothing}} {
if strings.Join(c.got, "\n") != strings.Join(c.want, "\n") || len(c.want) == 0 {
t.Errorf("the commands %s:\n%s\n--- ucode:\n%s", c.what, strings.Join(c.got, "\n"), strings.Join(c.want, "\n"))
}
}
if NSRules(g.Rules.Plan, true) != g.NSRules[0] || NSRules(g.Rules.Plan, false) != g.NSRules[1] {
t.Errorf("the netns's rules:\n%s\n--- ucode:\n%s", NSRules(g.Rules.Plan, true), g.NSRules[0])
}
for i, e := range []map[string]any{{"code": "no_lan"}, {"code": "not_bridge", "dev": "eth1"}, {"code": "no_ipv4", "dev": "br-lan"},
{"code": "no_address", "net": "10.0.1.0/24"}, {"code": "no_transit"}, {"code": "no_table"}} {
if got := LoopErrorNote(e); got != g.Notes[i] {
t.Errorf("the note for %v: %q, ucode %q", e, got, g.Notes[i])
}
}
}
// The home-like path through a row of states of the router: the plan, the commands in their order,
// loop.json, the netns's rules and the service log are ucode's own (testdata/loop.uc). The stand-in for ip
// here keeps the same state the golden's does.
func TestLoopAsUcode(t *testing.T) {
g := loopTrace(t)
if len(g.Steps) != 15 {
t.Fatalf("%d steps", len(g.Steps))
}
raw, err := os.ReadFile("../netview/testdata/trace.json")
if err != nil {
t.Fatal(err)
}
var router struct {
Routes json.RawMessage `json:"routes"`
Addrs json.RawMessage `json:"addrs"`
Links map[string]netview.Link `json:"links"`
}
if err := json.Unmarshal(raw, &router); err != nil {
t.Fatal(err)
}
dir := t.TempDir()
sys, etc := dir+"/sys", dir+"/etc"
os.MkdirAll(sys+"/br-lan", 0o755)
os.WriteFile(sys+"/br-lan/address", []byte(g.Bridge+"\n"), 0o644)
os.MkdirAll(dir+"/netns", 0o755)
os.WriteFile(dir+"/dhcp", []byte(g.DHCP), 0o644)
// what the stand-in is told and keeps
var neigh, nsmac, mac, rules, fail string
var ftFail bool
tables := map[string]string{}
var pings, said []string
there := func(p string) bool { _, err := os.Stat(p); return err == nil }
r := &Router{RunDir: dir + "/run", VarEtc: etc, SysNet: sys, NetnsDir: dir + "/netns", Leases: dir + "/leases", DHCP: dir + "/dhcp"}
r.Snapshot = func() *netview.Snapshot {
return netview.Take(netview.Sources{Routes: func() []byte { return router.Routes }, Addrs: func() []byte { return router.Addrs },
Links: func() map[string]netview.Link { return router.Links },
Logical: func() map[string]netview.Logical {
return map[string]netview.Logical{"br-lan": {Name: "lan", Proto: "static"}}
}})
}
r.Log = &servicelog.Log{RunDir: dir + "/run", Level: func() string { return "info" }, Syslog: func(_, line string) { said = append(said, line) }}
r.Exec = func(name string, args ...string) (string, int) {
if name != "sh" || len(args) != 2 || args[0] != "-c" {
t.Fatalf("not through the shell: %s %v", name, args)
}
cmd := args[1]
plain := strings.ReplaceAll(cmd, "'", "")
if strings.HasPrefix(cmd, "ping ") {
pings = append(pings, plain)
return "", 1
}
if fail != "" && strings.Contains(plain, fail) {
return "RTNETLINK answers: a made-up failure\n", 2
}
word := strings.Fields(plain)
switch {
case strings.HasPrefix(cmd, "ip -j -4 neigh show dev "):
if neigh == "" {
return "[]\n", 0
}
return neigh, 0
case strings.HasPrefix(cmd, "ip -n dawnline -j link show dll1"):
if !there(sys + "/dll0") {
return "", 1
}
if nsmac != "" {
return `[{"address":"` + nsmac + `"}]`, 0
}
return `[{"address":"` + mac + `"}]`, 0
case cmd == "ip -j -4 rule show":
if rules == "" {
return "[]", 0
}
return rules, 0
case strings.HasPrefix(cmd, "ip -4 route show table "):
return tables[word[5]], 0
case cmd == "ip netns add dawnline":
os.WriteFile(dir+"/netns/dawnline", nil, 0o644)
case cmd == "ip netns del dawnline":
os.Remove(dir + "/netns/dawnline")
case strings.HasPrefix(cmd, "ip netns exec dawnline nft -f "):
if text, _ := os.ReadFile(word[6]); ftFail && strings.Contains(string(text), "flowtable") {
return word[6] + ":4:2-10: Error: Could not process rule: No such file or directory\n", 1
}
case strings.HasPrefix(cmd, "ip link add dlx0 "):
os.MkdirAll(sys+"/dlx0", 0o755)
case strings.HasPrefix(cmd, "ip link add dll0 "):
for i, w := range word {
if w == "address" {
mac = word[i+1]
}
}
os.MkdirAll(sys+"/dll0", 0o755)
case strings.HasPrefix(cmd, "ip link del "):
os.RemoveAll(sys + "/" + word[3])
case strings.HasPrefix(cmd, "ip link set dll0 master "):
os.Remove(sys + "/dll0/master")
os.Symlink("../"+word[5], sys+"/dll0/master")
case strings.HasPrefix(cmd, "ip -n dawnline link set dll1 address "):
mac, nsmac = word[7], ""
}
return "", 0
}
text, _ := os.ReadFile("../access/testdata/access.uci")
c, err := uci.Parse(string(text))
if err != nil {
t.Fatal(err)
}
var last *LoopPlan
// the rules a plan wants, as `ip -j -4 rule show` prints them once they are in
shown := func() []map[string]any {
var out []map[string]any
for _, w := range LoopRules(last) {
o := map[string]any{"priority": w.Pref, "src": "all", "iif": w.Iif, "table": w.Table}
if w.To != "" {
parts := strings.SplitN(w.To, "/", 2)
o["dst"] = parts[0]
if n, _ := strconv.Atoi(parts[1]); n != 32 {
o["dstlen"] = n
}
}
out = append(out, o)
}
return out
}
put := func(list []map[string]any) {
raw, _ := json.Marshal(list)
rules = string(raw)
}
saved, logged := "", 0
for i, want := range g.Steps {
switch i {
case 1, 7, 8, 9, 12, 13:
put(shown())
case 2:
l := shown()
put(append(append([]map[string]any{}, l[1:]...), l[1], map[string]any{"priority": 5210, "src": "10.9.0.2", "iif": "dawn1", "dst": "10.1.0.0", "dstlen": 16, "table": "main"},
map[string]any{"priority": 5290, "src": "all", "iif": "dawn7", "iif_detached": nil, "table": "2077"},
map[string]any{"priority": 5290, "src": "all", "iif": "eth9", "table": "2077"}, map[string]any{"priority": 100, "src": "all", "iif": "dawn1", "table": "main"}))
case 3:
put(shown())
ftFail = true
case 5:
ftFail, nsmac = false, "5e:00:11:22:33:44"
case 6:
nsmac, saved = "", "192.168.77.200"
neigh = `[{"dst":"192.168.77.200","lladdr":"aa:bb:cc:00:00:01","state":["REACHABLE"]},{"dst":"192.168.77.254","lladdr":"aa:bb:cc:00:00:02","state":["FAILED"]},{"dst":"192.168.77.253","state":["STALE"]}]`
os.WriteFile(dir+"/leases", []byte("1700000000 aa:bb:cc:00:00:03 192.168.77.252 phone *\n"), 0o644)
d, _ := uci.Parse(g.DHCP)
d.Add("host", "nas")
d.Set("nas", "ip", "192.168.77.251")
d.Set("lan", "start", "240")
d.Set("lan", "limit", "11")
d.SetList("lan", "dhcp_option", []string{"3,192.168.77.1", "6,192.168.77.53,192.168.77.54"})
os.WriteFile(dir+"/dhcp", []byte(d.Format()), 0o644)
case 14:
put(nil)
}
switch i {
case 7:
saved = "192.168.77.201"
case 8:
tables["2077"] = "default via 10.0.0.1 dev eth5\n10.0.0.0/24 dev eth5\n"
tables["2078"] = "default via 169.254.77.2 dev dlx0\n"
case 9:
fail = "route replace default via 192.168.77.1"
case 11:
fail = ""
case 12:
c.Set("cabin", "lan_like", "0")
case 13:
c.Set("open", "lan_like", "0")
}
pings, said = nil, nil
res := r.LoopEnsure(model.Load(c, nil), saved, want.Force)
if res.Plan != nil {
last = res.Plan
}
fail := func(what string, got, exp any) {
a, _ := json.Marshal(got)
b, _ := json.Marshal(exp)
t.Errorf("step %d (%s): %s\n go: %s\n ucode: %s", i, want.What, what, a, b)
}
same := func(got, exp any) bool {
var a, b any
x, _ := json.Marshal(got)
y, _ := json.Marshal(exp)
json.Unmarshal(x, &a)
json.Unmarshal(y, &b)
return reflect.DeepEqual(a, b)
}
// where the files are kept here is not where the router keeps them
home := func(s string) string { return strings.ReplaceAll(s, etc, "/var/etc") }
var result any = res.Plan
switch {
case res.Off:
result = map[string]any{"off": true}
case res.Error != nil:
result = map[string]any{"error": map[string]any{"code": res.Error["code"], "detail": home(res.Error["detail"].(string))}}
}
if !same(result, want.Result) {
fail("what it came to", result, want.Result)
}
var ran, failed []string
for _, l := range said {
if s, is := strings.CutPrefix(l, "[info] [loop] $ "); is {
ran = append(ran, home(s))
}
if s, is := strings.CutPrefix(l, "[error] [loop] failed: "); is {
failed = append(failed, home(s))
}
}
if strings.Join(ran, "\n") != strings.Join(want.Ran, "\n") {
fail("the commands", ran, want.Ran)
}
if strings.Join(failed, "\n") != strings.Join(want.Failed, "\n") {
fail("what failed", failed, want.Failed)
}
if strings.Join(pings, "\n") != strings.Join(want.Pings, "\n") {
fail("who was asked whether they answer", pings, want.Pings)
}
var state any
if raw, err := os.ReadFile(dir + "/run/loop.json"); err == nil {
json.Unmarshal([]byte(home(string(raw))), &state)
if s, is := state.(map[string]any); is && s["applied"] != nil {
s["applied"] = float64(1)
}
}
if !same(state, want.State) {
fail("loop.json", state, want.State)
}
if got, _ := os.ReadFile(etc + "/dawnline-ns.nft"); string(got) != want.NSRules {
fail("the netns's rules", string(got), want.NSRules)
}
var log []map[string]any
lines, _ := os.ReadFile(dir + "/run/service.log")
all := strings.Split(strings.TrimRight(string(lines), "\n"), "\n")
if len(lines) == 0 {
all = nil
}
for _, l := range all[logged:] {
var e map[string]any
json.Unmarshal([]byte(home(l)), &e)
delete(e, "ts")
log = append(log, e)
}
logged = len(all)
if !same(log, want.Log) && !(len(log) == 0 && len(want.Log) == 0) {
fail("the service log", log, want.Log)
}
if there(sys+"/dlx0") != want.Sys.Dlx0 || there(sys+"/dll0") != want.Sys.Dll0 || there(dir+"/netns/dawnline") != want.Sys.Netns {
fail("what is left on the router", []bool{there(sys + "/dlx0"), there(sys + "/dll0"), there(dir + "/netns/dawnline")}, want.Sys)
}
}
}
+430
View File
@@ -0,0 +1,430 @@
package apply
import (
"crypto/rand"
"encoding/hex"
"encoding/json"
"fmt"
"os"
"path/filepath"
"strconv"
"strings"
"time"
"github.com/tickcount/luci-app-dawnline/backend/awg"
"github.com/tickcount/luci-app-dawnline/backend/disguise"
"github.com/tickcount/luci-app-dawnline/backend/files"
"github.com/tickcount/luci-app-dawnline/backend/model"
"github.com/tickcount/luci-app-dawnline/backend/servicelog"
"github.com/tickcount/luci-app-dawnline/backend/uci"
)
// netifd: one AmneziaWG interface a server, named after its ifname and marked `_dawnline` = the server's
// id (dawnline.netifd). Only interfaces Dawnline made are changed or removed: a name another interface has
// is left alone, and the server is kept down and said so (netifd-blocked.json: a code with its values).
// opt is one option of an interface: a string, a list, or nothing (the option goes).
type opt struct {
key string
val string
list []string
}
// put sets an option only when it differs (nothing deletes it); true when something changed.
func put(c *uci.Config, sec string, o opt) bool {
cur, has := c.Section(sec).Values[o.key]
if o.val == "" && len(o.list) == 0 {
if has {
c.Delete(sec, o.key)
return true
}
return false
}
if o.list != nil {
if has && cur.IsList && strings.Join(cur.List, "\n") == strings.Join(o.list, "\n") {
return false
}
c.SetList(sec, o.key, o.list)
return true
}
if has && !cur.IsList && cur.Str == o.val {
return false
}
c.Set(sec, o.key, o.val)
return true
}
// options is what is written into network.<ifname> apart from the markers: what netifd sets the tunnel up from.
func options(srv *model.Server) []opt {
prefix := ""
if i := strings.Index(srv.Subnet, "/"); i >= 0 {
prefix = srv.Subnet[i+1:]
}
o := []opt{{key: "proto", val: "amneziawg"}, {key: "private_key", val: srv.PrivateKey}, {key: "listen_port", val: strconv.Itoa(srv.Port)},
{key: "addresses", list: []string{model.ServerAddress(srv) + "/" + prefix}}, {key: "mtu", val: strconv.Itoa(model.TunnelMTU(srv))}}
for _, k := range model.ObfKeys {
v := srv.Obf[k]
// DisableCookies is the devices' alone: on the server it would turn off WireGuard's own defence
// against a flood of handshakes. Nothing takes it off an interface that had it.
if k == "disable_cookies" {
v = ""
}
o = append(o, opt{key: "awg_" + k, val: v})
}
off := opt{key: "disabled"}
auto := opt{key: "auto"}
if !srv.Enabled {
off.val, auto.val = "1", "0"
}
return append(o, off, auto)
}
// optsText is options as a log line's words (secrets masked, nothing as "-").
func optsText(list []opt) string {
var out []string
for _, o := range list {
s := "-"
if o.list != nil {
s = strings.Join(o.list, " ")
} else if o.val != "" {
s = o.val
}
if strings.Contains(o.key, "private_key") || strings.Contains(o.key, "preshared_key") || strings.Contains(o.key, "protection_key") ||
strings.Contains(o.key, "privatekey") || strings.Contains(o.key, "presharedkey") || strings.Contains(o.key, "protectionkey") {
s = "***"
}
out = append(out, o.key+"="+s)
}
return strings.Join(out, ", ")
}
// unsupported is why this AmneziaWG cannot run a server's disguise values, or nil when it can
// (dawnline.awg obf_unsupported).
func unsupported(o map[string]string, c awg.Caps) map[string]any {
has := func(keys ...string) bool {
for _, k := range keys {
if o[k] != "" {
return true
}
}
return false
}
installed := c.Kmod
if installed == nil {
installed = c.Tools
}
ranged := false
for _, k := range []string{"h1", "h2", "h3", "h4"} {
ranged = ranged || strings.Contains(o[k], "-")
}
switch {
case has("header_protection_key", "content_padding_addition", "rekey_after_time", "rekey_timeout", "reject_after_time", "keepalive_timeout",
"max_handshake_attempts", "random_trailers", "disable_cookies") && !c.V3:
return map[string]any{"code": "disguise", "need": "3.1", "installed": installed}
case (has("s3", "s4", "i1", "i2", "i3", "i4", "i5") || ranged) && !c.V2:
return map[string]any{"code": "disguise", "need": "2.0", "installed": installed}
}
return nil
}
// blockedNote is why a server is kept down, for the service log (dawnline.awg blocked_note).
func blockedNote(why map[string]any) string {
switch why["code"] {
case "ifname":
return fmt.Sprintf(`has an invalid interface name "%v"`, why["ifname"])
case "taken":
return fmt.Sprintf("can't use the network interface %v: it exists and isn't Dawnline's", why["ifname"])
case "disguise":
if in, _ := why["installed"].(string); in != "" {
return fmt.Sprintf("is kept down: its disguise needs AmneziaWG %v (installed: %s)", why["need"], in)
}
return fmt.Sprintf("is kept down: its disguise needs AmneziaWG %v (installed: none)", why["need"])
case "disguise_invalid":
return "is kept down: its disguise has values AmneziaWG cannot take"
}
return "is kept down"
}
func blockedFix(why map[string]any) string {
switch why["code"] {
case "disguise":
return "Install that AmneziaWG build in Settings → Updates, or switch the disguise in Settings → Disguise."
case "disguise_invalid":
return "Choose a disguise in Settings → Disguise: it replaces the values set by hand."
}
return "Choose another interface name in the server settings."
}
// intent notes why Dawnline itself is about to take a tunnel down, so the hotplug log can tell that from
// a tunnel that stopped on its own. reason: settings | off | removed. Kept for two minutes.
func (r *Router) intent(ifname, reason, name string) {
path := r.RunDir + "/iface-intent.json"
all := map[string]map[string]any{}
files.ReadJSON(path, &all)
now := time.Now().Unix()
for k, v := range all {
if ts, _ := v["ts"].(float64); float64(now)-ts >= 120 {
delete(all, k)
}
}
all[ifname] = map[string]any{"reason": reason, "name": name, "ts": now}
os.MkdirAll(r.RunDir, 0o755)
files.WriteJSON(path, all, 0o600)
}
// commit writes a configuration file in place whole, under a hidden name first.
func commit(path string, c *uci.Config) error {
var b [4]byte
rand.Read(b[:])
tmp := filepath.Join(filepath.Dir(path), "."+filepath.Base(path)+".dl-"+hex.EncodeToString(b[:]))
mode := os.FileMode(0o644)
if st, err := os.Stat(path); err == nil {
mode = st.Mode().Perm()
}
if err := os.WriteFile(tmp, []byte(c.Format()), mode); err != nil {
os.Remove(tmp)
return err
}
os.Chmod(tmp, mode)
if err := os.Rename(tmp, path); err != nil {
os.Remove(tmp)
return err
}
return nil
}
// ack records a configuration's new checksum after Dawnline committed and applied it itself, so a later
// `reload_config` does not treat it as changed and restart services that reload on any network change.
func (r *Router) ack(conf string) {
const md5f = "/var/run/config.md5"
if r.dry {
return
}
raw, err := os.ReadFile(md5f)
if err != nil {
return
}
sum, _ := r.Exec("sh", "-c", "uci show "+conf+" | md5sum | cut -d' ' -f1")
sum = strings.TrimSpace(sum)
if sum == "" {
return
}
path := "/var/run/config.check/" + conf
lines := strings.Split(strings.Trim(string(raw), " \t\r\n\v\f"), "\n")
found := false
for i, l := range lines {
if strings.HasSuffix(l, " "+path) {
lines[i], found = sum+" "+path, true
}
}
if !found {
lines = append(lines, sum+" "+path)
}
os.WriteFile(md5f, []byte(strings.Join(lines, "\n")+"\n"), 0o644)
}
// Netifd brings the router's network configuration in line with the servers; true when it changed. tools
// tells whether amneziawg-tools is there (without its protocol script, changing or bringing up an
// interface would only stop a tunnel that still runs); caps what this AmneziaWG can run. Each server that
// cannot have its interface is marked Blocked in m, as the rest of an apply works from the same model.
func (r *Router) Netifd(m *model.Model, tools bool, caps awg.Caps) bool {
text, _ := os.ReadFile(r.Network)
c, err := uci.Parse(string(text))
if err != nil {
r.say("error", "network", r.Network+" does not parse: nothing was changed · "+err.Error())
return false
}
changed := false
var touched []string
want := map[string]bool{}
was := map[string]any{}
files.ReadJSON(r.RunDir+"/netifd-blocked.json", &was)
blocked := map[string]any{}
block := func(srv *model.Server, why map[string]any, detail string) {
blocked[srv.ID] = why
srv.Blocked = why
a, _ := json.Marshal(was[srv.ID])
b, _ := json.Marshal(why)
if string(a) != string(b) && r.Log != nil {
r.Log.Write("dawnline", "error", blockedNote(why), detail, srv.Name, servicelog.Extra{})
}
}
flag := r.RunDir + "/netifd-no-awg"
_, flagged := os.Stat(flag)
keyed := false
for _, s := range m.Servers {
keyed = keyed || s.PrivateKey != ""
}
if tools && flagged == nil {
os.Remove(flag)
} else if !tools && keyed && flagged != nil {
if r.Log != nil {
r.Log.Write("dawnline", "error", "isn't installed: tunnels were left as they are", "Install it in Dawnline → Components.", "AmneziaWG", servicelog.Extra{})
}
os.MkdirAll(r.RunDir, 0o755)
os.WriteFile(flag, []byte(strconv.FormatInt(time.Now().Unix(), 10)), 0o644)
}
for _, id := range m.ServerIDs() {
srv := m.Servers[id]
if srv.PrivateKey == "" {
continue
}
ifn := srv.Ifname
if !model.ValidIfname(ifn) {
block(srv, map[string]any{"code": "ifname", "ifname": ifn}, "Interface name: 1-12 lowercase letters, digits or _.")
continue
}
// whose the section is: nobody's, this server's, or someone else's
if s := c.Section(ifn); s != nil {
if owner := s.Values["_dawnline"].Str; owner != id {
block(srv, map[string]any{"code": "taken", "ifname": ifn}, "Dawnline never changes interfaces it did not create. Choose another interface name for this server.")
continue
}
}
// disguise values AmneziaWG refuses or crashes on never reach the kernel, and a disguise this build
// cannot run would come up as a tunnel no device reaches: down, and said so
var why map[string]any
if tools {
if len(disguise.Unsafe(srv.Obf)) > 0 {
why = map[string]any{"code": "disguise_invalid"}
} else {
why = unsupported(srv.Obf, caps)
}
}
if why != nil {
block(srv, why, blockedFix(why))
continue
}
srv.Blocked = nil
want[ifn] = true
if !tools {
continue
}
created := false
if s := c.Section(ifn); s == nil || s.Type != "interface" {
c.DeleteSection(ifn)
c.Add("interface", ifn)
created = true
}
mine := created
var diff []opt
for _, o := range options(srv) {
if put(c, ifn, o) {
mine = true
diff = append(diff, o)
}
}
if mine {
how := "updated"
if created {
how = "created"
}
r.say("info", "network", fmt.Sprintf("interface %s (%s): %s · %s", ifn, srv.Name, how, optsText(diff)))
} else {
r.say("debug", "network", fmt.Sprintf("interface %s (%s): unchanged · %s", ifn, srv.Name, optsText(options(srv))))
}
// the markers are saved, but netifd does not read them: a renamed server keeps its tunnel and every session in it
if put(c, ifn, opt{key: "_dawnline", val: id}) {
changed = true
}
if put(c, ifn, opt{key: "_dawnline_name", val: srv.Name}) {
changed = true
}
if mine {
changed = true
touched = append(touched, ifn)
reason := "settings"
if !srv.Enabled {
reason = "off"
}
r.intent(ifn, reason, srv.Name)
}
}
a, _ := json.Marshal(blocked)
b, _ := json.Marshal(was)
if string(a) != string(b) {
os.MkdirAll(r.RunDir, 0o755)
files.WriteJSON(r.RunDir+"/netifd-blocked.json", blocked, 0o644)
}
// interfaces Dawnline made for servers that are no more
var stale []string
for _, s := range c.OfType("interface") {
if s.Values["_dawnline"].Str != "" && !want[s.Name] {
stale = append(stale, s.Name)
}
}
for _, ifn := range stale {
name := c.Section(ifn).Values["_dawnline_name"].Str
shown := name
if name == "" {
name, shown = ifn, "a removed server"
}
r.intent(ifn, "removed", name)
r.say("info", "network", fmt.Sprintf("interface %s (%s): removed, ifdown %s", ifn, shown, ifn))
r.Exec("ifdown", ifn)
c.DeleteSection(ifn)
changed = true
}
if changed {
if err := commit(r.Network, c); err != nil {
r.say("error", "network", r.Network+" could not be written · "+err.Error())
return false
}
r.ack("network")
}
// only the markers changed: nothing for netifd to read
if len(touched) > 0 || len(stale) > 0 {
r.say("info", "network", "ubus call network reload")
r.Exec("ubus", "call", "network", "reload")
for _, ifn := range touched {
if srv := m.Servers[c.Section(ifn).Values["_dawnline"].Str]; srv != nil && srv.Enabled {
r.say("info", "network", "ifup "+ifn)
r.Exec("ifup", ifn)
}
}
}
return changed
}
// NetifdOwner is whose an interface of the network configuration is: has false when there is none, id ""
// when it is not Dawnline's.
func (r *Router) NetifdOwner(ifname string) (id string, has bool) {
text, _ := os.ReadFile(r.Network)
c, err := uci.Parse(string(text))
if err != nil || c.Section(ifname) == nil {
return "", false
}
return c.Section(ifname).Values["_dawnline"].Str, true
}
// NetifdDrift is what of each running server's interface differs from what Netifd writes, by option name
// (a LuCI or uci edit of network.<ifname>, which would otherwise last until the next apply): an empty list
// when it is as Dawnline set it. Only enabled servers whose section exists and is theirs (a missing one is
// the tunnel probe's); the markers are not compared, netifd does not read them. Nothing is saved.
func (r *Router) NetifdDrift(m *model.Model) map[string][]string {
out := map[string][]string{}
text, _ := os.ReadFile(r.Network)
c, err := uci.Parse(string(text))
if err != nil {
return out
}
for _, id := range m.ServerIDs() {
srv := m.Servers[id]
s := c.Section(srv.Ifname)
if !srv.Enabled || !tunnelOK(srv) || s == nil || s.Values["_dawnline"].Str != id || s.Type != "interface" {
continue
}
diff := []string{}
for _, o := range options(srv) {
if put(c, srv.Ifname, o) {
diff = append(diff, o.key)
}
}
out[id] = diff
}
return out
}
// BlockedNote and BlockedFix word why a server is kept down, for the service log.
func BlockedNote(why map[string]any) string { return blockedNote(why) }
func BlockedFix(why map[string]any) string { return blockedFix(why) }
+154
View File
@@ -0,0 +1,154 @@
package apply
import (
"encoding/json"
"os"
"reflect"
"strings"
"testing"
"github.com/tickcount/luci-app-dawnline/backend/awg"
"github.com/tickcount/luci-app-dawnline/backend/model"
"github.com/tickcount/luci-app-dawnline/backend/uci"
)
// The router's network configuration through a row of changes to access's household: after each, the file
// ucode's netifd sync leaves, the servers it keeps down and why, and what it ran (testdata/netifd.uc).
func TestNetifdAsUcode(t *testing.T) {
raw, err := os.ReadFile("testdata/netifd.json")
if err != nil {
t.Fatal(err)
}
var trace struct {
Steps []struct {
What string `json:"what"`
Changed bool `json:"changed"`
Network string `json:"network"`
Blocked map[string]any `json:"blocked"`
ModelBlocked map[string]any `json:"model_blocked"`
Cmds []string `json:"cmds"`
Intents map[string]map[string]any `json:"intents"`
NoAWG bool `json:"no_awg"`
} `json:"steps"`
}
if err := json.Unmarshal(raw, &trace); err != nil {
t.Fatal(err)
}
if len(trace.Steps) != 9 {
t.Fatalf("%d steps", len(trace.Steps))
}
text, _ := os.ReadFile("../access/testdata/access.uci")
c, err := uci.Parse(string(text))
if err != nil {
t.Fatal(err)
}
dir := t.TempDir()
network, _ := os.ReadFile("testdata/network.uci")
os.WriteFile(dir+"/network", network, 0o644)
var cmds []string
r := &Router{RunDir: dir + "/run", Network: dir + "/network", Exec: func(name string, args ...string) (string, int) {
cmds = append(cmds, strings.Join(append([]string{name}, args...), " "))
return "", 0
}}
tools := true
caps := awg.Caps{V2: true, V3: true, Tools: "3.1"}
for i, want := range trace.Steps {
switch i {
case 2:
c.Set("home", "port", "4501")
c.Set("cabin", "enabled", "0")
case 3:
c.Set("home", "jmin", "90")
c.Set("home", "jmax", "50")
case 4:
c.Delete("home", "jmin")
c.Delete("home", "jmax")
c.Set("home", "name", "Anna's house")
case 5:
c.Set("home", "name", "House")
case 6:
c.DeleteSection("cabin")
c.Set("open", "ifname", "Not-A-Name")
case 7:
c.Set("home", "header_protection_key", "yAnz5TF+lXXJte14tji3zlMNq+hd2rYUIgJBgB3fBmk=")
for _, k := range []string{"s1", "s2", "s3", "s4"} {
c.Set("home", k, "12")
}
c.Set("home", "i1", "<b 0x01><r 2>")
c.Set("home", "disable_cookies", "on")
case 8:
tools = false
c.Set("home", "port", "4502")
}
cmds = nil
// as ucode's: each sync reads the settings anew, with who was kept down before
var before map[string]any
if raw, err := os.ReadFile(dir + "/run/netifd-blocked.json"); err == nil {
json.Unmarshal(raw, &before)
}
m := model.Load(c, before)
changed := r.Netifd(m, tools, caps)
fail := func(what string, got, exp any) {
t.Errorf("step %d (%s): %s\n go: %v\n ucode: %v", i, want.What, what, got, exp)
}
if changed != want.Changed {
fail("whether it changed", changed, want.Changed)
}
if got, _ := os.ReadFile(dir + "/network"); string(got) != want.Network {
g, w := strings.Split(string(got), "\n"), strings.Split(want.Network, "\n")
for n := 0; n < len(g) || n < len(w); n++ {
if n >= len(g) || n >= len(w) || g[n] != w[n] {
a, b := "(the end)", "(the end)"
if n < len(g) {
a = g[n]
}
if n < len(w) {
b = w[n]
}
fail("the network configuration, line "+string(rune('0'+(n+1)/10))+string(rune('0'+(n+1)%10)), a, b)
break
}
}
}
var blocked map[string]any
if raw, err := os.ReadFile(dir + "/run/netifd-blocked.json"); err == nil {
json.Unmarshal(raw, &blocked)
}
if !reflect.DeepEqual(blocked, want.Blocked) {
fail("who is kept down", blocked, want.Blocked)
}
kept := map[string]any{}
for id, srv := range m.Servers {
kept[id] = srv.Blocked
if why, is := srv.Blocked.(map[string]any); is {
kept[id] = why
}
}
if !reflect.DeepEqual(kept, want.ModelBlocked) {
fail("who the model holds as kept down", kept, want.ModelBlocked)
}
if strings.Join(cmds, "; ") != strings.Join(want.Cmds, "; ") {
fail("what was run", cmds, want.Cmds)
}
var all map[string]map[string]any
if raw, err := os.ReadFile(dir + "/run/iface-intent.json"); err == nil {
json.Unmarshal(raw, &all)
}
intents := map[string]map[string]any{}
for k, v := range all {
intents[k] = map[string]any{"reason": v["reason"], "name": v["name"]}
}
if !reflect.DeepEqual(intents, want.Intents) {
fail("why each tunnel goes down", intents, want.Intents)
}
if _, err := os.Stat(dir + "/run/netifd-no-awg"); (err == nil) != want.NoAWG {
fail("whether missing tools were told", err == nil, want.NoAWG)
}
}
left, _ := os.ReadDir(dir)
for _, e := range left {
if strings.HasPrefix(e.Name(), ".") {
t.Errorf("%s stays beside the configuration", e.Name())
}
}
}
+90
View File
@@ -0,0 +1,90 @@
package apply
import (
"fmt"
"os"
"regexp"
"strings"
"github.com/tickcount/luci-app-dawnline/backend/health"
"github.com/tickcount/luci-app-dawnline/backend/model"
)
// Our own answers leave by the main table: the portal's (TCP) and each tunnel's (UDP). Proxies on the
// router mark the router's own traffic in an output route chain, which diverts replies to outside clients
// into lo; a later output chain of our own (table inet dawnline_reply) clears exactly those marks on
// packets from our listening ports (dawnline.fw sync_reply_routes).
const replyTable = "dawnline_reply"
// Older versions kept answers out of proxies with `ip rule` at priority 90; it never matched.
var oldReplyRule = regexp.MustCompile(`(iif lo )?ipproto (tcp|udp) sport ([0-9]+) lookup main`)
// Diverts is the policy rules that send marked traffic into a table with `local default`, the way
// transparent proxies capture the router's own traffic.
func (r *Router) Diverts() []health.Divert {
return health.ProxyDiverts(func(fam string) string {
out, _ := r.Exec("ip", fam, "rule", "show")
return out
}, func(fam, name string) string {
out, _ := r.Exec("ip", fam, "route", "show", "table", name)
return out
})
}
func (r *Router) replyLoaded() bool {
_, code := r.Exec("nft", "list", "table", "inet", replyTable)
return code == 0
}
// ReplyOK tells whether answers from our ports are kept out of these diverts right now (the watchdog's question).
func (r *Router) ReplyOK(m *model.Model, diverts []health.Divert) bool {
s := health.ReplyScript(m, diverts)
if s == "" {
return true
}
was, _ := os.ReadFile(r.RunDir + "/reply.nft")
return s == string(was) && r.replyLoaded()
}
// ReplyRoutes keeps the reply table in step with our ports and the proxies' diverts (an apply, and every
// tick: a proxy may start after Dawnline). Cheap when nothing changed.
func (r *Router) ReplyRoutes(m *model.Model) {
sig := r.RunDir + "/reply.nft"
for _, fam := range []string{"-4", "-6"} {
out, _ := r.Exec("ip", fam, "rule", "show", "priority", "90")
for _, line := range strings.Split(out, "\n") {
if mm := oldReplyRule.FindStringSubmatch(line); mm != nil {
args := []string{fam, "rule", "del", "priority", "90"}
if mm[1] != "" {
args = append(args, "iif", "lo")
}
r.Exec("ip", append(args, "ipproto", mm[2], "sport", mm[3], "lookup", "main")...)
}
}
}
s := health.ReplyScript(m, r.Diverts())
if s == "" {
if r.replyLoaded() {
r.say("info", "nftables", "table inet "+replyTable+": removed (no proxy to keep Dawnline's answers out of)")
r.Exec("nft", "delete", "table", "inet", replyTable)
}
os.Remove(sig)
return
}
if was, _ := os.ReadFile(sig); s == string(was) && r.replyLoaded() {
r.say("debug", "nftables", "table inet "+replyTable+": unchanged")
return
}
if err := r.load("table inet " + replyTable + "\ndelete table inet " + replyTable + "\n" + s); err != "" {
os.Remove(sig)
r.say("error", "nftables", "table inet "+replyTable+": loading failed · "+err)
return
}
r.say("info", "nftables", fmt.Sprintf("table inet %s: loaded · %d lines (Dawnline's own answers kept out of proxies)", replyTable, strings.Count(s, "\n")+1))
for _, l := range strings.Split(strings.TrimRight(s, "\n"), "\n") {
r.say("debug", "nftables", "table inet "+replyTable+": "+l)
}
os.MkdirAll(r.RunDir, 0o755)
os.WriteFile(sig, []byte(s), 0o644)
}
+108
View File
@@ -0,0 +1,108 @@
package apply
import (
"os"
"strings"
"testing"
"github.com/tickcount/luci-app-dawnline/backend/model"
"github.com/tickcount/luci-app-dawnline/backend/uci"
)
// The reply table follows the proxies: loaded when one diverts the router's own traffic, left alone while
// nothing changed, taken away with the proxy; the rules older versions left are removed.
func TestReplyRoutes(t *testing.T) {
text, _ := os.ReadFile("../access/testdata/access.uci")
c, err := uci.Parse(string(text))
if err != nil {
t.Fatal(err)
}
m := model.Load(c, nil)
dir := t.TempDir()
proxy, loaded, refuse := true, false, false
var ran []string
var script string
r := &Router{RunDir: dir, Exec: func(name string, args ...string) (string, int) {
line := name + " " + strings.Join(args, " ")
switch {
case line == "ip -4 rule show priority 90":
return "90:\tfrom all iif lo ipproto udp sport 51820 lookup main\n", 0
case line == "ip -6 rule show priority 90":
return "90:\tfrom all ipproto tcp sport 8443 lookup main\n", 0
case line == "ip -4 rule show" && proxy:
return "0:\tfrom all lookup local\n1000:\tfrom all fwmark 0x1/0xff lookup 100\n32766:\tfrom all lookup main\n", 0
case line == "ip -4 route show table 100":
return "local default dev lo scope host\n", 0
case strings.HasPrefix(line, "ip ") && strings.Contains(line, " show"):
return "", 0
case line == "nft list table inet dawnline_reply":
if loaded {
return "", 0
}
return "", 1
case name == "nft" && args[0] == "-f":
raw, _ := os.ReadFile(args[1])
script = string(raw)
if refuse {
return args[1] + ":1:1-5: Error: a made-up failure", 1
}
loaded = true
return "", 0
case line == "nft delete table inet dawnline_reply":
loaded = false
}
ran = append(ran, line)
return "", 0
}}
sig := func() string { raw, _ := os.ReadFile(dir + "/reply.nft"); return string(raw) }
r.ReplyRoutes(m)
if want := "ip -4 rule del priority 90 iif lo ipproto udp sport 51820 lookup main; ip -6 rule del priority 90 ipproto tcp sport 8443 lookup main"; strings.Join(ran, "; ") != want {
t.Errorf("the old rules: %v", ran)
}
if !loaded || !strings.HasPrefix(script, "table inet dawnline_reply\ndelete table inet dawnline_reply\ntable inet dawnline_reply {\n") ||
!strings.Contains(script, "tcp sport { 4500, 4501 } meta mark & 0xff == 0x1 meta mark set meta mark & 0xffffff00\n") ||
!strings.Contains(script, "udp sport { 4500, 4600, 4700 } meta mark & 0xff == 0x1") {
t.Errorf("the table was not loaded as it should be:\n%s", script)
}
if sig() == "" || !strings.HasSuffix(script, sig()) || !r.ReplyOK(m, r.Diverts()) {
t.Error("what was loaded is not remembered")
}
script = ""
r.ReplyRoutes(m)
if script != "" {
t.Error("loaded again with nothing changed")
}
// the table went (fw4 restarted, say): loaded again
loaded = false
if r.ReplyOK(m, r.Diverts()) {
t.Error("fine without the table")
}
r.ReplyRoutes(m)
if !loaded {
t.Error("not loaded again")
}
// a load that fails forgets what was loaded, so the next tick tries again
c.Set("home", "port", "4555")
m = model.Load(c, nil)
refuse = true
r.ReplyRoutes(m)
if sig() != "" {
t.Error("a failed load is remembered")
}
refuse = false
r.ReplyRoutes(m)
if !strings.Contains(sig(), "4555") {
t.Error("not loaded after the failure")
}
// the proxy is gone: so is the table
proxy = false
r.ReplyRoutes(m)
if loaded || sig() != "" || !r.ReplyOK(m, r.Diverts()) {
t.Error("the table stays without a proxy")
}
left, _ := os.ReadDir(dir)
for _, e := range left {
t.Errorf("%s stays in the state directory", e.Name())
}
}
+198
View File
@@ -0,0 +1,198 @@
package apply
import (
"encoding/json"
"os"
"regexp"
"strconv"
"strings"
"github.com/tickcount/luci-app-dawnline/backend/model"
"github.com/tickcount/luci-app-dawnline/backend/uci"
)
// The plain resolver for people with Home-only access (dawnline.resolver): real addresses from the WAN's
// DNS, home names from the LAN's. Their internet does not use the tunnel, so fake-IP answers would break
// it. It runs inside the netns while that exists, otherwise on the tunnel interfaces; procd runs dnsmasq
// through /usr/libexec/dawnline/resolver, which reads where from the configuration's first line.
// ResolverPort is the port on the tunnel addresses while the resolver runs on the router itself.
const ResolverPort = 5354
var (
dotted = regexp.MustCompile(`^[0-9.]+$`)
digits = regexp.MustCompile(`^[0-9]+$`)
netifdOK = regexp.MustCompile(`^[A-Za-z0-9_.-]+$`)
)
// Target is where the resolver runs: "ns" (inside the netns, on Address) or "root" (on the tunnels).
type Target struct {
Mode string
Address string
Port int
}
func (r *Router) varEtc() string {
if r.VarEtc != "" {
return r.VarEtc
}
return "/var/etc"
}
func (r *Router) resolverPid() string {
if r.ResolverPid != "" {
return r.ResolverPid
}
return "/var/run/dawnline-dns.pid"
}
// ResolverTarget is where Home-only devices' DNS goes now: inside the netns while it is up, otherwise on
// the tunnel addresses (dawnline.loop resolver_target).
func (r *Router) ResolverTarget() Target {
if active, _, _, transit := r.likeHome(); active && transit != "" {
return Target{Mode: "ns", Address: transit, Port: 53}
}
return Target{Mode: "root", Port: ResolverPort}
}
// wanDNS is the DNS servers the WAN was given (IPv4), else two public ones.
func (r *Router) wanDNS() []string {
var out []string
snap := r.Snapshot()
wan := ""
if d := snap.Devices[snap.WAN]; d != nil {
wan = d.Logical
}
for _, name := range uniq([]string{wan, "wan", "wan6"}) {
if name == "" || !netifdOK.MatchString(name) {
continue
}
said, _ := r.Exec("ubus", "call", "network.interface."+name, "status")
var st struct {
DNS []string `json:"dns-server"`
}
if json.Unmarshal([]byte(said), &st) != nil {
continue
}
for _, a := range st.DNS {
if dotted.MatchString(a) {
out = append(out, a)
}
}
}
if len(out) == 0 {
return []string{"1.1.1.1", "8.8.8.8"}
}
return uniq(out)
}
// lanDomains is the local domain of the LAN's DNS (dnsmasq `domain`) and Dawnline's own for device names.
func (r *Router) lanDomains(m *model.Model) []string {
var out []string
if raw, err := os.ReadFile(r.DHCP); err == nil {
if c, err := uci.Parse(string(raw)); err == nil {
for _, s := range c.OfType("dnsmasq") {
if d, _ := s.Get("domain"); d != "" {
out = append(out, d)
break
}
}
}
}
if m.Settings.Domain != "" {
out = append(out, m.Settings.Domain)
}
return uniq(out)
}
// ResolverRunning tells whether the resolver's process is alive.
func (r *Router) ResolverRunning() bool {
raw, _ := os.ReadFile(r.resolverPid())
pid := strings.Trim(string(raw), " \t\r\n\v\f")
if !digits.MatchString(pid) {
return false
}
_, err := os.Stat("/proc/" + pid)
return err == nil
}
// Resolver writes the resolver's configuration for target, with home names from lan (the LAN's DNS, "":
// none); true when it changed (the running one is killed, and procd starts it again from the new file).
func (r *Router) Resolver(m *model.Model, target Target, lan string) bool {
etc := r.varEtc()
os.MkdirAll(etc, 0o755)
conf, resolv := etc+"/dawnline-dns.conf", etc+"/dawnline-dns.resolv"
// servers that are on: with none, the resolver idles on loopback
var ifs []string
for _, id := range m.ServerIDs() {
if s := m.Servers[id]; s.Enabled && tunnelOK(s) {
ifs = append(ifs, s.Ifname)
}
}
// the paths dnsmasq is told are the router's own, wherever a test keeps the files
lines := []string{"# mode=" + target.Mode, "# Generated by Dawnline: plain DNS for Home-only tunnel clients.", "port=" + strconv.Itoa(target.Port),
"no-hosts", "bogus-priv", "cache-size=1000", "pid-file=/var/run/dawnline-dns.pid", "user=dnsmasq", "group=dnsmasq"}
upstream := r.wanDNS()
if target.Mode == "ns" {
lines = append(lines, "listen-address="+target.Address, "bind-interfaces", "no-resolv")
// upstream from the transit address: forwarded through the router to the WAN
for _, a := range upstream {
lines = append(lines, "server="+a+"@"+target.Address)
}
} else {
// no tunnel on: loopback only (without any interface= line dnsmasq would answer everywhere)
lines = append(lines, "bind-dynamic")
if len(ifs) == 0 {
lines = append(lines, "listen-address=127.0.0.1")
}
for _, i := range ifs {
lines = append(lines, "interface="+i)
}
lines = append(lines, "resolv-file=/var/etc/dawnline-dns.resolv")
body := ""
for _, a := range upstream {
body += "nameserver " + a + "\n"
}
if was, _ := os.ReadFile(resolv); string(was) != body {
os.WriteFile(resolv, []byte(body), 0o644)
os.Chmod(resolv, 0o644)
}
}
if lan != "" {
for _, d := range r.lanDomains(m) {
lines = append(lines, "server=/"+d+"/"+lan)
}
}
text := strings.Join(lines, "\n") + "\n"
where := "loopback only (no tunnel on)"
if target.Mode == "ns" {
where = target.Address + ":" + strconv.Itoa(target.Port) + " in the netns"
} else if len(ifs) > 0 {
where = "port " + strconv.Itoa(target.Port) + " on " + strings.Join(ifs, ", ")
}
if was, _ := os.ReadFile(conf); string(was) == text {
r.say("debug", "dns", "resolver for Home-only devices: unchanged · "+where)
return false
}
os.WriteFile(conf, []byte(text), 0o644)
os.Chmod(conf, 0o644)
home := ""
if lan != "" {
home = " · home names via " + lan
}
r.say("info", "dns", "resolver for Home-only devices: "+conf+" written · "+where+" · upstream "+strings.Join(upstream, " ")+home+"; restarting it")
for _, l := range lines {
r.say("debug", "dns", "dnsmasq: "+l)
}
raw, _ := os.ReadFile(r.resolverPid())
if pid := strings.Trim(string(raw), " \t\r\n\v\f"); digits.MatchString(pid) {
r.Exec("kill", pid)
}
return true
}
// SyncResolver writes the resolver's configuration where it should run now; true when it changed.
func (r *Router) SyncResolver(m *model.Model) bool {
_, _, known, _ := r.likeHome()
return r.Resolver(m, r.ResolverTarget(), r.lanDNS(r.Snapshot(), known))
}
+94
View File
@@ -0,0 +1,94 @@
package apply
import (
"encoding/json"
"os"
"strings"
"testing"
"github.com/tickcount/luci-app-dawnline/backend/model"
"github.com/tickcount/luci-app-dawnline/backend/netview"
"github.com/tickcount/luci-app-dawnline/backend/uci"
)
// The Home-only resolver's configuration in each place it may run: the files ucode's own sync writes, and
// whether it changed (testdata/resolver.uc).
func TestResolverAsUcode(t *testing.T) {
raw, err := os.ReadFile("testdata/resolver.json")
if err != nil {
t.Fatal(err)
}
var trace struct {
DHCP string `json:"dhcp"`
Steps []struct {
What string `json:"what"`
Target struct {
Mode string `json:"mode"`
Address string `json:"address"`
Port int `json:"port"`
} `json:"target"`
Lan string `json:"lan"`
Changed bool `json:"changed"`
Conf string `json:"conf"`
Resolv string `json:"resolv"`
} `json:"steps"`
}
if err := json.Unmarshal(raw, &trace); err != nil {
t.Fatal(err)
}
if len(trace.Steps) != 6 {
t.Fatalf("%d steps", len(trace.Steps))
}
dir := t.TempDir()
os.WriteFile(dir+"/dhcp", []byte(trace.DHCP), 0o644)
wanDNS := true
var killed []string
r := &Router{RunDir: dir + "/run", VarEtc: dir + "/etc", ResolverPid: dir + "/pid", DHCP: dir + "/dhcp",
Snapshot: func() *netview.Snapshot { return &netview.Snapshot{Devices: map[string]*netview.Device{}} },
Exec: func(name string, args ...string) (string, int) {
line := name + " " + strings.Join(args, " ")
switch {
case name == "kill":
killed = append(killed, args...)
case !wanDNS:
case line == "ubus call network.interface.wan status":
return `{ "dns-server": [ "9.9.9.9", "2001:db8::1", "149.112.112.112" ] }`, 0
case line == "ubus call network.interface.wan6 status":
return `{ "dns-server": [ "9.9.9.9" ] }`, 0
}
return "", 0
}}
text, _ := os.ReadFile("../access/testdata/access.uci")
c, err := uci.Parse(string(text))
if err != nil {
t.Fatal(err)
}
for i, want := range trace.Steps {
switch i {
case 3:
c.Set("cabin", "enabled", "0")
os.WriteFile(dir+"/pid", []byte("4242\n"), 0o644)
case 4:
c.Set("home", "enabled", "0")
c.Set("open", "enabled", "0")
os.Remove(dir + "/pid")
case 5:
wanDNS = false
}
killed = nil
changed := r.Resolver(model.Load(c, nil), Target{Mode: want.Target.Mode, Address: want.Target.Address, Port: want.Target.Port}, want.Lan)
if changed != want.Changed {
t.Errorf("step %d (%s): changed %v, ucode %v", i, want.What, changed, want.Changed)
}
if got, _ := os.ReadFile(dir + "/etc/dawnline-dns.conf"); string(got) != want.Conf {
t.Errorf("step %d (%s): the configuration\n%s--- ucode:\n%s", i, want.What, got, want.Conf)
}
if got, _ := os.ReadFile(dir + "/etc/dawnline-dns.resolv"); string(got) != want.Resolv {
t.Errorf("step %d (%s): the upstream file\n%s--- ucode:\n%s", i, want.What, got, want.Resolv)
}
// the one that ran is stopped, so procd starts it from the new file
if stop := i == 3; stop != (strings.Join(killed, " ") == "4242") || (!stop && killed != nil) {
t.Errorf("step %d (%s): stopped %v", i, want.What, killed)
}
}
}
+127
View File
@@ -0,0 +1,127 @@
package apply
import (
"encoding/json"
"os"
"sort"
"github.com/tickcount/luci-app-dawnline/backend/health"
"github.com/tickcount/luci-app-dawnline/backend/model"
"github.com/tickcount/luci-app-dawnline/backend/servicelog"
)
// The networks behind people's routers, as the router's own routes: a packet for one leaves through the
// tunnel of the router it stands behind (the tunnel then picks the device by the peers' AllowedIPs).
//
// Reconciled, not patched: every route of ours carries one routing protocol number, so what the main table
// holds of them is read back and brought to what the settings and people's states want. Netifd takes a
// tunnel's routes away with its interface; the sync that follows the interface coming up puts them back.
// routeProto marks the routes Dawnline keeps (/etc/iproute2/rt_protos has no name for it).
const routeProto = "205"
// RoutesWanted is the networks that get a route, by the tunnel's interface, sorted: those behind the
// devices a tunnel was given (peers: each server's "ok"), so a route never leads into a tunnel that would
// drop the packet.
func RoutesWanted(m *model.Model, states, peers map[string]string, behind map[string][]string) map[string][]string {
want := map[string][]string{}
for _, id := range m.ServerIDs() {
srv := m.Servers[id]
if !srv.Enabled || !tunnelOK(srv) || peers[id] != "ok" {
continue
}
for _, d := range health.TunnelDevices(m, id, states) {
want[srv.Ifname] = append(want[srv.Ifname], behind[d.ID]...)
}
sort.Strings(want[srv.Ifname])
if len(want[srv.Ifname]) == 0 {
delete(want, srv.Ifname)
}
}
return want
}
// IPRoute is a route as `ip -j -4 route show` prints it.
type IPRoute struct {
Dst string `json:"dst"`
Dev string `json:"dev"`
}
// RouteCmds is the `ip` arguments that turn the routes of ours there are into the wanted ones: the missing
// ones first, then the ones nobody has any more. None when they are as wanted.
func RouteCmds(want map[string][]string, have []IPRoute) [][]string {
there, wanted := map[string]bool{}, map[string]bool{}
for _, x := range have {
there[x.Dev+" "+x.Dst] = true
}
var cmds [][]string
ifnames := make([]string, 0, len(want))
for ifname := range want {
ifnames = append(ifnames, ifname)
}
sort.Strings(ifnames)
for _, ifname := range ifnames {
for _, n := range want[ifname] {
if k := ifname + " " + n; !there[k] && !wanted[k] {
cmds = append(cmds, []string{"-4", "route", "replace", n, "dev", ifname, "proto", routeProto, "scope", "link"})
}
wanted[ifname+" "+n] = true
}
}
for _, x := range have {
if !wanted[x.Dev+" "+x.Dst] {
cmds = append(cmds, []string{"-4", "route", "del", x.Dst, "dev", x.Dev, "proto", routeProto})
}
}
return cmds
}
// routes keeps the routes to the networks behind routers as RoutesWanted says: "" when they are, else what
// `ip` said of the first that failed. states is whose devices were loaded, peers what each tunnel answered.
func (r *Router) routes(m *model.Model, states, peers map[string]string, behind map[string][]string) string {
out, code := r.Exec("ip", "-j", "-4", "route", "show", "proto", routeProto)
var have []IPRoute
if code == 0 {
json.Unmarshal([]byte(trimmed(out)), &have)
}
failed := ""
var added, removed []string
for _, args := range RouteCmds(RoutesWanted(m, states, peers, behind), have) {
said, code := r.Exec("ip", args...)
what := args[3] + " dev " + args[5]
switch {
case code != 0 && args[2] == "replace":
if failed == "" {
failed = what + ": " + trimmed(said)
}
case args[2] == "replace":
added = append(added, what)
case code == 0:
removed = append(removed, what)
}
}
if len(added) > 0 || len(removed) > 0 {
line := "networks behind routers:"
if len(added) > 0 {
line += " added " + someOf(added)
}
if len(removed) > 0 {
line += " removed " + someOf(removed)
}
r.say("info", "routes", line)
}
// once per distinct failure, as the access table's
path := r.RunDir + "/routes.err"
was, werr := os.ReadFile(path)
switch {
case failed == "" && werr == nil:
os.Remove(path)
case failed != "" && (werr != nil || string(was) != failed):
if r.Log != nil {
r.Log.Write("dawnline", "error", "couldn't set a route to a network behind a router", failed, "Routes", servicelog.Extra{})
}
os.MkdirAll(r.RunDir, 0o755)
os.WriteFile(path, []byte(failed), 0o644)
}
return failed
}
+191
View File
@@ -0,0 +1,191 @@
package apply
import (
"encoding/json"
"os"
"reflect"
"sort"
"strings"
"testing"
"github.com/tickcount/luci-app-dawnline/backend/i18n"
"github.com/tickcount/luci-app-dawnline/backend/model"
"github.com/tickcount/luci-app-dawnline/backend/netview"
"github.com/tickcount/luci-app-dawnline/backend/uci"
"github.com/tickcount/luci-app-dawnline/backend/usage"
)
// routed is a router that keeps the routes it is given, besides what stand keeps.
type routed struct {
stand
routes map[string]bool
fail string
ran []string
}
func (s *routed) exec(name string, args ...string) (string, int) {
if name != "ip" {
return s.stand.exec(name, args...)
}
line := strings.Join(args, " ")
switch {
case line == "-j -4 route show proto "+routeProto:
var list []IPRoute
for k := range s.routes {
f := strings.Fields(k)
list = append(list, IPRoute{Dev: f[0], Dst: f[1]})
}
sort.Slice(list, func(i, j int) bool { return list[i].Dev+list[i].Dst < list[j].Dev+list[j].Dst })
raw, _ := json.Marshal(list)
return string(raw), 0
case strings.HasPrefix(line, "-4 route replace ") && strings.HasSuffix(line, " proto "+routeProto+" scope link"):
s.ran = append(s.ran, line)
if s.fail != "" && strings.Contains(line, s.fail) {
return "RTNETLINK answers: a made-up failure\n", 2
}
s.routes[args[5]+" "+args[3]] = true
case strings.HasPrefix(line, "-4 route del ") && strings.HasSuffix(line, " proto "+routeProto):
s.ran = append(s.ran, line)
delete(s.routes, args[5]+" "+args[3])
default:
return "unknown: ip " + line, 1
}
return "", 0
}
// Access's household on the golden's router, with two routers that have networks behind them and one
// whose network the router has itself.
func sites(t *testing.T) (*uci.Config, *netview.Snapshot) {
t.Helper()
text, err := os.ReadFile("../access/testdata/access.uci")
if err != nil {
t.Fatal(err)
}
c, err := uci.Parse(string(text))
if err != nil {
t.Fatal(err)
}
c.Set("bphone", "kind", "router")
c.SetList("bphone", "behind_net", []string{"192.168.2.0/24", "172.20.0.0/16"})
c.Set("kphone", "kind", "router")
c.SetList("kphone", "behind_net", []string{"192.168.3.0/24"})
c.Set("hphone", "kind", "router")
c.SetList("hphone", "behind_net", []string{"192.168.50.0/24"})
raw, err := os.ReadFile("../netview/testdata/trace.json")
if err != nil {
t.Fatal(err)
}
var router struct {
Routes json.RawMessage `json:"routes"`
Addrs json.RawMessage `json:"addrs"`
Links map[string]netview.Link `json:"links"`
}
if err := json.Unmarshal(raw, &router); err != nil {
t.Fatal(err)
}
return c, netview.Take(netview.Sources{Routes: func() []byte { return router.Routes }, Addrs: func() []byte { return router.Addrs },
Links: func() map[string]netview.Link { return router.Links }})
}
func TestRoutesFollowTheTunnels(t *testing.T) {
c, snap := sites(t)
dir := t.TempDir()
s := &routed{stand: stand{dir: dir, refuse: map[string]bool{}, down: map[string]bool{}, confs: map[string]string{}}, routes: map[string]bool{}}
r := &Router{RunDir: dir, HostsFile: dir + "/hosts/dawnline", DHCP: dir + "/no-dhcp", Exec: s.exec, Snapshot: func() *netview.Snapshot { return snap }}
words := i18n.Use("", "")
have := func() []string {
out := []string{}
for k := range s.routes {
out = append(out, k)
}
sort.Strings(out)
return out
}
sync := func() Result {
s.ran = nil
return r.Sync(model.Load(c, nil), &usage.Usage{}, 1700000000, false, words)
}
// each router's networks leave through its own tunnel; what the router has itself gets no route
res := sync()
all := []string{"dawn0 172.20.0.0/16", "dawn0 192.168.2.0/24", "dawn2 192.168.3.0/24"}
if !reflect.DeepEqual(have(), all) || res.Routes != "" || res.Warning != "" {
t.Fatalf("routes %v, %q, %q", have(), res.Routes, res.Warning)
}
// the tunnel is told whose they are, and nobody else gets more than an address
if conf := s.confs["dawn0"]; !strings.Contains(conf, "AllowedIPs = 10.77.0.5/32, 192.168.2.0/24, 172.20.0.0/16\n") ||
strings.Count(conf, "/32\n") != strings.Count(conf, "AllowedIPs = ")-1 {
t.Errorf("dawn0's devices:\n%s", conf)
}
if conf := s.confs["dawn1"]; strings.Contains(conf, "192.168.50.0/24") {
t.Errorf("dawn1 was given a network the router has itself:\n%s", conf)
}
// nothing moved: nothing is run
if sync(); len(s.ran) != 0 {
t.Errorf("ran %v with nothing to do", s.ran)
}
// its owner paused: the route goes with the device
c.Set("boris", "paused", "1")
if sync(); !reflect.DeepEqual(have(), []string{"dawn2 192.168.3.0/24"}) {
t.Errorf("with Boris paused: %v", have())
}
c.Delete("boris", "paused")
// a tunnel that refuses its devices, and one that is down: no route leads into either
s.refuse["dawn0"], s.down["dawn2"] = true, true
if sync(); len(have()) != 0 {
t.Errorf("into tunnels that hold nobody: %v", have())
}
s.refuse["dawn0"], s.down["dawn2"] = false, false
// a route that will not go in is told, once in the log's file, and the others still go in
s.fail = "192.168.2.0/24"
res = sync()
if !reflect.DeepEqual(have(), []string{"dawn0 172.20.0.0/16", "dawn2 192.168.3.0/24"}) || !strings.Contains(res.Routes, "192.168.2.0/24 dev dawn0: RTNETLINK answers: a made-up failure") ||
!strings.Contains(res.Warning, "192.168.2.0/24 dev dawn0") {
t.Errorf("a route refused: %v, %q, %q", have(), res.Routes, res.Warning)
}
if kept, _ := os.ReadFile(dir + "/routes.err"); string(kept) != res.Routes {
t.Errorf("kept %q", kept)
}
s.fail = ""
if res = sync(); !reflect.DeepEqual(have(), all) || res.Routes != "" {
t.Errorf("after the failure: %v, %q", have(), res.Routes)
}
if _, err := os.Stat(dir + "/routes.err"); err == nil {
t.Error("the failure is still kept")
}
// a network taken off, a router that is one no more, and a route of ours nobody wants
c.SetList("bphone", "behind_net", []string{"172.20.0.0/16"})
c.Set("kphone", "kind", "phone")
s.routes["dawn9 192.168.99.0/24"] = true
if sync(); !reflect.DeepEqual(have(), []string{"dawn0 172.20.0.0/16"}) {
t.Errorf("after the changes: %v", have())
}
// a router that waits for the admin's answer: no device of the tunnel, no route to what it asks for
c.Set("kphone", "kind", "router")
c.Set("kphone", "waiting", "1")
if sync(); !reflect.DeepEqual(have(), []string{"dawn0 172.20.0.0/16"}) || strings.Contains(s.confs["dawn2"], "10.79.0.2/32") || !strings.Contains(s.confs["dawn2"], "10.79.0.3/32") {
t.Errorf("with Kira's router waiting: %v\n%s", have(), s.confs["dawn2"])
}
// the plan of a sync names them too
p := r.Plan(model.Load(c, nil), &usage.Usage{}, 1700000000)
if !reflect.DeepEqual(p.Routes, map[string][]string{"dawn0": {"172.20.0.0/16"}}) {
t.Errorf("the plan's routes: %v", p.Routes)
}
}
func TestRouteCommands(t *testing.T) {
want := map[string][]string{"dawn1": {"192.168.3.0/24"}, "dawn0": {"172.20.0.0/16", "192.168.2.0/24"}}
have := []IPRoute{{Dst: "192.168.2.0/24", Dev: "dawn0"}, {Dst: "192.168.2.0/24", Dev: "dawn1"}, {Dst: "10.9.0.0/24", Dev: "dawn7"}}
got := RouteCmds(want, have)
exp := [][]string{
{"-4", "route", "replace", "172.20.0.0/16", "dev", "dawn0", "proto", routeProto, "scope", "link"},
{"-4", "route", "replace", "192.168.3.0/24", "dev", "dawn1", "proto", routeProto, "scope", "link"},
{"-4", "route", "del", "192.168.2.0/24", "dev", "dawn1", "proto", routeProto},
{"-4", "route", "del", "10.9.0.0/24", "dev", "dawn7", "proto", routeProto},
}
if !reflect.DeepEqual(got, exp) {
t.Errorf("commands:\n%v\nwant\n%v", got, exp)
}
if got := RouteCmds(want, []IPRoute{{Dst: "172.20.0.0/16", Dev: "dawn0"}, {Dst: "192.168.2.0/24", Dev: "dawn0"}, {Dst: "192.168.3.0/24", Dev: "dawn1"}}); len(got) != 0 {
t.Errorf("as wanted, yet %v", got)
}
}
+545
View File
@@ -0,0 +1,545 @@
// Package apply puts the settings into effect on the router, as dawnline.apply does. This file is the
// runtime sync: the access table's sets, the devices into the tunnels (AmneziaWG peers) and the hostnames.
// Cheap, and safe to call often.
//
// Fail closed: without the table the firewall would let every loaded device reach everything, so while it
// is missing no device is loaded at all. An older table that survived a failed rebuild keeps limiting them
// with the sets it has, and the devices still follow people's states (a revoked one leaves).
//
// Held to ucode on a router whose `nft` and `awg` are stand-ins that keep what they are given
// (testdata/trace.uc, scripts/ucode-golden.sh): the scripts loaded, the peers of each tunnel, the
// hostnames and what is answered, through a table that is not there yet, one that will not load and a
// tunnel that refuses its devices.
package apply
import (
"crypto/rand"
"encoding/hex"
"encoding/json"
"fmt"
"os"
"regexp"
"strconv"
"strings"
"github.com/tickcount/luci-app-dawnline/backend/files"
"github.com/tickcount/luci-app-dawnline/backend/health"
"github.com/tickcount/luci-app-dawnline/backend/i18n"
"github.com/tickcount/luci-app-dawnline/backend/ipnet"
"github.com/tickcount/luci-app-dawnline/backend/model"
"github.com/tickcount/luci-app-dawnline/backend/netview"
"github.com/tickcount/luci-app-dawnline/backend/nft"
"github.com/tickcount/luci-app-dawnline/backend/servicelog"
"github.com/tickcount/luci-app-dawnline/backend/state"
"github.com/tickcount/luci-app-dawnline/backend/uci"
"github.com/tickcount/luci-app-dawnline/backend/usage"
"github.com/tickcount/luci-app-dawnline/backend/view"
)
// Router is the router a sync works on.
type Router struct {
// RunDir is the state directory (locks, what was last loaded); HostsFile where dnsmasq reads extra names;
// Network the router's network configuration, Firewall its firewall's.
RunDir, HostsFile, Network, Firewall string
// VarEtc is where generated configurations go ("": /var/etc); ResolverPid the Home-only resolver's pid file.
VarEtc, ResolverPid string
// Remember keeps the LAN address the home-like path chose (settings.lan_address), so it is the same after a restart.
Remember func(address string)
// dry: nothing outside the files this router is given is written (ApplyPlan).
dry bool
// SysNet is where the kernel shows interfaces ("": /sys/class/net), NetnsDir where named network
// namespaces are ("": /var/run/netns), Leases dnsmasq's leases ("": /tmp/dhcp.leases).
SysNet, NetnsDir, Leases string
// Exec runs a command: what it said (both streams) and its exit code.
Exec func(name string, args ...string) (out string, code int)
// Snapshot is the router's interfaces; DHCP the path of its DHCP settings.
Snapshot func() *netview.Snapshot
DHCP string
Log *servicelog.Log
}
// Result is what a sync came to: each server's devices ("ok", "down", or what awg said), people's states,
// the table's error ("" when it loaded), the routes' ("" when they are as wanted) and a sentence for the
// admin when it did not fully take.
type Result struct {
Peers map[string]string
States map[string]string
Table string
Routes string
Warning string
}
func (r *Router) say(level, src, line string) {
if r.Log != nil {
r.Log.Say(level, src, line)
}
}
// someOf names up to ten of a list, and how many more there are.
func someOf(list []string) string {
if len(list) <= 10 {
return strings.Join(list, ", ")
}
return strings.Join(list[:10], ", ") + " and " + strconv.Itoa(len(list)-10) + " more"
}
func minus(a, b []string) []string {
in := map[string]bool{}
for _, x := range b {
in[x] = true
}
var out []string
for _, x := range a {
if !in[x] {
out = append(out, x)
}
}
return out
}
func uniq(list []string) []string {
out := []string{}
seen := map[string]bool{}
for _, x := range list {
if !seen[x] {
seen[x] = true
out = append(out, x)
}
}
return out
}
// tunnelOK tells a server that runs one of Dawnline's own tunnels.
func tunnelOK(srv *model.Server) bool {
_, ok := ipnet.Subnet(srv.Subnet)
return ok && srv.PrivateKey != "" && srv.Blocked == nil && model.ValidIfname(srv.Ifname)
}
// likeHome is the home-like path as it stands (dawnline.loop status): whether it is up, its address on the
// LAN, the LAN's DNS it found and its address on the inner link.
func (r *Router) likeHome() (active bool, address, dns, transit string) {
var s struct {
Plan *struct {
Address string `json:"address"`
DNS string `json:"dns"`
TxNS string `json:"tx_ns"`
} `json:"plan"`
}
files.ReadJSON(r.RunDir+"/loop.json", &s)
if s.Plan == nil {
return false, "", "", ""
}
_, e1 := os.Stat("/sys/class/net/dlx0")
_, e2 := os.Stat("/sys/class/net/dll0")
return e1 == nil && e2 == nil, s.Plan.Address, s.Plan.DNS, s.Plan.TxNS
}
var dnsOption = regexp.MustCompile(`^(option:dns-server|6),([0-9.]+)`)
// lanDNS is the DNS the LAN gets from DHCP (option 6), else the router on the LAN (dawnline.loop lan_dns);
// known is what the home-like path found already.
func (r *Router) lanDNS(snap *netview.Snapshot, known string) string {
out := known
if lan := snap.Devices[snap.LAN]; out == "" && lan != nil && len(lan.Addrs) > 0 {
out = strings.SplitN(lan.Addrs[0], "/", 2)[0]
if _, ok := ipnet.Subnet(lan.Addrs[0]); ok {
if raw, err := os.ReadFile(r.DHCP); err == nil {
if c, err := uci.Parse(string(raw)); err == nil {
found := ""
for _, s := range c.OfType("dhcp") {
iface, _ := s.Get("interface")
if ignore, _ := s.Get("ignore"); iface != lan.Logical || ignore == "1" {
continue
}
v := s.Values["dhcp_option"]
opts := v.List
if !v.IsList && v.Str != "" {
opts = []string{v.Str}
}
for _, o := range opts {
if m := dnsOption.FindStringSubmatch(o); m != nil && found == "" {
found = m[2]
}
}
}
if found != "" {
out = found
}
}
}
}
}
return out
}
// Ctx is what the table is made from besides the settings, read from the router (dawnline.nft router_ctx).
func (r *Router) Ctx(snap *netview.Snapshot) nft.Ctx {
active, address, dns, transit := r.likeHome()
ctx := nft.Ctx{Snap: snap, ResolverPort: 5354}
if active {
ctx.DNSAddr = address
if transit != "" {
ctx.ResolverNS, ctx.ResolverPort = transit, 53
}
}
ctx.LanDNS = r.lanDNS(snap, dns)
return ctx
}
// load runs an nft script (one transaction): "" when it loaded, else what nft said.
func (r *Router) load(script string) string {
os.MkdirAll(r.RunDir, 0o755)
// a file of its own: two writers must never load each other's script
var b [4]byte
rand.Read(b[:])
f := r.RunDir + "/nft." + hex.EncodeToString(b[:]) + ".rules"
if os.WriteFile(f, []byte(script), 0o600) != nil {
return "couldn't write " + f
}
out, code := r.Exec("nft", "-f", f)
os.Remove(f)
if code == 0 {
return ""
}
// without the random file name, so the same failure reads the same every time
if said := strings.ReplaceAll(strings.Trim(out, " \t\r\n\v\f"), f, "rules"); said != "" {
return said
}
return fmt.Sprintf("nft exited with %d", code)
}
// Present tells whether the table is loaded.
func (r *Router) Present() bool {
_, code := r.Exec("nft", "list", "table", "inet", "dawnline")
return code == 0
}
// logSets tells the sets in syslog: each that changed, or that none did; remembered for the next time.
func (r *Router) logSets(sets nft.Sets, how string) {
path := r.RunDir + "/nft-sets.json"
var was map[string][]string
first := !files.ReadJSON(path, &was) || was == nil
now := map[string][]string{}
var diff, counts []string
for _, name := range nft.Names {
a, b := uniq(was[name]), uniq(sets[name])
now[name] = b
counts = append(counts, name+" "+strconv.Itoa(len(b)))
add, del := minus(b, a), minus(a, b)
if len(add) > 0 || len(del) > 0 {
line := fmt.Sprintf("%s %d → %d", name, len(a), len(b))
if len(add) > 0 {
line += ": +" + someOf(add)
}
if len(del) > 0 {
if len(add) > 0 {
line += " -" + someOf(del)
} else {
line += ": -" + someOf(del)
}
}
diff = append(diff, line)
}
}
files.WriteJSON(path, now, 0o600)
switch {
// the first load since the router started: how many in each set (the members at debug)
case first:
r.say("info", "nftables", "table inet dawnline: "+how+" · "+strings.Join(counts, ", "))
for _, n := range nft.Names {
if len(now[n]) > 0 {
r.say("debug", "nftables", "set "+n+": "+strings.Join(now[n], " "))
}
}
case len(diff) > 0:
r.say("info", "nftables", "table inet dawnline: "+how+" · "+strings.Join(diff, "; "))
default:
r.say("debug", "nftables", "table inet dawnline: "+how+" · sets unchanged ("+strings.Join(counts, ", ")+")")
}
}
// rebuild replaces the whole table: "" or the error.
//
// members: a runtime sync, where only who is in the sets may have moved. The table is replaced whole all
// the same: to add an element to a set that exists, nft first reads the router's whole ruleset, every
// other program's sets with it (0.9 s on an MT7981 beside a proxy's lists), where replacing our own table
// reads nothing (0.06 s). The line in the log is then the sets', and the rebuild's own is for a debug log.
func (r *Router) rebuild(m *model.Model, sets nft.Sets, snap *netview.Snapshot, members bool) string {
table := nft.Render(m, sets, r.Ctx(snap))
if err := r.load(nft.Rebuild(table)); err != "" {
r.say("error", "nftables", "table inet dawnline: rebuild failed · "+err)
return err
}
chains, nsets, rules := nft.Shape(table)
level, how := "info", "sets loaded with the table"
if members {
level, how = "debug", "sets updated"
}
r.say(level, "nftables", fmt.Sprintf("table inet dawnline: rebuilt · %d chains, %d sets, %d rules", chains, nsets, rules))
r.logSets(sets, how)
return ""
}
// table has the table in place, replaced whole every time: with `full` after a change of its shape,
// otherwise for who is in its sets. A failure is told in the service log once per distinct error.
func (r *Router) table(m *model.Model, sets nft.Sets, snap *netview.Snapshot, full bool) string {
err := r.rebuild(m, sets, snap, !full)
path := r.RunDir + "/nft.err"
was, werr := os.ReadFile(path)
if err == "" {
if werr == nil {
os.Remove(path)
}
return ""
}
if werr != nil || string(was) != err {
msg := "couldn't load - no device is loaded into the tunnels until they do"
if r.Present() {
msg = "couldn't be updated - the previous rules stay, and changes to access wait until they load"
}
if r.Log != nil {
r.Log.Write("dawnline", "error", msg, err, "Access rules", servicelog.Extra{})
}
os.MkdirAll(r.RunDir, 0o755)
os.WriteFile(path, []byte(err), 0o644)
}
return err
}
// PeersConf is what a tunnel is given to hold: its own key and port, then each device that belongs there
// with the networks behind it (behind: by the device's id), and who they are for a log line
// ("Person · Device (address)").
func PeersConf(m *model.Model, srv *model.Server, states map[string]string, behind map[string][]string) (conf string, who []string) {
lines := []string{"[Interface]", "PrivateKey = " + srv.PrivateKey, "ListenPort = " + strconv.Itoa(srv.Port), ""}
who = []string{}
for _, d := range health.TunnelDevices(m, srv.ID, states) {
lines = append(lines, "[Peer]", "PublicKey = "+d.PublicKey)
if d.PresharedKey != "" {
lines = append(lines, "PresharedKey = "+d.PresharedKey)
}
// a router brings the networks behind it: the tunnel takes their packets from it and sends theirs to it
lines = append(lines, "AllowedIPs = "+strings.Join(append([]string{d.Address + "/32"}, behind[d.ID]...), ", "), "")
name := d.Person
if p := m.People[d.Person]; p != nil {
name = p.Name
}
who = append(who, name+" · "+d.Name+" ("+strings.Join(append([]string{d.Address}, behind[d.ID]...), ", ")+")")
}
return strings.Join(lines, "\n"), who
}
// peers pushes every server's devices to the kernel without restarting its tunnel.
func (r *Router) peers(m *model.Model, states map[string]string, behind map[string][]string) map[string]string {
os.MkdirAll(r.RunDir, 0o755)
res := map[string]string{}
path := r.RunDir + "/peers-seen.json"
seen := map[string][]string{}
files.ReadJSON(path, &seen)
now := map[string][]string{}
for _, id := range m.ServerIDs() {
srv := m.Servers[id]
// only Dawnline's own interfaces: never another tunnel of the same name
if !srv.Enabled || !tunnelOK(srv) {
continue
}
if _, code := r.Exec("awg", "show", srv.Ifname, "public-key"); code != 0 {
res[id] = "down"
r.say("debug", "awg", "interface "+srv.Ifname+" ("+srv.Name+"): down, no devices to load")
continue
}
conf, who := PeersConf(m, srv, states, behind)
f := r.RunDir + "/" + srv.Ifname + ".conf"
os.WriteFile(f, []byte(conf), 0o600)
out, code := r.Exec("awg", "syncconf", srv.Ifname, f)
os.Remove(f)
if code != 0 {
res[id] = strings.Trim(out, " \t\r\n\v\f")
if r.Log != nil {
r.Log.Write("awg", "error", "couldn't load devices into the tunnel", res[id], srv.Name, servicelog.Extra{})
}
continue
}
res[id] = "ok"
// who came in and who left since the last load: info; the same peers: debug
now[srv.Ifname] = who
plural := "peers"
if len(who) == 1 {
plural = "peer"
}
head := fmt.Sprintf("interface %s (%s): awg syncconf · listen port %d · %d %s", srv.Ifname, srv.Name, srv.Port, len(who), plural)
was, had := seen[srv.Ifname]
if !had {
r.say("info", "awg", head+" loaded")
r.say("debug", "awg", "interface "+srv.Ifname+": "+strings.Join(who, ", "))
continue
}
add, del := minus(who, was), minus(was, who)
switch {
case len(add) > 0 || len(del) > 0:
line := head
if len(add) > 0 {
line += " · added " + someOf(add)
}
if len(del) > 0 {
line += " · removed " + someOf(del)
}
r.say("info", "awg", line)
default:
r.say("debug", "awg", head+", unchanged")
}
}
a, _ := json.Marshal(now)
b, _ := json.Marshal(seen)
if string(a) != string(b) {
files.WriteJSON(path, now, 0o600)
}
return res
}
// Hosts is the names dnsmasq is given for people's devices: one label a device, unique within the person
// (the pages show the same), and the router's own on the LAN while the home-like path is up.
func Hosts(m *model.Model, lanAddress string) (body string, names int) {
var lines []string
if m.Settings.Hostnames {
for _, pid := range m.PersonIDs() {
p := m.People[pid]
labels := view.Labels(m, p)
for _, id := range p.Devices {
if d := m.Devices[id]; d != nil {
if _, ok := ipnet.IP(d.Address); ok {
lines = append(lines, d.Address+" "+labels[id]+"."+p.ID+"."+m.Settings.Domain)
}
}
}
}
}
if lanAddress != "" {
lines = append(lines, lanAddress+" dawnline."+m.Settings.Domain)
}
if len(lines) == 0 {
return "", 0
}
return strings.Join(lines, "\n") + "\n", len(lines)
}
// hosts keeps the names file as Hosts says and has dnsmasq read it again when it changed.
func (r *Router) hosts(m *model.Model) bool {
active, address, _, _ := r.likeHome()
if !active {
address = ""
}
body, n := Hosts(m, address)
was, _ := os.ReadFile(r.HostsFile)
// dnsmasq runs as its own user: a file only root reads is no use to it
readable := false
if st, err := os.Stat(r.HostsFile); err == nil {
readable = st.Mode().Perm()&0o004 != 0
}
if string(was) == body && (body == "" || readable) {
r.say("debug", "dns", fmt.Sprintf("%s: unchanged · %d names", r.HostsFile, n))
return false
}
if i := strings.LastIndex(r.HostsFile, "/"); i > 0 {
os.MkdirAll(r.HostsFile[:i], 0o755)
}
if body == "" {
os.Remove(r.HostsFile)
r.say("info", "dns", r.HostsFile+": removed (no device names)")
} else {
os.WriteFile(r.HostsFile, []byte(body), 0o644)
os.Chmod(r.HostsFile, 0o644)
r.say("info", "dns", fmt.Sprintf("%s: %d names written (*.%s) · killall -HUP dnsmasq", r.HostsFile, n, m.Settings.Domain))
}
r.Exec("killall", "-HUP", "dnsmasq")
return true
}
// Sync is the runtime sync: with the apply lock held, the access sets first, then the devices into the
// tunnels, then the hostnames. `full` rebuilds the whole table (its shape changed).
func (r *Router) Sync(m *model.Model, u *usage.Usage, now int64, full bool, t *i18n.Catalog) Result {
defer files.Lock(r.RunDir, "apply")()
return r.sync(m, u, now, full, t)
}
// sync is Sync with the apply lock held already.
func (r *Router) sync(m *model.Model, u *usage.Usage, now int64, full bool, t *i18n.Catalog) Result {
states := map[string]string{}
for _, id := range m.PersonIDs() {
states[id] = state.Of(m, m.People[id], u, now)
}
snap := r.Snapshot()
sets := nft.AccessSets(m, states, snap)
table := r.table(m, sets, snap, full)
// fail closed: with no table at all, nobody is loaded
loaded := states
if table != "" && !r.Present() {
loaded = map[string]string{}
}
behind := snap.Behind(m)
peers := r.peers(m, loaded, behind)
routes := r.routes(m, loaded, peers, behind)
r.hosts(m)
os.MkdirAll(r.RunDir, 0o755)
files.WriteJSON(r.RunDir+"/states.json", states, 0o644)
// what an admin should hear when it did not fully take, with what nft or awg said
var out []string
if table != "" {
if r.Present() {
out = append(out, fmt.Sprintf(t.T("Access rules couldn't be updated (%s): the previous rules stay, so this change isn't in effect yet."), table))
} else {
out = append(out, fmt.Sprintf(t.T("Access rules couldn't load (%s): no device is loaded into the tunnels until they do."), table))
}
}
for _, id := range m.ServerIDs() {
if res, has := peers[id]; has && res != "ok" && res != "down" {
out = append(out, fmt.Sprintf(t.T("Couldn't load devices into %s: %s."), m.Servers[id].Name, res))
}
}
if routes != "" {
out = append(out, fmt.Sprintf(t.T("Couldn't set the routes to the networks behind routers (%s): they aren't reachable yet."), routes))
}
warning := ""
if len(out) > 0 {
warning = strings.Join(append(out, t.T("Open Overview → Health.")), " ")
}
return Result{Peers: peers, States: states, Table: table, Routes: routes, Warning: warning}
}
// Plan is what a sync would load, with nothing loaded: the table's text, the script for its sets, each
// tunnel's peers by interface, the routes to the networks behind routers by interface (as if every tunnel
// took its devices) and the hostnames. For holding the Go sync to what a router runs now.
type Plan struct {
Table string `json:"table"`
Update string `json:"update"`
Peers map[string]string `json:"peers"`
Routes map[string][]string `json:"routes,omitempty"`
Hosts string `json:"hosts"`
}
// Plan works a sync out and loads nothing.
func (r *Router) Plan(m *model.Model, u *usage.Usage, now int64) Plan {
states := map[string]string{}
for _, id := range m.PersonIDs() {
states[id] = state.Of(m, m.People[id], u, now)
}
snap := r.Snapshot()
sets := nft.AccessSets(m, states, snap)
p := Plan{Table: nft.Render(m, sets, r.Ctx(snap)), Update: nft.Update(sets), Peers: map[string]string{}}
behind := snap.Behind(m)
took := map[string]string{}
for _, id := range m.ServerIDs() {
if srv := m.Servers[id]; srv.Enabled && tunnelOK(srv) {
p.Peers[srv.Ifname], _ = PeersConf(m, srv, states, behind)
took[id] = "ok"
}
}
if want := RoutesWanted(m, states, took, behind); len(want) > 0 {
p.Routes = want
}
active, address, _, _ := r.likeHome()
if !active {
address = ""
}
p.Hosts, _ = Hosts(m, address)
return p
}
+190
View File
@@ -0,0 +1,190 @@
package apply
import (
"encoding/json"
"os"
"reflect"
"strings"
"testing"
"github.com/tickcount/luci-app-dawnline/backend/model"
"github.com/tickcount/luci-app-dawnline/backend/netview"
"github.com/tickcount/luci-app-dawnline/backend/uci"
"github.com/tickcount/luci-app-dawnline/backend/usage"
)
// stand is a router whose nft and awg keep what they are given, as the golden's stand-ins do.
type stand struct {
dir string
present, nftFail bool
refuse, down map[string]bool
scripts []string
confs map[string]string
}
func (s *stand) exec(name string, args ...string) (string, int) {
switch {
case name == "nft" && args[0] == "-f":
raw, _ := os.ReadFile(args[1])
s.scripts = append(s.scripts, string(raw))
if s.nftFail {
return args[1] + ":1:1-5: Error: a made-up failure\n", 1
}
if strings.HasPrefix(string(raw), "flush set") {
if !s.present {
return args[1] + ":1:1-9: Error: No such file or directory\n", 1
}
} else {
s.present = true
}
return "", 0
case name == "nft" && args[0] == "list":
if s.present {
return "", 0
}
return "", 1
case name == "awg" && args[0] == "show":
if s.down[args[1]] {
return "", 1
}
return "", 0
case name == "awg" && args[0] == "syncconf":
raw, _ := os.ReadFile(args[2])
s.confs[args[1]] = string(raw)
if s.refuse[args[1]] {
return "Line unrecognized: a made-up refusal\n", 1
}
return "", 0
}
return "", 0
}
// A row of syncs of access's household, each as ucode's sync does it on the golden's router: the scripts
// loaded, each tunnel's peers, the hostnames, the states and what is answered (testdata/trace.uc).
func TestSyncAsUcode(t *testing.T) {
raw, err := os.ReadFile("testdata/trace.json")
if err != nil {
t.Fatal(err)
}
var trace struct {
Steps []struct {
What string `json:"what"`
Peers map[string]string `json:"peers"`
Table *string `json:"table"`
Warning *string `json:"warning"`
States map[string]string `json:"states"`
Scripts []string `json:"scripts"`
Confs map[string]string `json:"confs"`
Hosts *string `json:"hosts"`
HostsMode *bool `json:"hosts_mode"`
NftErr *string `json:"nft_err"`
Present bool `json:"present"`
} `json:"steps"`
}
if err := json.Unmarshal(raw, &trace); err != nil {
t.Fatal(err)
}
if len(trace.Steps) != 9 {
t.Fatalf("%d steps", len(trace.Steps))
}
text, _ := os.ReadFile("../access/testdata/access.uci")
c, err := uci.Parse(string(text))
if err != nil {
t.Fatal(err)
}
raw, _ = os.ReadFile("../netview/testdata/trace.json")
var router struct {
Routes json.RawMessage `json:"routes"`
Addrs json.RawMessage `json:"addrs"`
Firewall string `json:"firewall"`
Links map[string]netview.Link `json:"links"`
}
json.Unmarshal(raw, &router)
fw, _ := uci.Parse(router.Firewall)
snap := netview.Take(netview.Sources{Routes: func() []byte { return router.Routes }, Addrs: func() []byte { return router.Addrs },
Links: func() map[string]netview.Link { return router.Links }, Zones: func() netview.Zones { return netview.ZonesOf(fw) }})
dir := t.TempDir()
s := &stand{dir: dir, refuse: map[string]bool{}, down: map[string]bool{}}
r := &Router{RunDir: dir, HostsFile: dir + "/hosts/dawnline", DHCP: dir + "/no-dhcp", Exec: s.exec, Snapshot: func() *netview.Snapshot { return snap }}
str := func(p *string) string {
if p == nil {
return ""
}
return *p
}
for i, want := range trace.Steps {
// what the golden does before each step
switch i {
case 2:
c.Set("anna", "paused", "1")
case 3:
c.Delete("anna", "paused")
s.nftFail = true
case 4:
s.present = false
case 6:
s.nftFail = false
s.refuse["dawn0"] = true
case 7:
s.refuse["dawn0"] = false
s.down["dawn1"] = true
case 8:
s.down["dawn1"] = false
}
s.scripts, s.confs = nil, map[string]string{}
res := r.Sync(model.Load(c, nil), usage.Empty(), 1_800_000_000, false, nil)
fail := func(what string, got, exp any) {
t.Errorf("step %d (%s): %s\n go: %v\n ucode: %v", i, want.What, what, got, exp)
}
if !reflect.DeepEqual(res.Peers, want.Peers) {
fail("each server's devices", res.Peers, want.Peers)
}
if res.Table != str(want.Table) || res.Warning != str(want.Warning) {
fail("the table and the warning", res.Table+" | "+res.Warning, str(want.Table)+" | "+str(want.Warning))
}
if !reflect.DeepEqual(res.States, want.States) {
fail("the states", res.States, want.States)
}
if !reflect.DeepEqual(s.scripts, want.Scripts) {
for n := range want.Scripts {
if n >= len(s.scripts) || s.scripts[n] != want.Scripts[n] {
fail("script "+string(rune('1'+n))+" of "+string(rune('0'+len(want.Scripts))), len(s.scripts), "differs")
break
}
}
if len(s.scripts) != len(want.Scripts) {
fail("how many scripts were loaded", len(s.scripts), len(want.Scripts))
}
}
if !reflect.DeepEqual(s.confs, want.Confs) {
fail("the tunnels' peers", s.confs, want.Confs)
}
hosts, herr := os.ReadFile(r.HostsFile)
if string(hosts) != str(want.Hosts) || (herr == nil) != (want.Hosts != nil) {
fail("the hostnames", string(hosts), str(want.Hosts))
}
if st, err := os.Stat(r.HostsFile); err == nil && want.HostsMode != nil && (st.Mode().Perm()&0o004 != 0) != *want.HostsMode {
fail("who may read the hostnames", st.Mode().Perm(), *want.HostsMode)
}
nftErr, eerr := os.ReadFile(dir + "/nft.err")
if string(nftErr) != str(want.NftErr) || (eerr == nil) != (want.NftErr != nil) {
fail("the table's error kept", string(nftErr), str(want.NftErr))
}
if s.present != want.Present {
fail("whether a table is there", s.present, want.Present)
}
var kept map[string]string
raw, _ := os.ReadFile(dir + "/states.json")
json.Unmarshal(raw, &kept)
if !reflect.DeepEqual(kept, want.States) {
fail("the states kept", kept, want.States)
}
}
// nobody's key stays on disk between syncs, nor a script
left, _ := os.ReadDir(dir)
for _, e := range left {
if strings.HasSuffix(e.Name(), ".conf") || strings.HasSuffix(e.Name(), ".rules") {
t.Errorf("%s stays in the state directory", e.Name())
}
}
}
+122
View File
@@ -0,0 +1,122 @@
{
"steps": [
{
"what": "the first time: a zone a tunnel, the way home and out, the ports",
"dry": false,
"changed": true,
"before": "config defaults\n\toption syn_flood\t1\n\toption input\t\tREJECT\n\toption output\t\tACCEPT\n\toption forward\t\tREJECT\n# Uncomment this line to disable ipv6 rules\n#\toption disable_ipv6\t1\n\nconfig zone\n\toption name\t\tlan\n\tlist network\t\t'lan'\n\toption input\t\tACCEPT\n\toption output\t\tACCEPT\n\toption forward\t\tACCEPT\n\nconfig zone\n\toption name\t\twan\n\tlist network\t\t'wan'\n\tlist network\t\t'wan6'\n\toption input\t\tREJECT\n\toption output\t\tACCEPT\n\toption forward\t\tDROP\n\toption masq\t\t1\n\toption mtu_fix\t\t1\n\nconfig forwarding\n\toption src\t\tlan\n\toption dest\t\twan\n\n# We need to accept udp packets on port 68,\n# see https://dev.openwrt.org/ticket/4108\nconfig rule\n\toption name\t\tAllow-DHCP-Renew\n\toption src\t\twan\n\toption proto\t\tudp\n\toption dest_port\t68\n\toption target\t\tACCEPT\n\toption family\t\tipv4\n\n# Allow IPv4 ping\nconfig rule\n\toption name\t\tAllow-Ping\n\toption src\t\twan\n\toption proto\t\ticmp\n\toption icmp_type\techo-request\n\toption family\t\tipv4\n\toption target\t\tACCEPT\n\nconfig rule\n\toption name\t\tAllow-IGMP\n\toption src\t\twan\n\toption proto\t\tigmp\n\toption family\t\tipv4\n\toption target\t\tACCEPT\n\n# Allow DHCPv6 replies\n# see https://github.com/openwrt/openwrt/issues/5066\nconfig rule\n\toption name\t\tAllow-DHCPv6\n\toption src\t\twan\n\toption proto\t\tudp\n\toption dest_port\t546\n\toption family\t\tipv6\n\toption target\t\tACCEPT\n\nconfig rule\n\toption name\t\tAllow-MLD\n\toption src\t\twan\n\toption proto\t\ticmp\n\toption src_ip\t\tfe80::/10\n\tlist icmp_type\t\t'130/0'\n\tlist icmp_type\t\t'131/0'\n\tlist icmp_type\t\t'132/0'\n\tlist icmp_type\t\t'143/0'\n\toption family\t\tipv6\n\toption target\t\tACCEPT\n\n# Allow essential incoming IPv6 ICMP traffic\nconfig rule\n\toption name\t\tAllow-ICMPv6-Input\n\toption src\t\twan\n\toption proto\ticmp\n\tlist icmp_type\t\techo-request\n\tlist icmp_type\t\techo-reply\n\tlist icmp_type\t\tdestination-unreachable\n\tlist icmp_type\t\tpacket-too-big\n\tlist icmp_type\t\ttime-exceeded\n\tlist icmp_type\t\tbad-header\n\tlist icmp_type\t\tunknown-header-type\n\tlist icmp_type\t\trouter-solicitation\n\tlist icmp_type\t\tneighbour-solicitation\n\tlist icmp_type\t\trouter-advertisement\n\tlist icmp_type\t\tneighbour-advertisement\n\toption limit\t\t1000/sec\n\toption family\t\tipv6\n\toption target\t\tACCEPT\n\n# Allow essential forwarded IPv6 ICMP traffic\nconfig rule\n\toption name\t\tAllow-ICMPv6-Forward\n\toption src\t\twan\n\toption dest\t\t*\n\toption proto\t\ticmp\n\tlist icmp_type\t\techo-request\n\tlist icmp_type\t\techo-reply\n\tlist icmp_type\t\tdestination-unreachable\n\tlist icmp_type\t\tpacket-too-big\n\tlist icmp_type\t\ttime-exceeded\n\tlist icmp_type\t\tbad-header\n\tlist icmp_type\t\tunknown-header-type\n\toption limit\t\t1000/sec\n\toption family\t\tipv6\n\toption target\t\tACCEPT\n\nconfig rule\n\toption name\t\tAllow-IPSec-ESP\n\toption src\t\twan\n\toption dest\t\tlan\n\toption proto\t\tesp\n\toption target\t\tACCEPT\n\nconfig rule\n\toption name\t\tAllow-ISAKMP\n\toption src\t\twan\n\toption dest\t\tlan\n\toption dest_port\t500\n\toption proto\t\tudp\n\toption target\t\tACCEPT\n\n\n### EXAMPLE CONFIG SECTIONS\n# do not allow a specific ip to access wan\n#config rule\n#\toption src\t\tlan\n#\toption src_ip\t192.168.45.2\n#\toption dest\t\twan\n#\toption proto\ttcp\n#\toption target\tREJECT\n\n# block a specific mac on wan\n#config rule\n#\toption dest\t\twan\n#\toption src_mac\t00:11:22:33:44:66\n#\toption target\tREJECT\n\n# block incoming ICMP traffic on a zone\n#config rule\n#\toption src\t\tlan\n#\toption proto\tICMP\n#\toption target\tDROP\n\n# port redirect port coming in on wan to lan\n#config redirect\n#\toption src\t\t\twan\n#\toption src_dport\t80\n#\toption dest\t\t\tlan\n#\toption dest_ip\t\t192.168.16.235\n#\toption dest_port\t80\n#\toption proto\t\ttcp\n\n# port redirect of remapped ssh port (22001) on wan\n#config redirect\n#\toption src\t\twan\n#\toption src_dport\t22001\n#\toption dest\t\tlan\n#\toption dest_port\t22\n#\toption proto\t\ttcp\n\n### FULL CONFIG SECTIONS\n#config rule\n#\toption src\t\tlan\n#\toption src_ip\t192.168.45.2\n#\toption src_mac\t00:11:22:33:44:55\n#\toption src_port\t80\n#\toption dest\t\twan\n#\toption dest_ip\t194.25.2.129\n#\toption dest_port\t120\n#\toption proto\ttcp\n#\toption target\tREJECT\n\n#config redirect\n#\toption src\t\tlan\n#\toption src_ip\t192.168.45.2\n#\toption src_mac\t00:11:22:33:44:55\n#\toption src_port\t\t1024\n#\toption src_dport\t80\n#\toption dest_ip\t194.25.2.129\n#\toption dest_port\t120\n#\toption proto\ttcp\n\nconfig zone\n\toption name 'guest'\n\tlist device 'dlguest'\n\nconfig zone\n\toption name 'home'\n\toption device 'br-lan dlhome'\n",
"firewall": "\nconfig defaults\n\toption syn_flood '1'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'REJECT'\n\nconfig zone\n\toption name 'lan'\n\tlist network 'lan'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig zone\n\toption name 'wan'\n\tlist network 'wan'\n\tlist network 'wan6'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'DROP'\n\toption masq '1'\n\toption mtu_fix '1'\n\nconfig forwarding\n\toption src 'lan'\n\toption dest 'wan'\n\nconfig rule\n\toption name 'Allow-DHCP-Renew'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '68'\n\toption target 'ACCEPT'\n\toption family 'ipv4'\n\nconfig rule\n\toption name 'Allow-Ping'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption icmp_type 'echo-request'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IGMP'\n\toption src 'wan'\n\toption proto 'igmp'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-DHCPv6'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '546'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-MLD'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption src_ip 'fe80::/10'\n\tlist icmp_type '130/0'\n\tlist icmp_type '131/0'\n\tlist icmp_type '132/0'\n\tlist icmp_type '143/0'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Input'\n\toption src 'wan'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\tlist icmp_type 'router-solicitation'\n\tlist icmp_type 'neighbour-solicitation'\n\tlist icmp_type 'router-advertisement'\n\tlist icmp_type 'neighbour-advertisement'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Forward'\n\toption src 'wan'\n\toption dest '*'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IPSec-ESP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption proto 'esp'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ISAKMP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption dest_port '500'\n\toption proto 'udp'\n\toption target 'ACCEPT'\n\nconfig zone\n\toption name 'guest'\n\tlist device 'dlguest'\n\nconfig zone\n\toption name 'home'\n\toption device 'br-lan dlhome'\n\nconfig rule 'dawnline_home_loopdns'\n\toption name 'Dawnline-dawn0-names'\n\toption src 'dawn0'\n\toption dest 'dl_loop'\n\toption proto 'tcp udp'\n\toption dest_port '53'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_home_zone'\n\toption name 'dawn0'\n\tlist network 'dawn0'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_home_lan'\n\toption src 'dawn0'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_home_from_lan'\n\toption src 'home'\n\toption dest 'dawn0'\n\nconfig forwarding 'dawnline_home_wan'\n\toption src 'dawn0'\n\toption dest 'wan'\n\nconfig rule 'dawnline_home_port'\n\toption name 'Dawnline-dawn0'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4500'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_cabin_zone'\n\toption name 'dawn1'\n\tlist network 'dawn1'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_cabin_lan'\n\toption src 'dawn1'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_cabin_from_lan'\n\toption src 'home'\n\toption dest 'dawn1'\n\nconfig forwarding 'dawnline_cabin_wan'\n\toption src 'dawn1'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_cabin_loop'\n\toption src 'dawn1'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_cabin_port'\n\toption name 'Dawnline-dawn1'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4600'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_open_zone'\n\toption name 'dawn2'\n\tlist network 'dawn2'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_open_lan'\n\toption src 'dawn2'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_open_from_lan'\n\toption src 'home'\n\toption dest 'dawn2'\n\nconfig forwarding 'dawnline_open_wan'\n\toption src 'dawn2'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_open_loop'\n\toption src 'dawn2'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_open_port'\n\toption name 'Dawnline-dawn2'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4700Line truncated
"cmds": [
"ubus call network.interface dump",
"fw4 -q reload"
]
},
{
"what": "again: nothing to do",
"dry": false,
"changed": false,
"before": "\nconfig defaults\n\toption syn_flood '1'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'REJECT'\n\nconfig zone\n\toption name 'lan'\n\tlist network 'lan'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig zone\n\toption name 'wan'\n\tlist network 'wan'\n\tlist network 'wan6'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'DROP'\n\toption masq '1'\n\toption mtu_fix '1'\n\nconfig forwarding\n\toption src 'lan'\n\toption dest 'wan'\n\nconfig rule\n\toption name 'Allow-DHCP-Renew'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '68'\n\toption target 'ACCEPT'\n\toption family 'ipv4'\n\nconfig rule\n\toption name 'Allow-Ping'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption icmp_type 'echo-request'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IGMP'\n\toption src 'wan'\n\toption proto 'igmp'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-DHCPv6'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '546'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-MLD'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption src_ip 'fe80::/10'\n\tlist icmp_type '130/0'\n\tlist icmp_type '131/0'\n\tlist icmp_type '132/0'\n\tlist icmp_type '143/0'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Input'\n\toption src 'wan'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\tlist icmp_type 'router-solicitation'\n\tlist icmp_type 'neighbour-solicitation'\n\tlist icmp_type 'router-advertisement'\n\tlist icmp_type 'neighbour-advertisement'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Forward'\n\toption src 'wan'\n\toption dest '*'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IPSec-ESP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption proto 'esp'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ISAKMP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption dest_port '500'\n\toption proto 'udp'\n\toption target 'ACCEPT'\n\nconfig zone\n\toption name 'guest'\n\tlist device 'dlguest'\n\nconfig zone\n\toption name 'home'\n\toption device 'br-lan dlhome'\n\nconfig rule 'dawnline_home_loopdns'\n\toption name 'Dawnline-dawn0-names'\n\toption src 'dawn0'\n\toption dest 'dl_loop'\n\toption proto 'tcp udp'\n\toption dest_port '53'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_home_zone'\n\toption name 'dawn0'\n\tlist network 'dawn0'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_home_lan'\n\toption src 'dawn0'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_home_from_lan'\n\toption src 'home'\n\toption dest 'dawn0'\n\nconfig forwarding 'dawnline_home_wan'\n\toption src 'dawn0'\n\toption dest 'wan'\n\nconfig rule 'dawnline_home_port'\n\toption name 'Dawnline-dawn0'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4500'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_cabin_zone'\n\toption name 'dawn1'\n\tlist network 'dawn1'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_cabin_lan'\n\toption src 'dawn1'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_cabin_from_lan'\n\toption src 'home'\n\toption dest 'dawn1'\n\nconfig forwarding 'dawnline_cabin_wan'\n\toption src 'dawn1'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_cabin_loop'\n\toption src 'dawn1'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_cabin_port'\n\toption name 'Dawnline-dawn1'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4600'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_open_zone'\n\toption name 'dawn2'\n\tlist network 'dawn2'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_open_lan'\n\toption src 'dawn2'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_open_from_lan'\n\toption src 'home'\n\toption dest 'dawn2'\n\nconfig forwarding 'dawnline_open_wan'\n\toption src 'dawn2'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_open_loop'\n\toption src 'dawn2'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_open_port'\n\toption name 'Dawnline-dawn2'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4700'\Line truncated
"firewall": "\nconfig defaults\n\toption syn_flood '1'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'REJECT'\n\nconfig zone\n\toption name 'lan'\n\tlist network 'lan'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig zone\n\toption name 'wan'\n\tlist network 'wan'\n\tlist network 'wan6'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'DROP'\n\toption masq '1'\n\toption mtu_fix '1'\n\nconfig forwarding\n\toption src 'lan'\n\toption dest 'wan'\n\nconfig rule\n\toption name 'Allow-DHCP-Renew'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '68'\n\toption target 'ACCEPT'\n\toption family 'ipv4'\n\nconfig rule\n\toption name 'Allow-Ping'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption icmp_type 'echo-request'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IGMP'\n\toption src 'wan'\n\toption proto 'igmp'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-DHCPv6'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '546'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-MLD'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption src_ip 'fe80::/10'\n\tlist icmp_type '130/0'\n\tlist icmp_type '131/0'\n\tlist icmp_type '132/0'\n\tlist icmp_type '143/0'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Input'\n\toption src 'wan'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\tlist icmp_type 'router-solicitation'\n\tlist icmp_type 'neighbour-solicitation'\n\tlist icmp_type 'router-advertisement'\n\tlist icmp_type 'neighbour-advertisement'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Forward'\n\toption src 'wan'\n\toption dest '*'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IPSec-ESP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption proto 'esp'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ISAKMP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption dest_port '500'\n\toption proto 'udp'\n\toption target 'ACCEPT'\n\nconfig zone\n\toption name 'guest'\n\tlist device 'dlguest'\n\nconfig zone\n\toption name 'home'\n\toption device 'br-lan dlhome'\n\nconfig rule 'dawnline_home_loopdns'\n\toption name 'Dawnline-dawn0-names'\n\toption src 'dawn0'\n\toption dest 'dl_loop'\n\toption proto 'tcp udp'\n\toption dest_port '53'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_home_zone'\n\toption name 'dawn0'\n\tlist network 'dawn0'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_home_lan'\n\toption src 'dawn0'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_home_from_lan'\n\toption src 'home'\n\toption dest 'dawn0'\n\nconfig forwarding 'dawnline_home_wan'\n\toption src 'dawn0'\n\toption dest 'wan'\n\nconfig rule 'dawnline_home_port'\n\toption name 'Dawnline-dawn0'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4500'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_cabin_zone'\n\toption name 'dawn1'\n\tlist network 'dawn1'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_cabin_lan'\n\toption src 'dawn1'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_cabin_from_lan'\n\toption src 'home'\n\toption dest 'dawn1'\n\nconfig forwarding 'dawnline_cabin_wan'\n\toption src 'dawn1'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_cabin_loop'\n\toption src 'dawn1'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_cabin_port'\n\toption name 'Dawnline-dawn1'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4600'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_open_zone'\n\toption name 'dawn2'\n\tlist network 'dawn2'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_open_lan'\n\toption src 'dawn2'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_open_from_lan'\n\toption src 'home'\n\toption dest 'dawn2'\n\nconfig forwarding 'dawnline_open_wan'\n\toption src 'dawn2'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_open_loop'\n\toption src 'dawn2'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_open_port'\n\toption name 'Dawnline-dawn2'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4700Line truncated
"cmds": [
"ubus call network.interface dump"
]
},
{
"what": "a port changed, a server turned off, a second home zone",
"dry": false,
"changed": true,
"before": "\nconfig defaults\n\toption syn_flood '1'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'REJECT'\n\nconfig zone\n\toption name 'lan'\n\tlist network 'lan'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig zone\n\toption name 'wan'\n\tlist network 'wan'\n\tlist network 'wan6'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'DROP'\n\toption masq '1'\n\toption mtu_fix '1'\n\nconfig forwarding\n\toption src 'lan'\n\toption dest 'wan'\n\nconfig rule\n\toption name 'Allow-DHCP-Renew'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '68'\n\toption target 'ACCEPT'\n\toption family 'ipv4'\n\nconfig rule\n\toption name 'Allow-Ping'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption icmp_type 'echo-request'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IGMP'\n\toption src 'wan'\n\toption proto 'igmp'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-DHCPv6'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '546'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-MLD'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption src_ip 'fe80::/10'\n\tlist icmp_type '130/0'\n\tlist icmp_type '131/0'\n\tlist icmp_type '132/0'\n\tlist icmp_type '143/0'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Input'\n\toption src 'wan'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\tlist icmp_type 'router-solicitation'\n\tlist icmp_type 'neighbour-solicitation'\n\tlist icmp_type 'router-advertisement'\n\tlist icmp_type 'neighbour-advertisement'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Forward'\n\toption src 'wan'\n\toption dest '*'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IPSec-ESP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption proto 'esp'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ISAKMP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption dest_port '500'\n\toption proto 'udp'\n\toption target 'ACCEPT'\n\nconfig zone\n\toption name 'guest'\n\tlist device 'dlguest'\n\nconfig zone\n\toption name 'home'\n\toption device 'br-lan dlhome'\n\nconfig rule 'dawnline_home_loopdns'\n\toption name 'Dawnline-dawn0-names'\n\toption src 'dawn0'\n\toption dest 'dl_loop'\n\toption proto 'tcp udp'\n\toption dest_port '53'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_home_zone'\n\toption name 'dawn0'\n\tlist network 'dawn0'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_home_lan'\n\toption src 'dawn0'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_home_from_lan'\n\toption src 'home'\n\toption dest 'dawn0'\n\nconfig forwarding 'dawnline_home_wan'\n\toption src 'dawn0'\n\toption dest 'wan'\n\nconfig rule 'dawnline_home_port'\n\toption name 'Dawnline-dawn0'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4500'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_cabin_zone'\n\toption name 'dawn1'\n\tlist network 'dawn1'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_cabin_lan'\n\toption src 'dawn1'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_cabin_from_lan'\n\toption src 'home'\n\toption dest 'dawn1'\n\nconfig forwarding 'dawnline_cabin_wan'\n\toption src 'dawn1'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_cabin_loop'\n\toption src 'dawn1'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_cabin_port'\n\toption name 'Dawnline-dawn1'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4600'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_open_zone'\n\toption name 'dawn2'\n\tlist network 'dawn2'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_open_lan'\n\toption src 'dawn2'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_open_from_lan'\n\toption src 'home'\n\toption dest 'dawn2'\n\nconfig forwarding 'dawnline_open_wan'\n\toption src 'dawn2'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_open_loop'\n\toption src 'dawn2'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_open_port'\n\toption name 'Dawnline-dawn2'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4700'\Line truncated
"firewall": "\nconfig defaults\n\toption syn_flood '1'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'REJECT'\n\nconfig zone\n\toption name 'lan'\n\tlist network 'lan'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig zone\n\toption name 'wan'\n\tlist network 'wan'\n\tlist network 'wan6'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'DROP'\n\toption masq '1'\n\toption mtu_fix '1'\n\nconfig forwarding\n\toption src 'lan'\n\toption dest 'wan'\n\nconfig rule\n\toption name 'Allow-DHCP-Renew'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '68'\n\toption target 'ACCEPT'\n\toption family 'ipv4'\n\nconfig rule\n\toption name 'Allow-Ping'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption icmp_type 'echo-request'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IGMP'\n\toption src 'wan'\n\toption proto 'igmp'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-DHCPv6'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '546'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-MLD'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption src_ip 'fe80::/10'\n\tlist icmp_type '130/0'\n\tlist icmp_type '131/0'\n\tlist icmp_type '132/0'\n\tlist icmp_type '143/0'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Input'\n\toption src 'wan'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\tlist icmp_type 'router-solicitation'\n\tlist icmp_type 'neighbour-solicitation'\n\tlist icmp_type 'router-advertisement'\n\tlist icmp_type 'neighbour-advertisement'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Forward'\n\toption src 'wan'\n\toption dest '*'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IPSec-ESP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption proto 'esp'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ISAKMP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption dest_port '500'\n\toption proto 'udp'\n\toption target 'ACCEPT'\n\nconfig zone\n\toption name 'guest'\n\tlist device 'dlguest'\n\nconfig zone\n\toption name 'home'\n\toption device 'br-lan dlhome'\n\nconfig rule 'dawnline_home_loopdns'\n\toption name 'Dawnline-dawn0-names'\n\toption src 'dawn0'\n\toption dest 'dl_loop'\n\toption proto 'tcp udp'\n\toption dest_port '53'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_home_zone'\n\toption name 'dawn0'\n\tlist network 'dawn0'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_home_lan'\n\toption src 'dawn0'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_home_from_lan'\n\toption src 'home'\n\toption dest 'dawn0'\n\nconfig forwarding 'dawnline_home_wan'\n\toption src 'dawn0'\n\toption dest 'wan'\n\nconfig rule 'dawnline_home_port'\n\toption name 'Dawnline-dawn0'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4501'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_cabin_zone'\n\toption name 'dawn1'\n\tlist network 'dawn1'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_cabin_lan'\n\toption src 'dawn1'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_cabin_from_lan'\n\toption src 'home'\n\toption dest 'dawn1'\n\nconfig forwarding 'dawnline_cabin_wan'\n\toption src 'dawn1'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_cabin_loop'\n\toption src 'dawn1'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_cabin_port'\n\toption name 'Dawnline-dawn1'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4600'\n\toption target 'ACCEPT'\n\toption enabled '0'\n\nconfig zone 'dawnline_open_zone'\n\toption name 'dawn2'\n\tlist network 'dawn2'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_open_lan'\n\toption src 'dawn2'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_open_from_lan'\n\toption src 'home'\n\toption dest 'dawn2'\n\nconfig forwarding 'dawnline_open_wan'\n\toption src 'dawn2'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_open_loop'\n\toption src 'dawn2'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_open_port'\n\toption name 'Dawnline-dawn2'\n\toption src 'wan'\n\toption proto 'udp'\n\tLine truncated
"cmds": [
"ubus call network.interface dump",
"fw4 -q reload"
]
},
{
"what": "a server that does not reach the zone of the DNS of the LAN",
"dry": false,
"changed": true,
"before": "\nconfig defaults\n\toption syn_flood '1'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'REJECT'\n\nconfig zone\n\toption name 'lan'\n\tlist network 'lan'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig zone\n\toption name 'wan'\n\tlist network 'wan'\n\tlist network 'wan6'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'DROP'\n\toption masq '1'\n\toption mtu_fix '1'\n\nconfig forwarding\n\toption src 'lan'\n\toption dest 'wan'\n\nconfig rule\n\toption name 'Allow-DHCP-Renew'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '68'\n\toption target 'ACCEPT'\n\toption family 'ipv4'\n\nconfig rule\n\toption name 'Allow-Ping'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption icmp_type 'echo-request'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IGMP'\n\toption src 'wan'\n\toption proto 'igmp'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-DHCPv6'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '546'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-MLD'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption src_ip 'fe80::/10'\n\tlist icmp_type '130/0'\n\tlist icmp_type '131/0'\n\tlist icmp_type '132/0'\n\tlist icmp_type '143/0'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Input'\n\toption src 'wan'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\tlist icmp_type 'router-solicitation'\n\tlist icmp_type 'neighbour-solicitation'\n\tlist icmp_type 'router-advertisement'\n\tlist icmp_type 'neighbour-advertisement'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Forward'\n\toption src 'wan'\n\toption dest '*'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IPSec-ESP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption proto 'esp'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ISAKMP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption dest_port '500'\n\toption proto 'udp'\n\toption target 'ACCEPT'\n\nconfig zone\n\toption name 'guest'\n\tlist device 'dlguest'\n\nconfig zone\n\toption name 'home'\n\toption device 'br-lan dlhome'\n\nconfig rule 'dawnline_home_loopdns'\n\toption name 'Dawnline-dawn0-names'\n\toption src 'dawn0'\n\toption dest 'dl_loop'\n\toption proto 'tcp udp'\n\toption dest_port '53'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_home_zone'\n\toption name 'dawn0'\n\tlist network 'dawn0'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_home_lan'\n\toption src 'dawn0'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_home_from_lan'\n\toption src 'home'\n\toption dest 'dawn0'\n\nconfig forwarding 'dawnline_home_wan'\n\toption src 'dawn0'\n\toption dest 'wan'\n\nconfig rule 'dawnline_home_port'\n\toption name 'Dawnline-dawn0'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4501'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_cabin_zone'\n\toption name 'dawn1'\n\tlist network 'dawn1'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_cabin_lan'\n\toption src 'dawn1'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_cabin_from_lan'\n\toption src 'home'\n\toption dest 'dawn1'\n\nconfig forwarding 'dawnline_cabin_wan'\n\toption src 'dawn1'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_cabin_loop'\n\toption src 'dawn1'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_cabin_port'\n\toption name 'Dawnline-dawn1'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4600'\n\toption target 'ACCEPT'\n\toption enabled '0'\n\nconfig zone 'dawnline_open_zone'\n\toption name 'dawn2'\n\tlist network 'dawn2'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_open_lan'\n\toption src 'dawn2'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_open_from_lan'\n\toption src 'home'\n\toption dest 'dawn2'\n\nconfig forwarding 'dawnline_open_wan'\n\toption src 'dawn2'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_open_loop'\n\toption src 'dawn2'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_open_port'\n\toption name 'Dawnline-dawn2'\n\toption src 'wan'\n\toption proto 'udp'\n\topLine truncated
"firewall": "\nconfig defaults\n\toption syn_flood '1'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'REJECT'\n\nconfig zone\n\toption name 'lan'\n\tlist network 'lan'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig zone\n\toption name 'wan'\n\tlist network 'wan'\n\tlist network 'wan6'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'DROP'\n\toption masq '1'\n\toption mtu_fix '1'\n\nconfig forwarding\n\toption src 'lan'\n\toption dest 'wan'\n\nconfig rule\n\toption name 'Allow-DHCP-Renew'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '68'\n\toption target 'ACCEPT'\n\toption family 'ipv4'\n\nconfig rule\n\toption name 'Allow-Ping'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption icmp_type 'echo-request'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IGMP'\n\toption src 'wan'\n\toption proto 'igmp'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-DHCPv6'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '546'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-MLD'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption src_ip 'fe80::/10'\n\tlist icmp_type '130/0'\n\tlist icmp_type '131/0'\n\tlist icmp_type '132/0'\n\tlist icmp_type '143/0'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Input'\n\toption src 'wan'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\tlist icmp_type 'router-solicitation'\n\tlist icmp_type 'neighbour-solicitation'\n\tlist icmp_type 'router-advertisement'\n\tlist icmp_type 'neighbour-advertisement'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Forward'\n\toption src 'wan'\n\toption dest '*'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IPSec-ESP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption proto 'esp'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ISAKMP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption dest_port '500'\n\toption proto 'udp'\n\toption target 'ACCEPT'\n\nconfig zone\n\toption name 'guest'\n\tlist device 'dlguest'\n\nconfig zone\n\toption name 'home'\n\toption device 'br-lan dlhome'\n\nconfig rule 'dawnline_home_loopdns'\n\toption name 'Dawnline-dawn0-names'\n\toption src 'dawn0'\n\toption dest 'dl_loop'\n\toption proto 'tcp udp'\n\toption dest_port '53'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_home_zone'\n\toption name 'dawn0'\n\tlist network 'dawn0'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_home_lan'\n\toption src 'dawn0'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_home_from_lan'\n\toption src 'home'\n\toption dest 'dawn0'\n\nconfig forwarding 'dawnline_home_wan'\n\toption src 'dawn0'\n\toption dest 'wan'\n\nconfig rule 'dawnline_home_port'\n\toption name 'Dawnline-dawn0'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4501'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_cabin_zone'\n\toption name 'dawn1'\n\tlist network 'dawn1'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_cabin_lan'\n\toption src 'dawn1'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_cabin_from_lan'\n\toption src 'home'\n\toption dest 'dawn1'\n\nconfig forwarding 'dawnline_cabin_wan'\n\toption src 'dawn1'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_cabin_loop'\n\toption src 'dawn1'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_cabin_port'\n\toption name 'Dawnline-dawn1'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4600'\n\toption target 'ACCEPT'\n\toption enabled '0'\n\nconfig zone 'dawnline_open_zone'\n\toption name 'dawn2'\n\tlist network 'dawn2'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_open_lan'\n\toption src 'dawn2'\n\toption dest 'guest'\n\nconfig forwarding 'dawnline_open_from_lan'\n\toption src 'guest'\n\toption dest 'dawn2'\n\nconfig forwarding 'dawnline_open_wan'\n\toption src 'dawn2'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_open_loop'\n\toption src 'dawn2'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_open_port'\n\toption name 'Dawnline-dawn2'\n\toption src 'wan'\n\toption proto 'udp'\nLine truncated
"cmds": [
"ubus call network.interface dump",
"fw4 -q reload"
]
},
{
"what": "the portal on a port it never takes",
"dry": false,
"changed": true,
"before": "\nconfig defaults\n\toption syn_flood '1'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'REJECT'\n\nconfig zone\n\toption name 'lan'\n\tlist network 'lan'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig zone\n\toption name 'wan'\n\tlist network 'wan'\n\tlist network 'wan6'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'DROP'\n\toption masq '1'\n\toption mtu_fix '1'\n\nconfig forwarding\n\toption src 'lan'\n\toption dest 'wan'\n\nconfig rule\n\toption name 'Allow-DHCP-Renew'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '68'\n\toption target 'ACCEPT'\n\toption family 'ipv4'\n\nconfig rule\n\toption name 'Allow-Ping'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption icmp_type 'echo-request'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IGMP'\n\toption src 'wan'\n\toption proto 'igmp'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-DHCPv6'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '546'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-MLD'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption src_ip 'fe80::/10'\n\tlist icmp_type '130/0'\n\tlist icmp_type '131/0'\n\tlist icmp_type '132/0'\n\tlist icmp_type '143/0'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Input'\n\toption src 'wan'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\tlist icmp_type 'router-solicitation'\n\tlist icmp_type 'neighbour-solicitation'\n\tlist icmp_type 'router-advertisement'\n\tlist icmp_type 'neighbour-advertisement'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Forward'\n\toption src 'wan'\n\toption dest '*'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IPSec-ESP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption proto 'esp'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ISAKMP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption dest_port '500'\n\toption proto 'udp'\n\toption target 'ACCEPT'\n\nconfig zone\n\toption name 'guest'\n\tlist device 'dlguest'\n\nconfig zone\n\toption name 'home'\n\toption device 'br-lan dlhome'\n\nconfig rule 'dawnline_home_loopdns'\n\toption name 'Dawnline-dawn0-names'\n\toption src 'dawn0'\n\toption dest 'dl_loop'\n\toption proto 'tcp udp'\n\toption dest_port '53'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_home_zone'\n\toption name 'dawn0'\n\tlist network 'dawn0'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_home_lan'\n\toption src 'dawn0'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_home_from_lan'\n\toption src 'home'\n\toption dest 'dawn0'\n\nconfig forwarding 'dawnline_home_wan'\n\toption src 'dawn0'\n\toption dest 'wan'\n\nconfig rule 'dawnline_home_port'\n\toption name 'Dawnline-dawn0'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4501'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_cabin_zone'\n\toption name 'dawn1'\n\tlist network 'dawn1'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_cabin_lan'\n\toption src 'dawn1'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_cabin_from_lan'\n\toption src 'home'\n\toption dest 'dawn1'\n\nconfig forwarding 'dawnline_cabin_wan'\n\toption src 'dawn1'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_cabin_loop'\n\toption src 'dawn1'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_cabin_port'\n\toption name 'Dawnline-dawn1'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4600'\n\toption target 'ACCEPT'\n\toption enabled '0'\n\nconfig zone 'dawnline_open_zone'\n\toption name 'dawn2'\n\tlist network 'dawn2'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_open_lan'\n\toption src 'dawn2'\n\toption dest 'guest'\n\nconfig forwarding 'dawnline_open_from_lan'\n\toption src 'guest'\n\toption dest 'dawn2'\n\nconfig forwarding 'dawnline_open_wan'\n\toption src 'dawn2'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_open_loop'\n\toption src 'dawn2'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_open_port'\n\toption name 'Dawnline-dawn2'\n\toption src 'wan'\n\toption proto 'udp'\n\tLine truncated
"firewall": "\nconfig defaults\n\toption syn_flood '1'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'REJECT'\n\nconfig zone\n\toption name 'lan'\n\tlist network 'lan'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig zone\n\toption name 'wan'\n\tlist network 'wan'\n\tlist network 'wan6'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'DROP'\n\toption masq '1'\n\toption mtu_fix '1'\n\nconfig forwarding\n\toption src 'lan'\n\toption dest 'wan'\n\nconfig rule\n\toption name 'Allow-DHCP-Renew'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '68'\n\toption target 'ACCEPT'\n\toption family 'ipv4'\n\nconfig rule\n\toption name 'Allow-Ping'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption icmp_type 'echo-request'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IGMP'\n\toption src 'wan'\n\toption proto 'igmp'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-DHCPv6'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '546'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-MLD'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption src_ip 'fe80::/10'\n\tlist icmp_type '130/0'\n\tlist icmp_type '131/0'\n\tlist icmp_type '132/0'\n\tlist icmp_type '143/0'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Input'\n\toption src 'wan'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\tlist icmp_type 'router-solicitation'\n\tlist icmp_type 'neighbour-solicitation'\n\tlist icmp_type 'router-advertisement'\n\tlist icmp_type 'neighbour-advertisement'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Forward'\n\toption src 'wan'\n\toption dest '*'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IPSec-ESP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption proto 'esp'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ISAKMP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption dest_port '500'\n\toption proto 'udp'\n\toption target 'ACCEPT'\n\nconfig zone\n\toption name 'guest'\n\tlist device 'dlguest'\n\nconfig zone\n\toption name 'home'\n\toption device 'br-lan dlhome'\n\nconfig rule 'dawnline_home_loopdns'\n\toption name 'Dawnline-dawn0-names'\n\toption src 'dawn0'\n\toption dest 'dl_loop'\n\toption proto 'tcp udp'\n\toption dest_port '53'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_home_zone'\n\toption name 'dawn0'\n\tlist network 'dawn0'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_home_lan'\n\toption src 'dawn0'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_home_from_lan'\n\toption src 'home'\n\toption dest 'dawn0'\n\nconfig forwarding 'dawnline_home_wan'\n\toption src 'dawn0'\n\toption dest 'wan'\n\nconfig rule 'dawnline_home_port'\n\toption name 'Dawnline-dawn0'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4501'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_cabin_zone'\n\toption name 'dawn1'\n\tlist network 'dawn1'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_cabin_lan'\n\toption src 'dawn1'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_cabin_from_lan'\n\toption src 'home'\n\toption dest 'dawn1'\n\nconfig forwarding 'dawnline_cabin_wan'\n\toption src 'dawn1'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_cabin_loop'\n\toption src 'dawn1'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_cabin_port'\n\toption name 'Dawnline-dawn1'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4600'\n\toption target 'ACCEPT'\n\toption enabled '0'\n\nconfig zone 'dawnline_open_zone'\n\toption name 'dawn2'\n\tlist network 'dawn2'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_open_lan'\n\toption src 'dawn2'\n\toption dest 'guest'\n\nconfig forwarding 'dawnline_open_from_lan'\n\toption src 'guest'\n\toption dest 'dawn2'\n\nconfig forwarding 'dawnline_open_wan'\n\toption src 'dawn2'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_open_loop'\n\toption src 'dawn2'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_open_port'\n\toption name 'Dawnline-dawn2'\n\toption src 'wan'\n\toption proto 'udp'\nLine truncated
"cmds": [
"ubus call network.interface dump",
"fw4 -q reload"
]
},
{
"what": "the portal back, with names only: no plain HTTP",
"dry": false,
"changed": true,
"before": "\nconfig defaults\n\toption syn_flood '1'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'REJECT'\n\nconfig zone\n\toption name 'lan'\n\tlist network 'lan'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig zone\n\toption name 'wan'\n\tlist network 'wan'\n\tlist network 'wan6'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'DROP'\n\toption masq '1'\n\toption mtu_fix '1'\n\nconfig forwarding\n\toption src 'lan'\n\toption dest 'wan'\n\nconfig rule\n\toption name 'Allow-DHCP-Renew'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '68'\n\toption target 'ACCEPT'\n\toption family 'ipv4'\n\nconfig rule\n\toption name 'Allow-Ping'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption icmp_type 'echo-request'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IGMP'\n\toption src 'wan'\n\toption proto 'igmp'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-DHCPv6'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '546'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-MLD'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption src_ip 'fe80::/10'\n\tlist icmp_type '130/0'\n\tlist icmp_type '131/0'\n\tlist icmp_type '132/0'\n\tlist icmp_type '143/0'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Input'\n\toption src 'wan'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\tlist icmp_type 'router-solicitation'\n\tlist icmp_type 'neighbour-solicitation'\n\tlist icmp_type 'router-advertisement'\n\tlist icmp_type 'neighbour-advertisement'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Forward'\n\toption src 'wan'\n\toption dest '*'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IPSec-ESP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption proto 'esp'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ISAKMP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption dest_port '500'\n\toption proto 'udp'\n\toption target 'ACCEPT'\n\nconfig zone\n\toption name 'guest'\n\tlist device 'dlguest'\n\nconfig zone\n\toption name 'home'\n\toption device 'br-lan dlhome'\n\nconfig rule 'dawnline_home_loopdns'\n\toption name 'Dawnline-dawn0-names'\n\toption src 'dawn0'\n\toption dest 'dl_loop'\n\toption proto 'tcp udp'\n\toption dest_port '53'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_home_zone'\n\toption name 'dawn0'\n\tlist network 'dawn0'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_home_lan'\n\toption src 'dawn0'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_home_from_lan'\n\toption src 'home'\n\toption dest 'dawn0'\n\nconfig forwarding 'dawnline_home_wan'\n\toption src 'dawn0'\n\toption dest 'wan'\n\nconfig rule 'dawnline_home_port'\n\toption name 'Dawnline-dawn0'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4501'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_cabin_zone'\n\toption name 'dawn1'\n\tlist network 'dawn1'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_cabin_lan'\n\toption src 'dawn1'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_cabin_from_lan'\n\toption src 'home'\n\toption dest 'dawn1'\n\nconfig forwarding 'dawnline_cabin_wan'\n\toption src 'dawn1'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_cabin_loop'\n\toption src 'dawn1'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_cabin_port'\n\toption name 'Dawnline-dawn1'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4600'\n\toption target 'ACCEPT'\n\toption enabled '0'\n\nconfig zone 'dawnline_open_zone'\n\toption name 'dawn2'\n\tlist network 'dawn2'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_open_lan'\n\toption src 'dawn2'\n\toption dest 'guest'\n\nconfig forwarding 'dawnline_open_from_lan'\n\toption src 'guest'\n\toption dest 'dawn2'\n\nconfig forwarding 'dawnline_open_wan'\n\toption src 'dawn2'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_open_loop'\n\toption src 'dawn2'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_open_port'\n\toption name 'Dawnline-dawn2'\n\toption src 'wan'\n\toption proto 'udp'\n\tLine truncated
"firewall": "\nconfig defaults\n\toption syn_flood '1'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'REJECT'\n\nconfig zone\n\toption name 'lan'\n\tlist network 'lan'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig zone\n\toption name 'wan'\n\tlist network 'wan'\n\tlist network 'wan6'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'DROP'\n\toption masq '1'\n\toption mtu_fix '1'\n\nconfig forwarding\n\toption src 'lan'\n\toption dest 'wan'\n\nconfig rule\n\toption name 'Allow-DHCP-Renew'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '68'\n\toption target 'ACCEPT'\n\toption family 'ipv4'\n\nconfig rule\n\toption name 'Allow-Ping'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption icmp_type 'echo-request'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IGMP'\n\toption src 'wan'\n\toption proto 'igmp'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-DHCPv6'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '546'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-MLD'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption src_ip 'fe80::/10'\n\tlist icmp_type '130/0'\n\tlist icmp_type '131/0'\n\tlist icmp_type '132/0'\n\tlist icmp_type '143/0'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Input'\n\toption src 'wan'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\tlist icmp_type 'router-solicitation'\n\tlist icmp_type 'neighbour-solicitation'\n\tlist icmp_type 'router-advertisement'\n\tlist icmp_type 'neighbour-advertisement'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Forward'\n\toption src 'wan'\n\toption dest '*'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IPSec-ESP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption proto 'esp'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ISAKMP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption dest_port '500'\n\toption proto 'udp'\n\toption target 'ACCEPT'\n\nconfig zone\n\toption name 'guest'\n\tlist device 'dlguest'\n\nconfig zone\n\toption name 'home'\n\toption device 'br-lan dlhome'\n\nconfig rule 'dawnline_home_loopdns'\n\toption name 'Dawnline-dawn0-names'\n\toption src 'dawn0'\n\toption dest 'dl_loop'\n\toption proto 'tcp udp'\n\toption dest_port '53'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_home_zone'\n\toption name 'dawn0'\n\tlist network 'dawn0'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_home_lan'\n\toption src 'dawn0'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_home_from_lan'\n\toption src 'home'\n\toption dest 'dawn0'\n\nconfig forwarding 'dawnline_home_wan'\n\toption src 'dawn0'\n\toption dest 'wan'\n\nconfig rule 'dawnline_home_port'\n\toption name 'Dawnline-dawn0'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4501'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_cabin_zone'\n\toption name 'dawn1'\n\tlist network 'dawn1'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_cabin_lan'\n\toption src 'dawn1'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_cabin_from_lan'\n\toption src 'home'\n\toption dest 'dawn1'\n\nconfig forwarding 'dawnline_cabin_wan'\n\toption src 'dawn1'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_cabin_loop'\n\toption src 'dawn1'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_cabin_port'\n\toption name 'Dawnline-dawn1'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4600'\n\toption target 'ACCEPT'\n\toption enabled '0'\n\nconfig zone 'dawnline_open_zone'\n\toption name 'dawn2'\n\tlist network 'dawn2'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_open_lan'\n\toption src 'dawn2'\n\toption dest 'guest'\n\nconfig forwarding 'dawnline_open_from_lan'\n\toption src 'guest'\n\toption dest 'dawn2'\n\nconfig forwarding 'dawnline_open_wan'\n\toption src 'dawn2'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_open_loop'\n\toption src 'dawn2'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_open_port'\n\toption name 'Dawnline-dawn2'\n\toption src 'wan'\n\toption proto 'udp'\nLine truncated
"cmds": [
"ubus call network.interface dump",
"fw4 -q reload"
]
},
{
"what": "would it change: asked only",
"dry": true,
"changed": true,
"before": "\nconfig defaults\n\toption syn_flood '1'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'REJECT'\n\nconfig zone\n\toption name 'lan'\n\tlist network 'lan'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig zone\n\toption name 'wan'\n\tlist network 'wan'\n\tlist network 'wan6'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'DROP'\n\toption masq '1'\n\toption mtu_fix '1'\n\nconfig forwarding\n\toption src 'lan'\n\toption dest 'wan'\n\nconfig rule\n\toption name 'Allow-DHCP-Renew'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '68'\n\toption target 'ACCEPT'\n\toption family 'ipv4'\n\nconfig rule\n\toption name 'Allow-Ping'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption icmp_type 'echo-request'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IGMP'\n\toption src 'wan'\n\toption proto 'igmp'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-DHCPv6'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '546'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-MLD'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption src_ip 'fe80::/10'\n\tlist icmp_type '130/0'\n\tlist icmp_type '131/0'\n\tlist icmp_type '132/0'\n\tlist icmp_type '143/0'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Input'\n\toption src 'wan'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\tlist icmp_type 'router-solicitation'\n\tlist icmp_type 'neighbour-solicitation'\n\tlist icmp_type 'router-advertisement'\n\tlist icmp_type 'neighbour-advertisement'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Forward'\n\toption src 'wan'\n\toption dest '*'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IPSec-ESP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption proto 'esp'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ISAKMP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption dest_port '500'\n\toption proto 'udp'\n\toption target 'ACCEPT'\n\nconfig zone\n\toption name 'guest'\n\tlist device 'dlguest'\n\nconfig zone\n\toption name 'home'\n\toption device 'br-lan dlhome'\n\nconfig rule 'dawnline_home_loopdns'\n\toption name 'Dawnline-dawn0-names'\n\toption src 'dawn0'\n\toption dest 'dl_loop'\n\toption proto 'tcp udp'\n\toption dest_port '53'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_home_zone'\n\toption name 'dawn0'\n\tlist network 'dawn0'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_home_lan'\n\toption src 'dawn0'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_home_from_lan'\n\toption src 'home'\n\toption dest 'dawn0'\n\nconfig forwarding 'dawnline_home_wan'\n\toption src 'dawn0'\n\toption dest 'wan'\n\nconfig rule 'dawnline_home_port'\n\toption name 'Dawnline-dawn0'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4501'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_cabin_zone'\n\toption name 'dawn1'\n\tlist network 'dawn1'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_cabin_lan'\n\toption src 'dawn1'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_cabin_from_lan'\n\toption src 'home'\n\toption dest 'dawn1'\n\nconfig forwarding 'dawnline_cabin_wan'\n\toption src 'dawn1'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_cabin_loop'\n\toption src 'dawn1'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_cabin_port'\n\toption name 'Dawnline-dawn1'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4600'\n\toption target 'ACCEPT'\n\toption enabled '0'\n\nconfig zone 'dawnline_open_zone'\n\toption name 'dawn2'\n\tlist network 'dawn2'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_open_lan'\n\toption src 'dawn2'\n\toption dest 'guest'\n\nconfig forwarding 'dawnline_open_from_lan'\n\toption src 'guest'\n\toption dest 'dawn2'\n\nconfig forwarding 'dawnline_open_wan'\n\toption src 'dawn2'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_open_loop'\n\toption src 'dawn2'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_open_port'\n\toption name 'Dawnline-dawn2'\n\toption src 'wan'\n\toption proto 'udp'\n\tLine truncated
"firewall": "\nconfig defaults\n\toption syn_flood '1'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'REJECT'\n\nconfig zone\n\toption name 'lan'\n\tlist network 'lan'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig zone\n\toption name 'wan'\n\tlist network 'wan'\n\tlist network 'wan6'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'DROP'\n\toption masq '1'\n\toption mtu_fix '1'\n\nconfig forwarding\n\toption src 'lan'\n\toption dest 'wan'\n\nconfig rule\n\toption name 'Allow-DHCP-Renew'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '68'\n\toption target 'ACCEPT'\n\toption family 'ipv4'\n\nconfig rule\n\toption name 'Allow-Ping'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption icmp_type 'echo-request'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IGMP'\n\toption src 'wan'\n\toption proto 'igmp'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-DHCPv6'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '546'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-MLD'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption src_ip 'fe80::/10'\n\tlist icmp_type '130/0'\n\tlist icmp_type '131/0'\n\tlist icmp_type '132/0'\n\tlist icmp_type '143/0'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Input'\n\toption src 'wan'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\tlist icmp_type 'router-solicitation'\n\tlist icmp_type 'neighbour-solicitation'\n\tlist icmp_type 'router-advertisement'\n\tlist icmp_type 'neighbour-advertisement'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Forward'\n\toption src 'wan'\n\toption dest '*'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IPSec-ESP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption proto 'esp'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ISAKMP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption dest_port '500'\n\toption proto 'udp'\n\toption target 'ACCEPT'\n\nconfig zone\n\toption name 'guest'\n\tlist device 'dlguest'\n\nconfig zone\n\toption name 'home'\n\toption device 'br-lan dlhome'\n\nconfig rule 'dawnline_home_loopdns'\n\toption name 'Dawnline-dawn0-names'\n\toption src 'dawn0'\n\toption dest 'dl_loop'\n\toption proto 'tcp udp'\n\toption dest_port '53'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_home_zone'\n\toption name 'dawn0'\n\tlist network 'dawn0'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_home_lan'\n\toption src 'dawn0'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_home_from_lan'\n\toption src 'home'\n\toption dest 'dawn0'\n\nconfig forwarding 'dawnline_home_wan'\n\toption src 'dawn0'\n\toption dest 'wan'\n\nconfig rule 'dawnline_home_port'\n\toption name 'Dawnline-dawn0'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4501'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_cabin_zone'\n\toption name 'dawn1'\n\tlist network 'dawn1'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_cabin_lan'\n\toption src 'dawn1'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_cabin_from_lan'\n\toption src 'home'\n\toption dest 'dawn1'\n\nconfig forwarding 'dawnline_cabin_wan'\n\toption src 'dawn1'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_cabin_loop'\n\toption src 'dawn1'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_cabin_port'\n\toption name 'Dawnline-dawn1'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4600'\n\toption target 'ACCEPT'\n\toption enabled '0'\n\nconfig zone 'dawnline_open_zone'\n\toption name 'dawn2'\n\tlist network 'dawn2'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_open_lan'\n\toption src 'dawn2'\n\toption dest 'guest'\n\nconfig forwarding 'dawnline_open_from_lan'\n\toption src 'guest'\n\toption dest 'dawn2'\n\nconfig forwarding 'dawnline_open_wan'\n\toption src 'dawn2'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_open_loop'\n\toption src 'dawn2'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_open_port'\n\toption name 'Dawnline-dawn2'\n\toption src 'wan'\n\toption proto 'udp'\nLine truncated
"cmds": [
"ubus call network.interface dump"
]
},
{
"what": "a server removed, another like a home device",
"dry": false,
"changed": true,
"before": "\nconfig defaults\n\toption syn_flood '1'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'REJECT'\n\nconfig zone\n\toption name 'lan'\n\tlist network 'lan'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig zone\n\toption name 'wan'\n\tlist network 'wan'\n\tlist network 'wan6'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'DROP'\n\toption masq '1'\n\toption mtu_fix '1'\n\nconfig forwarding\n\toption src 'lan'\n\toption dest 'wan'\n\nconfig rule\n\toption name 'Allow-DHCP-Renew'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '68'\n\toption target 'ACCEPT'\n\toption family 'ipv4'\n\nconfig rule\n\toption name 'Allow-Ping'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption icmp_type 'echo-request'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IGMP'\n\toption src 'wan'\n\toption proto 'igmp'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-DHCPv6'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '546'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-MLD'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption src_ip 'fe80::/10'\n\tlist icmp_type '130/0'\n\tlist icmp_type '131/0'\n\tlist icmp_type '132/0'\n\tlist icmp_type '143/0'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Input'\n\toption src 'wan'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\tlist icmp_type 'router-solicitation'\n\tlist icmp_type 'neighbour-solicitation'\n\tlist icmp_type 'router-advertisement'\n\tlist icmp_type 'neighbour-advertisement'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Forward'\n\toption src 'wan'\n\toption dest '*'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IPSec-ESP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption proto 'esp'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ISAKMP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption dest_port '500'\n\toption proto 'udp'\n\toption target 'ACCEPT'\n\nconfig zone\n\toption name 'guest'\n\tlist device 'dlguest'\n\nconfig zone\n\toption name 'home'\n\toption device 'br-lan dlhome'\n\nconfig rule 'dawnline_home_loopdns'\n\toption name 'Dawnline-dawn0-names'\n\toption src 'dawn0'\n\toption dest 'dl_loop'\n\toption proto 'tcp udp'\n\toption dest_port '53'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_home_zone'\n\toption name 'dawn0'\n\tlist network 'dawn0'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_home_lan'\n\toption src 'dawn0'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_home_from_lan'\n\toption src 'home'\n\toption dest 'dawn0'\n\nconfig forwarding 'dawnline_home_wan'\n\toption src 'dawn0'\n\toption dest 'wan'\n\nconfig rule 'dawnline_home_port'\n\toption name 'Dawnline-dawn0'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4501'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_cabin_zone'\n\toption name 'dawn1'\n\tlist network 'dawn1'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_cabin_lan'\n\toption src 'dawn1'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_cabin_from_lan'\n\toption src 'home'\n\toption dest 'dawn1'\n\nconfig forwarding 'dawnline_cabin_wan'\n\toption src 'dawn1'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_cabin_loop'\n\toption src 'dawn1'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_cabin_port'\n\toption name 'Dawnline-dawn1'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4600'\n\toption target 'ACCEPT'\n\toption enabled '0'\n\nconfig zone 'dawnline_open_zone'\n\toption name 'dawn2'\n\tlist network 'dawn2'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_open_lan'\n\toption src 'dawn2'\n\toption dest 'guest'\n\nconfig forwarding 'dawnline_open_from_lan'\n\toption src 'guest'\n\toption dest 'dawn2'\n\nconfig forwarding 'dawnline_open_wan'\n\toption src 'dawn2'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_open_loop'\n\toption src 'dawn2'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_open_port'\n\toption name 'Dawnline-dawn2'\n\toption src 'wan'\n\toption proto 'udp'\n\tLine truncated
"firewall": "\nconfig defaults\n\toption syn_flood '1'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'REJECT'\n\nconfig zone\n\toption name 'lan'\n\tlist network 'lan'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig zone\n\toption name 'wan'\n\tlist network 'wan'\n\tlist network 'wan6'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'DROP'\n\toption masq '1'\n\toption mtu_fix '1'\n\nconfig forwarding\n\toption src 'lan'\n\toption dest 'wan'\n\nconfig rule\n\toption name 'Allow-DHCP-Renew'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '68'\n\toption target 'ACCEPT'\n\toption family 'ipv4'\n\nconfig rule\n\toption name 'Allow-Ping'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption icmp_type 'echo-request'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IGMP'\n\toption src 'wan'\n\toption proto 'igmp'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-DHCPv6'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '546'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-MLD'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption src_ip 'fe80::/10'\n\tlist icmp_type '130/0'\n\tlist icmp_type '131/0'\n\tlist icmp_type '132/0'\n\tlist icmp_type '143/0'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Input'\n\toption src 'wan'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\tlist icmp_type 'router-solicitation'\n\tlist icmp_type 'neighbour-solicitation'\n\tlist icmp_type 'router-advertisement'\n\tlist icmp_type 'neighbour-advertisement'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Forward'\n\toption src 'wan'\n\toption dest '*'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IPSec-ESP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption proto 'esp'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ISAKMP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption dest_port '500'\n\toption proto 'udp'\n\toption target 'ACCEPT'\n\nconfig zone\n\toption name 'guest'\n\tlist device 'dlguest'\n\nconfig zone\n\toption name 'home'\n\toption device 'br-lan dlhome'\n\nconfig zone 'dawnline_home_zone'\n\toption name 'dawn0'\n\tlist network 'dawn0'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_home_lan'\n\toption src 'dawn0'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_home_from_lan'\n\toption src 'home'\n\toption dest 'dawn0'\n\nconfig forwarding 'dawnline_home_wan'\n\toption src 'dawn0'\n\toption dest 'wan'\n\nconfig rule 'dawnline_home_port'\n\toption name 'Dawnline-dawn0'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4502'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_open_zone'\n\toption name 'dawn2'\n\tlist network 'dawn2'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_open_lan'\n\toption src 'dawn2'\n\toption dest 'guest'\n\nconfig forwarding 'dawnline_open_from_lan'\n\toption src 'guest'\n\toption dest 'dawn2'\n\nconfig forwarding 'dawnline_open_wan'\n\toption src 'dawn2'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_open_loop'\n\toption src 'dawn2'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_open_port'\n\toption name 'Dawnline-dawn2'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4700'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_loop'\n\toption name 'dl_loop'\n\tlist device 'dlx0'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'REJECT'\n\nconfig forwarding 'dawnline_loop_wan'\n\toption src 'dl_loop'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_home_lan_guest'\n\toption src 'dawn0'\n\toption dest 'guest'\n\nconfig forwarding 'dawnline_home_from_lan_guest'\n\toption src 'guest'\n\toption dest 'dawn0'\n\nconfig rule 'dawnline_open_landns'\n\toption name 'Dawnline-dawn2-dns'\n\toption src 'dawn2'\n\toption dest 'home'\n\toption dest_ip '192.168.77.1'\n\toption proto 'tcp udp'\n\toption dest_port '53'\n\toption target 'ACCEPT'\n\nconfig rule 'dawnline_portal'\n\toption name 'Dawnline-Portal'\n\toption src 'wan'\n\toption proto 'tcp'\n\toption dest_port '8443'\n\toption target 'ACCEPT'\n\nconfig forwarding 'dawnlinLine truncated
"cmds": [
"ubus call network.interface dump",
"fw4 -q reload"
]
},
{
"what": "nobody like a home device",
"dry": false,
"changed": true,
"before": "\nconfig defaults\n\toption syn_flood '1'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'REJECT'\n\nconfig zone\n\toption name 'lan'\n\tlist network 'lan'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig zone\n\toption name 'wan'\n\tlist network 'wan'\n\tlist network 'wan6'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'DROP'\n\toption masq '1'\n\toption mtu_fix '1'\n\nconfig forwarding\n\toption src 'lan'\n\toption dest 'wan'\n\nconfig rule\n\toption name 'Allow-DHCP-Renew'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '68'\n\toption target 'ACCEPT'\n\toption family 'ipv4'\n\nconfig rule\n\toption name 'Allow-Ping'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption icmp_type 'echo-request'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IGMP'\n\toption src 'wan'\n\toption proto 'igmp'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-DHCPv6'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '546'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-MLD'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption src_ip 'fe80::/10'\n\tlist icmp_type '130/0'\n\tlist icmp_type '131/0'\n\tlist icmp_type '132/0'\n\tlist icmp_type '143/0'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Input'\n\toption src 'wan'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\tlist icmp_type 'router-solicitation'\n\tlist icmp_type 'neighbour-solicitation'\n\tlist icmp_type 'router-advertisement'\n\tlist icmp_type 'neighbour-advertisement'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Forward'\n\toption src 'wan'\n\toption dest '*'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IPSec-ESP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption proto 'esp'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ISAKMP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption dest_port '500'\n\toption proto 'udp'\n\toption target 'ACCEPT'\n\nconfig zone\n\toption name 'guest'\n\tlist device 'dlguest'\n\nconfig zone\n\toption name 'home'\n\toption device 'br-lan dlhome'\n\nconfig zone 'dawnline_home_zone'\n\toption name 'dawn0'\n\tlist network 'dawn0'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_home_lan'\n\toption src 'dawn0'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_home_from_lan'\n\toption src 'home'\n\toption dest 'dawn0'\n\nconfig forwarding 'dawnline_home_wan'\n\toption src 'dawn0'\n\toption dest 'wan'\n\nconfig rule 'dawnline_home_port'\n\toption name 'Dawnline-dawn0'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4502'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_open_zone'\n\toption name 'dawn2'\n\tlist network 'dawn2'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_open_lan'\n\toption src 'dawn2'\n\toption dest 'guest'\n\nconfig forwarding 'dawnline_open_from_lan'\n\toption src 'guest'\n\toption dest 'dawn2'\n\nconfig forwarding 'dawnline_open_wan'\n\toption src 'dawn2'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_open_loop'\n\toption src 'dawn2'\n\toption dest 'dl_loop'\n\nconfig rule 'dawnline_open_port'\n\toption name 'Dawnline-dawn2'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4700'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_loop'\n\toption name 'dl_loop'\n\tlist device 'dlx0'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'REJECT'\n\nconfig forwarding 'dawnline_loop_wan'\n\toption src 'dl_loop'\n\toption dest 'wan'\n\nconfig forwarding 'dawnline_home_lan_guest'\n\toption src 'dawn0'\n\toption dest 'guest'\n\nconfig forwarding 'dawnline_home_from_lan_guest'\n\toption src 'guest'\n\toption dest 'dawn0'\n\nconfig rule 'dawnline_open_landns'\n\toption name 'Dawnline-dawn2-dns'\n\toption src 'dawn2'\n\toption dest 'home'\n\toption dest_ip '192.168.77.1'\n\toption proto 'tcp udp'\n\toption dest_port '53'\n\toption target 'ACCEPT'\n\nconfig rule 'dawnline_portal'\n\toption name 'Dawnline-Portal'\n\toption src 'wan'\n\toption proto 'tcp'\n\toption dest_port '8443'\n\toption target 'ACCEPT'\n\nconfig forwarding 'dawnline_Line truncated
"firewall": "\nconfig defaults\n\toption syn_flood '1'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'REJECT'\n\nconfig zone\n\toption name 'lan'\n\tlist network 'lan'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig zone\n\toption name 'wan'\n\tlist network 'wan'\n\tlist network 'wan6'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'DROP'\n\toption masq '1'\n\toption mtu_fix '1'\n\nconfig forwarding\n\toption src 'lan'\n\toption dest 'wan'\n\nconfig rule\n\toption name 'Allow-DHCP-Renew'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '68'\n\toption target 'ACCEPT'\n\toption family 'ipv4'\n\nconfig rule\n\toption name 'Allow-Ping'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption icmp_type 'echo-request'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IGMP'\n\toption src 'wan'\n\toption proto 'igmp'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-DHCPv6'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '546'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-MLD'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption src_ip 'fe80::/10'\n\tlist icmp_type '130/0'\n\tlist icmp_type '131/0'\n\tlist icmp_type '132/0'\n\tlist icmp_type '143/0'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Input'\n\toption src 'wan'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\tlist icmp_type 'router-solicitation'\n\tlist icmp_type 'neighbour-solicitation'\n\tlist icmp_type 'router-advertisement'\n\tlist icmp_type 'neighbour-advertisement'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Forward'\n\toption src 'wan'\n\toption dest '*'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IPSec-ESP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption proto 'esp'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ISAKMP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption dest_port '500'\n\toption proto 'udp'\n\toption target 'ACCEPT'\n\nconfig zone\n\toption name 'guest'\n\tlist device 'dlguest'\n\nconfig zone\n\toption name 'home'\n\toption device 'br-lan dlhome'\n\nconfig zone 'dawnline_home_zone'\n\toption name 'dawn0'\n\tlist network 'dawn0'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_home_lan'\n\toption src 'dawn0'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_home_from_lan'\n\toption src 'home'\n\toption dest 'dawn0'\n\nconfig forwarding 'dawnline_home_wan'\n\toption src 'dawn0'\n\toption dest 'wan'\n\nconfig rule 'dawnline_home_port'\n\toption name 'Dawnline-dawn0'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4502'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_open_zone'\n\toption name 'dawn2'\n\tlist network 'dawn2'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_open_lan'\n\toption src 'dawn2'\n\toption dest 'guest'\n\nconfig forwarding 'dawnline_open_from_lan'\n\toption src 'guest'\n\toption dest 'dawn2'\n\nconfig forwarding 'dawnline_open_wan'\n\toption src 'dawn2'\n\toption dest 'wan'\n\nconfig rule 'dawnline_open_port'\n\toption name 'Dawnline-dawn2'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4700'\n\toption target 'ACCEPT'\n\nconfig forwarding 'dawnline_home_lan_guest'\n\toption src 'dawn0'\n\toption dest 'guest'\n\nconfig forwarding 'dawnline_home_from_lan_guest'\n\toption src 'guest'\n\toption dest 'dawn0'\n\nconfig rule 'dawnline_open_landns'\n\toption name 'Dawnline-dawn2-dns'\n\toption src 'dawn2'\n\toption dest 'home'\n\toption dest_ip '192.168.77.1'\n\toption proto 'tcp udp'\n\toption dest_port '53'\n\toption target 'ACCEPT'\n\nconfig rule 'dawnline_portal'\n\toption name 'Dawnline-Portal'\n\toption src 'wan'\n\toption proto 'tcp'\n\toption dest_port '8443'\n\toption target 'ACCEPT'\n\n",
"cmds": [
"ubus call network.interface dump",
"fw4 -q reload"
]
},
{
"what": "a section of another kind under our name, one of a server long gone, the portal off",
"dry": false,
"changed": true,
"before": "\nconfig defaults\n\toption syn_flood '1'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'REJECT'\n\nconfig zone\n\toption name 'lan'\n\tlist network 'lan'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig zone\n\toption name 'wan'\n\tlist network 'wan'\n\tlist network 'wan6'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'DROP'\n\toption masq '1'\n\toption mtu_fix '1'\n\nconfig forwarding\n\toption src 'lan'\n\toption dest 'wan'\n\nconfig rule\n\toption name 'Allow-DHCP-Renew'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '68'\n\toption target 'ACCEPT'\n\toption family 'ipv4'\n\nconfig rule\n\toption name 'Allow-Ping'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption icmp_type 'echo-request'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IGMP'\n\toption src 'wan'\n\toption proto 'igmp'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-DHCPv6'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '546'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-MLD'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption src_ip 'fe80::/10'\n\tlist icmp_type '130/0'\n\tlist icmp_type '131/0'\n\tlist icmp_type '132/0'\n\tlist icmp_type '143/0'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Input'\n\toption src 'wan'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\tlist icmp_type 'router-solicitation'\n\tlist icmp_type 'neighbour-solicitation'\n\tlist icmp_type 'router-advertisement'\n\tlist icmp_type 'neighbour-advertisement'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Forward'\n\toption src 'wan'\n\toption dest '*'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IPSec-ESP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption proto 'esp'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ISAKMP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption dest_port '500'\n\toption proto 'udp'\n\toption target 'ACCEPT'\n\nconfig zone\n\toption name 'guest'\n\tlist device 'dlguest'\n\nconfig zone\n\toption name 'home'\n\toption device 'br-lan dlhome'\n\nconfig forwarding 'dawnline_home_lan'\n\toption src 'dawn0'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_home_from_lan'\n\toption src 'home'\n\toption dest 'dawn0'\n\nconfig forwarding 'dawnline_home_wan'\n\toption src 'dawn0'\n\toption dest 'wan'\n\nconfig rule 'dawnline_home_port'\n\toption name 'Dawnline-dawn0'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4502'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_open_zone'\n\toption name 'dawn2'\n\tlist network 'dawn2'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_open_lan'\n\toption src 'dawn2'\n\toption dest 'guest'\n\nconfig forwarding 'dawnline_open_from_lan'\n\toption src 'guest'\n\toption dest 'dawn2'\n\nconfig forwarding 'dawnline_open_wan'\n\toption src 'dawn2'\n\toption dest 'wan'\n\nconfig rule 'dawnline_open_port'\n\toption name 'Dawnline-dawn2'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4700'\n\toption target 'ACCEPT'\n\nconfig forwarding 'dawnline_home_lan_guest'\n\toption src 'dawn0'\n\toption dest 'guest'\n\nconfig forwarding 'dawnline_home_from_lan_guest'\n\toption src 'guest'\n\toption dest 'dawn0'\n\nconfig rule 'dawnline_open_landns'\n\toption name 'Dawnline-dawn2-dns'\n\toption src 'dawn2'\n\toption dest 'home'\n\toption dest_ip '192.168.77.1'\n\toption proto 'tcp udp'\n\toption dest_port '53'\n\toption target 'ACCEPT'\n\nconfig rule 'dawnline_portal'\n\toption name 'Dawnline-Portal'\n\toption src 'wan'\n\toption proto 'tcp'\n\toption dest_port '8443'\n\toption target 'ACCEPT'\n\nconfig rule 'dawnline_home_zone'\n\toption name 'Not a zone'\n\nconfig forwarding 'dawnline_old_wan'\n\toption src 'dawn9'\n\n",
"firewall": "\nconfig defaults\n\toption syn_flood '1'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'REJECT'\n\nconfig zone\n\toption name 'lan'\n\tlist network 'lan'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig zone\n\toption name 'wan'\n\tlist network 'wan'\n\tlist network 'wan6'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'DROP'\n\toption masq '1'\n\toption mtu_fix '1'\n\nconfig forwarding\n\toption src 'lan'\n\toption dest 'wan'\n\nconfig rule\n\toption name 'Allow-DHCP-Renew'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '68'\n\toption target 'ACCEPT'\n\toption family 'ipv4'\n\nconfig rule\n\toption name 'Allow-Ping'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption icmp_type 'echo-request'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IGMP'\n\toption src 'wan'\n\toption proto 'igmp'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-DHCPv6'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '546'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-MLD'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption src_ip 'fe80::/10'\n\tlist icmp_type '130/0'\n\tlist icmp_type '131/0'\n\tlist icmp_type '132/0'\n\tlist icmp_type '143/0'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Input'\n\toption src 'wan'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\tlist icmp_type 'router-solicitation'\n\tlist icmp_type 'neighbour-solicitation'\n\tlist icmp_type 'router-advertisement'\n\tlist icmp_type 'neighbour-advertisement'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Forward'\n\toption src 'wan'\n\toption dest '*'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IPSec-ESP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption proto 'esp'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ISAKMP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption dest_port '500'\n\toption proto 'udp'\n\toption target 'ACCEPT'\n\nconfig zone\n\toption name 'guest'\n\tlist device 'dlguest'\n\nconfig zone\n\toption name 'home'\n\toption device 'br-lan dlhome'\n\nconfig forwarding 'dawnline_home_lan'\n\toption src 'dawn0'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_home_from_lan'\n\toption src 'home'\n\toption dest 'dawn0'\n\nconfig forwarding 'dawnline_home_wan'\n\toption src 'dawn0'\n\toption dest 'wan'\n\nconfig rule 'dawnline_home_port'\n\toption name 'Dawnline-dawn0'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4502'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_open_zone'\n\toption name 'dawn2'\n\tlist network 'dawn2'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_open_lan'\n\toption src 'dawn2'\n\toption dest 'guest'\n\nconfig forwarding 'dawnline_open_from_lan'\n\toption src 'guest'\n\toption dest 'dawn2'\n\nconfig forwarding 'dawnline_open_wan'\n\toption src 'dawn2'\n\toption dest 'wan'\n\nconfig rule 'dawnline_open_port'\n\toption name 'Dawnline-dawn2'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4700'\n\toption target 'ACCEPT'\n\nconfig forwarding 'dawnline_home_lan_guest'\n\toption src 'dawn0'\n\toption dest 'guest'\n\nconfig forwarding 'dawnline_home_from_lan_guest'\n\toption src 'guest'\n\toption dest 'dawn0'\n\nconfig rule 'dawnline_open_landns'\n\toption name 'Dawnline-dawn2-dns'\n\toption src 'dawn2'\n\toption dest 'home'\n\toption dest_ip '192.168.77.1'\n\toption proto 'tcp udp'\n\toption dest_port '53'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_home_zone'\n\toption name 'dawn0'\n\tlist network 'dawn0'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\n",
"cmds": [
"ubus call network.interface dump",
"fw4 -q reload"
]
},
{
"what": "would it change: no",
"dry": true,
"changed": false,
"before": "\nconfig defaults\n\toption syn_flood '1'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'REJECT'\n\nconfig zone\n\toption name 'lan'\n\tlist network 'lan'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig zone\n\toption name 'wan'\n\tlist network 'wan'\n\tlist network 'wan6'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'DROP'\n\toption masq '1'\n\toption mtu_fix '1'\n\nconfig forwarding\n\toption src 'lan'\n\toption dest 'wan'\n\nconfig rule\n\toption name 'Allow-DHCP-Renew'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '68'\n\toption target 'ACCEPT'\n\toption family 'ipv4'\n\nconfig rule\n\toption name 'Allow-Ping'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption icmp_type 'echo-request'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IGMP'\n\toption src 'wan'\n\toption proto 'igmp'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-DHCPv6'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '546'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-MLD'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption src_ip 'fe80::/10'\n\tlist icmp_type '130/0'\n\tlist icmp_type '131/0'\n\tlist icmp_type '132/0'\n\tlist icmp_type '143/0'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Input'\n\toption src 'wan'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\tlist icmp_type 'router-solicitation'\n\tlist icmp_type 'neighbour-solicitation'\n\tlist icmp_type 'router-advertisement'\n\tlist icmp_type 'neighbour-advertisement'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Forward'\n\toption src 'wan'\n\toption dest '*'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IPSec-ESP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption proto 'esp'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ISAKMP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption dest_port '500'\n\toption proto 'udp'\n\toption target 'ACCEPT'\n\nconfig zone\n\toption name 'guest'\n\tlist device 'dlguest'\n\nconfig zone\n\toption name 'home'\n\toption device 'br-lan dlhome'\n\nconfig forwarding 'dawnline_home_lan'\n\toption src 'dawn0'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_home_from_lan'\n\toption src 'home'\n\toption dest 'dawn0'\n\nconfig forwarding 'dawnline_home_wan'\n\toption src 'dawn0'\n\toption dest 'wan'\n\nconfig rule 'dawnline_home_port'\n\toption name 'Dawnline-dawn0'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4502'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_open_zone'\n\toption name 'dawn2'\n\tlist network 'dawn2'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_open_lan'\n\toption src 'dawn2'\n\toption dest 'guest'\n\nconfig forwarding 'dawnline_open_from_lan'\n\toption src 'guest'\n\toption dest 'dawn2'\n\nconfig forwarding 'dawnline_open_wan'\n\toption src 'dawn2'\n\toption dest 'wan'\n\nconfig rule 'dawnline_open_port'\n\toption name 'Dawnline-dawn2'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4700'\n\toption target 'ACCEPT'\n\nconfig forwarding 'dawnline_home_lan_guest'\n\toption src 'dawn0'\n\toption dest 'guest'\n\nconfig forwarding 'dawnline_home_from_lan_guest'\n\toption src 'guest'\n\toption dest 'dawn0'\n\nconfig rule 'dawnline_open_landns'\n\toption name 'Dawnline-dawn2-dns'\n\toption src 'dawn2'\n\toption dest 'home'\n\toption dest_ip '192.168.77.1'\n\toption proto 'tcp udp'\n\toption dest_port '53'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_home_zone'\n\toption name 'dawn0'\n\tlist network 'dawn0'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\n",
"firewall": "\nconfig defaults\n\toption syn_flood '1'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'REJECT'\n\nconfig zone\n\toption name 'lan'\n\tlist network 'lan'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig zone\n\toption name 'wan'\n\tlist network 'wan'\n\tlist network 'wan6'\n\toption input 'REJECT'\n\toption output 'ACCEPT'\n\toption forward 'DROP'\n\toption masq '1'\n\toption mtu_fix '1'\n\nconfig forwarding\n\toption src 'lan'\n\toption dest 'wan'\n\nconfig rule\n\toption name 'Allow-DHCP-Renew'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '68'\n\toption target 'ACCEPT'\n\toption family 'ipv4'\n\nconfig rule\n\toption name 'Allow-Ping'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption icmp_type 'echo-request'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IGMP'\n\toption src 'wan'\n\toption proto 'igmp'\n\toption family 'ipv4'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-DHCPv6'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '546'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-MLD'\n\toption src 'wan'\n\toption proto 'icmp'\n\toption src_ip 'fe80::/10'\n\tlist icmp_type '130/0'\n\tlist icmp_type '131/0'\n\tlist icmp_type '132/0'\n\tlist icmp_type '143/0'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Input'\n\toption src 'wan'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\tlist icmp_type 'router-solicitation'\n\tlist icmp_type 'neighbour-solicitation'\n\tlist icmp_type 'router-advertisement'\n\tlist icmp_type 'neighbour-advertisement'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ICMPv6-Forward'\n\toption src 'wan'\n\toption dest '*'\n\toption proto 'icmp'\n\tlist icmp_type 'echo-request'\n\tlist icmp_type 'echo-reply'\n\tlist icmp_type 'destination-unreachable'\n\tlist icmp_type 'packet-too-big'\n\tlist icmp_type 'time-exceeded'\n\tlist icmp_type 'bad-header'\n\tlist icmp_type 'unknown-header-type'\n\toption limit '1000/sec'\n\toption family 'ipv6'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-IPSec-ESP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption proto 'esp'\n\toption target 'ACCEPT'\n\nconfig rule\n\toption name 'Allow-ISAKMP'\n\toption src 'wan'\n\toption dest 'lan'\n\toption dest_port '500'\n\toption proto 'udp'\n\toption target 'ACCEPT'\n\nconfig zone\n\toption name 'guest'\n\tlist device 'dlguest'\n\nconfig zone\n\toption name 'home'\n\toption device 'br-lan dlhome'\n\nconfig forwarding 'dawnline_home_lan'\n\toption src 'dawn0'\n\toption dest 'home'\n\nconfig forwarding 'dawnline_home_from_lan'\n\toption src 'home'\n\toption dest 'dawn0'\n\nconfig forwarding 'dawnline_home_wan'\n\toption src 'dawn0'\n\toption dest 'wan'\n\nconfig rule 'dawnline_home_port'\n\toption name 'Dawnline-dawn0'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4502'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_open_zone'\n\toption name 'dawn2'\n\tlist network 'dawn2'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\nconfig forwarding 'dawnline_open_lan'\n\toption src 'dawn2'\n\toption dest 'guest'\n\nconfig forwarding 'dawnline_open_from_lan'\n\toption src 'guest'\n\toption dest 'dawn2'\n\nconfig forwarding 'dawnline_open_wan'\n\toption src 'dawn2'\n\toption dest 'wan'\n\nconfig rule 'dawnline_open_port'\n\toption name 'Dawnline-dawn2'\n\toption src 'wan'\n\toption proto 'udp'\n\toption dest_port '4700'\n\toption target 'ACCEPT'\n\nconfig forwarding 'dawnline_home_lan_guest'\n\toption src 'dawn0'\n\toption dest 'guest'\n\nconfig forwarding 'dawnline_home_from_lan_guest'\n\toption src 'guest'\n\toption dest 'dawn0'\n\nconfig rule 'dawnline_open_landns'\n\toption name 'Dawnline-dawn2-dns'\n\toption src 'dawn2'\n\toption dest 'home'\n\toption dest_ip '192.168.77.1'\n\toption proto 'tcp udp'\n\toption dest_port '53'\n\toption target 'ACCEPT'\n\nconfig zone 'dawnline_home_zone'\n\toption name 'dawn0'\n\tlist network 'dawn0'\n\toption input 'ACCEPT'\n\toption output 'ACCEPT'\n\toption forward 'ACCEPT'\n\n",
"cmds": [
"ubus call network.interface dump"
]
}
]
}
+1537
View File
File diff suppressed because it is too large. Load diff
+307
View File
@@ -0,0 +1,307 @@
{
"steps": [
{
"what": "the first time: two tunnels made, a third whose name is taken",
"changed": true,
"network": "\nconfig interface 'loopback'\n\toption device 'lo'\n\toption proto 'static'\n\tlist ipaddr '127.0.0.1/8'\n\nconfig globals 'globals'\n\toption ula_prefix 'fd00:1234::/48'\n\nconfig device\n\toption name 'br-lan'\n\toption type 'bridge'\n\tlist ports 'lan1'\n\tlist ports 'lan2'\n\nconfig interface 'lan'\n\toption device 'br-lan'\n\toption proto 'static'\n\toption ipaddr '192.168.77.1/24'\n\toption note 'it'\\''s the LAN'\n\nconfig interface 'dawn2'\n\toption proto 'wireguard'\n\toption private_key 'someone else'\\''s'\n\nconfig interface 'dawn0'\n\toption proto 'amneziawg'\n\toption private_key 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA='\n\toption listen_port '4500'\n\tlist addresses '10.77.0.1/24'\n\toption mtu '1380'\n\toption _dawnline 'home'\n\toption _dawnline_name 'Home'\n\nconfig interface 'dawn1'\n\toption proto 'amneziawg'\n\toption private_key 'ccccccccccccccccccccccccccccccccccccccccccA='\n\toption listen_port '4600'\n\tlist addresses '10.78.0.1/24'\n\toption mtu '1380'\n\toption _dawnline 'cabin'\n\toption _dawnline_name 'Cabin'\n\n",
"blocked": {
"open": {
"code": "taken",
"ifname": "dawn2"
}
},
"model_blocked": {
"home": null,
"cabin": null,
"open": {
"code": "taken",
"ifname": "dawn2"
}
},
"cmds": [
"ubus call network reload",
"ifup dawn0",
"ifup dawn1"
],
"intents": {
"dawn0": {
"reason": "settings",
"name": "Home"
},
"dawn1": {
"reason": "settings",
"name": "Cabin"
}
},
"no_awg": false
},
{
"what": "again: nothing to do",
"changed": false,
"network": "\nconfig interface 'loopback'\n\toption device 'lo'\n\toption proto 'static'\n\tlist ipaddr '127.0.0.1/8'\n\nconfig globals 'globals'\n\toption ula_prefix 'fd00:1234::/48'\n\nconfig device\n\toption name 'br-lan'\n\toption type 'bridge'\n\tlist ports 'lan1'\n\tlist ports 'lan2'\n\nconfig interface 'lan'\n\toption device 'br-lan'\n\toption proto 'static'\n\toption ipaddr '192.168.77.1/24'\n\toption note 'it'\\''s the LAN'\n\nconfig interface 'dawn2'\n\toption proto 'wireguard'\n\toption private_key 'someone else'\\''s'\n\nconfig interface 'dawn0'\n\toption proto 'amneziawg'\n\toption private_key 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA='\n\toption listen_port '4500'\n\tlist addresses '10.77.0.1/24'\n\toption mtu '1380'\n\toption _dawnline 'home'\n\toption _dawnline_name 'Home'\n\nconfig interface 'dawn1'\n\toption proto 'amneziawg'\n\toption private_key 'ccccccccccccccccccccccccccccccccccccccccccA='\n\toption listen_port '4600'\n\tlist addresses '10.78.0.1/24'\n\toption mtu '1380'\n\toption _dawnline 'cabin'\n\toption _dawnline_name 'Cabin'\n\n",
"blocked": {
"open": {
"code": "taken",
"ifname": "dawn2"
}
},
"model_blocked": {
"home": null,
"cabin": null,
"open": {
"code": "taken",
"ifname": "dawn2"
}
},
"cmds": [
],
"intents": {
"dawn0": {
"reason": "settings",
"name": "Home"
},
"dawn1": {
"reason": "settings",
"name": "Cabin"
}
},
"no_awg": false
},
{
"what": "a port changed, a server turned off",
"changed": true,
"network": "\nconfig interface 'loopback'\n\toption device 'lo'\n\toption proto 'static'\n\tlist ipaddr '127.0.0.1/8'\n\nconfig globals 'globals'\n\toption ula_prefix 'fd00:1234::/48'\n\nconfig device\n\toption name 'br-lan'\n\toption type 'bridge'\n\tlist ports 'lan1'\n\tlist ports 'lan2'\n\nconfig interface 'lan'\n\toption device 'br-lan'\n\toption proto 'static'\n\toption ipaddr '192.168.77.1/24'\n\toption note 'it'\\''s the LAN'\n\nconfig interface 'dawn2'\n\toption proto 'wireguard'\n\toption private_key 'someone else'\\''s'\n\nconfig interface 'dawn0'\n\toption proto 'amneziawg'\n\toption private_key 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA='\n\toption listen_port '4501'\n\tlist addresses '10.77.0.1/24'\n\toption mtu '1380'\n\toption _dawnline 'home'\n\toption _dawnline_name 'Home'\n\nconfig interface 'dawn1'\n\toption proto 'amneziawg'\n\toption private_key 'ccccccccccccccccccccccccccccccccccccccccccA='\n\toption listen_port '4600'\n\tlist addresses '10.78.0.1/24'\n\toption mtu '1380'\n\toption _dawnline 'cabin'\n\toption _dawnline_name 'Cabin'\n\toption disabled '1'\n\toption auto '0'\n\n",
"blocked": {
"open": {
"code": "taken",
"ifname": "dawn2"
}
},
"model_blocked": {
"home": null,
"cabin": null,
"open": {
"code": "taken",
"ifname": "dawn2"
}
},
"cmds": [
"ubus call network reload",
"ifup dawn0"
],
"intents": {
"dawn0": {
"reason": "settings",
"name": "Home"
},
"dawn1": {
"reason": "off",
"name": "Cabin"
}
},
"no_awg": false
},
{
"what": "a disguise AmneziaWG cannot take: the tunnel goes",
"changed": true,
"network": "\nconfig interface 'loopback'\n\toption device 'lo'\n\toption proto 'static'\n\tlist ipaddr '127.0.0.1/8'\n\nconfig globals 'globals'\n\toption ula_prefix 'fd00:1234::/48'\n\nconfig device\n\toption name 'br-lan'\n\toption type 'bridge'\n\tlist ports 'lan1'\n\tlist ports 'lan2'\n\nconfig interface 'lan'\n\toption device 'br-lan'\n\toption proto 'static'\n\toption ipaddr '192.168.77.1/24'\n\toption note 'it'\\''s the LAN'\n\nconfig interface 'dawn2'\n\toption proto 'wireguard'\n\toption private_key 'someone else'\\''s'\n\nconfig interface 'dawn1'\n\toption proto 'amneziawg'\n\toption private_key 'ccccccccccccccccccccccccccccccccccccccccccA='\n\toption listen_port '4600'\n\tlist addresses '10.78.0.1/24'\n\toption mtu '1380'\n\toption _dawnline 'cabin'\n\toption _dawnline_name 'Cabin'\n\toption disabled '1'\n\toption auto '0'\n\n",
"blocked": {
"home": {
"code": "disguise_invalid"
},
"open": {
"code": "taken",
"ifname": "dawn2"
}
},
"model_blocked": {
"home": {
"code": "disguise_invalid"
},
"cabin": null,
"open": {
"code": "taken",
"ifname": "dawn2"
}
},
"cmds": [
"ifdown dawn0",
"ubus call network reload"
],
"intents": {
"dawn0": {
"reason": "removed",
"name": "Home"
},
"dawn1": {
"reason": "off",
"name": "Cabin"
}
},
"no_awg": false
},
{
"what": "put right, and the server renamed",
"changed": true,
"network": "\nconfig interface 'loopback'\n\toption device 'lo'\n\toption proto 'static'\n\tlist ipaddr '127.0.0.1/8'\n\nconfig globals 'globals'\n\toption ula_prefix 'fd00:1234::/48'\n\nconfig device\n\toption name 'br-lan'\n\toption type 'bridge'\n\tlist ports 'lan1'\n\tlist ports 'lan2'\n\nconfig interface 'lan'\n\toption device 'br-lan'\n\toption proto 'static'\n\toption ipaddr '192.168.77.1/24'\n\toption note 'it'\\''s the LAN'\n\nconfig interface 'dawn2'\n\toption proto 'wireguard'\n\toption private_key 'someone else'\\''s'\n\nconfig interface 'dawn1'\n\toption proto 'amneziawg'\n\toption private_key 'ccccccccccccccccccccccccccccccccccccccccccA='\n\toption listen_port '4600'\n\tlist addresses '10.78.0.1/24'\n\toption mtu '1380'\n\toption _dawnline 'cabin'\n\toption _dawnline_name 'Cabin'\n\toption disabled '1'\n\toption auto '0'\n\nconfig interface 'dawn0'\n\toption proto 'amneziawg'\n\toption private_key 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA='\n\toption listen_port '4501'\n\tlist addresses '10.77.0.1/24'\n\toption mtu '1380'\n\toption _dawnline 'home'\n\toption _dawnline_name 'Anna'\\''s house'\n\n",
"blocked": {
"open": {
"code": "taken",
"ifname": "dawn2"
}
},
"model_blocked": {
"home": null,
"cabin": null,
"open": {
"code": "taken",
"ifname": "dawn2"
}
},
"cmds": [
"ubus call network reload",
"ifup dawn0"
],
"intents": {
"dawn0": {
"reason": "settings",
"name": "Anna's house"
},
"dawn1": {
"reason": "off",
"name": "Cabin"
}
},
"no_awg": false
},
{
"what": "renamed again: only the marker moves",
"changed": true,
"network": "\nconfig interface 'loopback'\n\toption device 'lo'\n\toption proto 'static'\n\tlist ipaddr '127.0.0.1/8'\n\nconfig globals 'globals'\n\toption ula_prefix 'fd00:1234::/48'\n\nconfig device\n\toption name 'br-lan'\n\toption type 'bridge'\n\tlist ports 'lan1'\n\tlist ports 'lan2'\n\nconfig interface 'lan'\n\toption device 'br-lan'\n\toption proto 'static'\n\toption ipaddr '192.168.77.1/24'\n\toption note 'it'\\''s the LAN'\n\nconfig interface 'dawn2'\n\toption proto 'wireguard'\n\toption private_key 'someone else'\\''s'\n\nconfig interface 'dawn1'\n\toption proto 'amneziawg'\n\toption private_key 'ccccccccccccccccccccccccccccccccccccccccccA='\n\toption listen_port '4600'\n\tlist addresses '10.78.0.1/24'\n\toption mtu '1380'\n\toption _dawnline 'cabin'\n\toption _dawnline_name 'Cabin'\n\toption disabled '1'\n\toption auto '0'\n\nconfig interface 'dawn0'\n\toption proto 'amneziawg'\n\toption private_key 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA='\n\toption listen_port '4501'\n\tlist addresses '10.77.0.1/24'\n\toption mtu '1380'\n\toption _dawnline 'home'\n\toption _dawnline_name 'House'\n\n",
"blocked": {
"open": {
"code": "taken",
"ifname": "dawn2"
}
},
"model_blocked": {
"home": null,
"cabin": null,
"open": {
"code": "taken",
"ifname": "dawn2"
}
},
"cmds": [
],
"intents": {
"dawn0": {
"reason": "settings",
"name": "Anna's house"
},
"dawn1": {
"reason": "off",
"name": "Cabin"
}
},
"no_awg": false
},
{
"what": "a server removed, another given a name that will not do",
"changed": true,
"network": "\nconfig interface 'loopback'\n\toption device 'lo'\n\toption proto 'static'\n\tlist ipaddr '127.0.0.1/8'\n\nconfig globals 'globals'\n\toption ula_prefix 'fd00:1234::/48'\n\nconfig device\n\toption name 'br-lan'\n\toption type 'bridge'\n\tlist ports 'lan1'\n\tlist ports 'lan2'\n\nconfig interface 'lan'\n\toption device 'br-lan'\n\toption proto 'static'\n\toption ipaddr '192.168.77.1/24'\n\toption note 'it'\\''s the LAN'\n\nconfig interface 'dawn2'\n\toption proto 'wireguard'\n\toption private_key 'someone else'\\''s'\n\nconfig interface 'dawn0'\n\toption proto 'amneziawg'\n\toption private_key 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA='\n\toption listen_port '4501'\n\tlist addresses '10.77.0.1/24'\n\toption mtu '1380'\n\toption _dawnline 'home'\n\toption _dawnline_name 'House'\n\n",
"blocked": {
"open": {
"code": "ifname",
"ifname": "Not-A-Name"
}
},
"model_blocked": {
"home": null,
"open": {
"code": "ifname",
"ifname": "Not-A-Name"
}
},
"cmds": [
"ifdown dawn1",
"ubus call network reload"
],
"intents": {
"dawn0": {
"reason": "settings",
"name": "Anna's house"
},
"dawn1": {
"reason": "removed",
"name": "Cabin"
}
},
"no_awg": false
},
{
"what": "a 3.1 disguise, and a list of DNS-shaped packets",
"changed": true,
"network": "\nconfig interface 'loopback'\n\toption device 'lo'\n\toption proto 'static'\n\tlist ipaddr '127.0.0.1/8'\n\nconfig globals 'globals'\n\toption ula_prefix 'fd00:1234::/48'\n\nconfig device\n\toption name 'br-lan'\n\toption type 'bridge'\n\tlist ports 'lan1'\n\tlist ports 'lan2'\n\nconfig interface 'lan'\n\toption device 'br-lan'\n\toption proto 'static'\n\toption ipaddr '192.168.77.1/24'\n\toption note 'it'\\''s the LAN'\n\nconfig interface 'dawn2'\n\toption proto 'wireguard'\n\toption private_key 'someone else'\\''s'\n\nconfig interface 'dawn0'\n\toption proto 'amneziawg'\n\toption private_key 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA='\n\toption listen_port '4501'\n\tlist addresses '10.77.0.1/24'\n\toption mtu '1368'\n\toption _dawnline 'home'\n\toption _dawnline_name 'House'\n\toption awg_s1 '12'\n\toption awg_s2 '12'\n\toption awg_s3 '12'\n\toption awg_s4 '12'\n\toption awg_i1 '<b 0x01><r 2>'\n\toption awg_header_protection_key 'yAnz5TF+lXXJte14tji3zlMNq+hd2rYUIgJBgB3fBmk='\n\n",
"blocked": {
"open": {
"code": "ifname",
"ifname": "Not-A-Name"
}
},
"model_blocked": {
"home": null,
"open": {
"code": "ifname",
"ifname": "Not-A-Name"
}
},
"cmds": [
"ubus call network reload",
"ifup dawn0"
],
"intents": {
"dawn0": {
"reason": "settings",
"name": "House"
},
"dawn1": {
"reason": "removed",
"name": "Cabin"
}
},
"no_awg": false
},
{
"what": "the tools are gone: nothing is touched",
"changed": false,
"network": "\nconfig interface 'loopback'\n\toption device 'lo'\n\toption proto 'static'\n\tlist ipaddr '127.0.0.1/8'\n\nconfig globals 'globals'\n\toption ula_prefix 'fd00:1234::/48'\n\nconfig device\n\toption name 'br-lan'\n\toption type 'bridge'\n\tlist ports 'lan1'\n\tlist ports 'lan2'\n\nconfig interface 'lan'\n\toption device 'br-lan'\n\toption proto 'static'\n\toption ipaddr '192.168.77.1/24'\n\toption note 'it'\\''s the LAN'\n\nconfig interface 'dawn2'\n\toption proto 'wireguard'\n\toption private_key 'someone else'\\''s'\n\nconfig interface 'dawn0'\n\toption proto 'amneziawg'\n\toption private_key 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA='\n\toption listen_port '4501'\n\tlist addresses '10.77.0.1/24'\n\toption mtu '1368'\n\toption _dawnline 'home'\n\toption _dawnline_name 'House'\n\toption awg_s1 '12'\n\toption awg_s2 '12'\n\toption awg_s3 '12'\n\toption awg_s4 '12'\n\toption awg_i1 '<b 0x01><r 2>'\n\toption awg_header_protection_key 'yAnz5TF+lXXJte14tji3zlMNq+hd2rYUIgJBgB3fBmk='\n\n",
"blocked": {
"open": {
"code": "ifname",
"ifname": "Not-A-Name"
}
},
"model_blocked": {
"home": null,
"open": {
"code": "ifname",
"ifname": "Not-A-Name"
}
},
"cmds": [
],
"intents": {
"dawn0": {
"reason": "settings",
"name": "House"
},
"dawn1": {
"reason": "removed",
"name": "Cabin"
}
},
"no_awg": true
}
]
}
+25
View File
@@ -0,0 +1,25 @@
config interface 'loopback'
option device 'lo'
option proto 'static'
list ipaddr '127.0.0.1/8'
config globals 'globals'
option ula_prefix 'fd00:1234::/48'
config device
option name 'br-lan'
option type 'bridge'
list ports 'lan1'
list ports 'lan2'
config interface 'lan'
option device 'br-lan'
option proto 'static'
option ipaddr '192.168.77.1/24'
option note 'it'\''s the LAN'
config interface 'dawn2'
option proto 'wireguard'
option private_key 'someone else'\''s'
+107
View File
@@ -0,0 +1,107 @@
{
"dhcp": "config dnsmasq\n\toption domainneeded\t1\n\toption boguspriv\t1\n\toption filterwin2k\t0 # enable for dial on demand\n\toption localise_queries\t1\n\toption rebind_protection 1 # disable if upstream must serve RFC1918 addresses\n\toption rebind_localhost 1 # enable for RBL checking and similar services\n\t#list rebind_domain example.lan # whitelist RFC1918 responses for domains\n\toption local\t'/lan/'\n\toption domain\t'lan'\n\toption expandhosts\t1\n\toption nonegcache\t0\n\toption cachesize\t1000\n\toption authoritative\t1\n\toption readethers\t1\n\toption leasefile\t'/tmp/dhcp.leases'\n\toption resolvfile\t'/tmp/resolv.conf.d/resolv.conf.auto'\n\t#list server\t\t'/mycompany.local/1.2.3.4'\n\toption nonwildcard\t1 # bind to & keep track of interfaces\n\t#list interface\t\tbr-lan\n\t#list notinterface\tlo\n\t#list bogusnxdomain '64.94.110.11'\n\toption localservice\t1 # disable to allow DNS requests from non-local subnets\n\toption ednspacket_max\t1232\n\toption filter_aaaa\t0\n\toption filter_a\t\t0\n\t#list addnmount\t\t/some/path # read-only mount path to expose it to dnsmasq\n\nconfig dhcp lan\n\toption interface\tlan\n\toption start \t100\n\toption limit\t150\n\toption leasetime\t12h\n\nconfig dhcp wan\n\toption interface\twan\n\toption ignore\t1\n",
"steps": [
{
"what": "on the tunnels, home names from the LAN",
"target": {
"mode": "root",
"port": 5354
},
"lan": "192.168.77.1",
"changed": true,
"conf": "# mode=root\n# Generated by Dawnline: plain DNS for Home-only tunnel clients.\nport=5354\nno-hosts\nbogus-priv\ncache-size=1000\npid-file=/var/run/dawnline-dns.pid\nuser=dnsmasq\ngroup=dnsmasq\nbind-dynamic\ninterface=dawn0\ninterface=dawn1\ninterface=dawn2\nresolv-file=/var/etc/dawnline-dns.resolv\nserver=/lan/192.168.77.1\n",
"resolv": "nameserver 9.9.9.9\nnameserver 149.112.112.112\n",
"cmds": [
"ubus call network.interface.wan status",
"ubus call network.interface.wan6 status",
"ubus call network.interface.wan status",
"ubus call network.interface.wan6 status"
]
},
{
"what": "again: nothing to do",
"target": {
"mode": "root",
"port": 5354
},
"lan": "192.168.77.1",
"changed": false,
"conf": "# mode=root\n# Generated by Dawnline: plain DNS for Home-only tunnel clients.\nport=5354\nno-hosts\nbogus-priv\ncache-size=1000\npid-file=/var/run/dawnline-dns.pid\nuser=dnsmasq\ngroup=dnsmasq\nbind-dynamic\ninterface=dawn0\ninterface=dawn1\ninterface=dawn2\nresolv-file=/var/etc/dawnline-dns.resolv\nserver=/lan/192.168.77.1\n",
"resolv": "nameserver 9.9.9.9\nnameserver 149.112.112.112\n",
"cmds": [
"ubus call network.interface.wan status",
"ubus call network.interface.wan6 status"
]
},
{
"what": "inside the netns",
"target": {
"mode": "ns",
"address": "100.127.0.2",
"port": 53
},
"lan": "192.168.77.53",
"changed": true,
"conf": "# mode=ns\n# Generated by Dawnline: plain DNS for Home-only tunnel clients.\nport=53\nno-hosts\nbogus-priv\ncache-size=1000\npid-file=/var/run/dawnline-dns.pid\nuser=dnsmasq\ngroup=dnsmasq\nlisten-address=100.127.0.2\nbind-interfaces\nno-resolv\nserver=9.9.9.9@100.127.0.2\nserver=149.112.112.112@100.127.0.2\nserver=/lan/192.168.77.53\n",
"resolv": "nameserver 9.9.9.9\nnameserver 149.112.112.112\n",
"cmds": [
"ubus call network.interface.wan status",
"ubus call network.interface.wan6 status",
"ubus call network.interface.wan status",
"ubus call network.interface.wan6 status"
]
},
{
"what": "back on the tunnels with one of them off, no DNS on the LAN, a running one to stop",
"target": {
"mode": "root",
"port": 5354
},
"lan": null,
"changed": true,
"conf": "# mode=root\n# Generated by Dawnline: plain DNS for Home-only tunnel clients.\nport=5354\nno-hosts\nbogus-priv\ncache-size=1000\npid-file=/var/run/dawnline-dns.pid\nuser=dnsmasq\ngroup=dnsmasq\nbind-dynamic\ninterface=dawn0\ninterface=dawn2\nresolv-file=/var/etc/dawnline-dns.resolv\n",
"resolv": "nameserver 9.9.9.9\nnameserver 149.112.112.112\n",
"cmds": [
"ubus call network.interface.wan status",
"ubus call network.interface.wan6 status",
"ubus call network.interface.wan status",
"ubus call network.interface.wan6 status"
]
},
{
"what": "no tunnel on: loopback only",
"target": {
"mode": "root",
"port": 5354
},
"lan": "192.168.77.1",
"changed": true,
"conf": "# mode=root\n# Generated by Dawnline: plain DNS for Home-only tunnel clients.\nport=5354\nno-hosts\nbogus-priv\ncache-size=1000\npid-file=/var/run/dawnline-dns.pid\nuser=dnsmasq\ngroup=dnsmasq\nbind-dynamic\nlisten-address=127.0.0.1\nresolv-file=/var/etc/dawnline-dns.resolv\nserver=/lan/192.168.77.1\n",
"resolv": "nameserver 9.9.9.9\nnameserver 149.112.112.112\n",
"cmds": [
"ubus call network.interface.wan status",
"ubus call network.interface.wan6 status",
"ubus call network.interface.wan status",
"ubus call network.interface.wan6 status"
]
},
{
"what": "the WAN says nothing of DNS: two public ones",
"target": {
"mode": "ns",
"address": "100.127.0.2",
"port": 53
},
"lan": "192.168.77.1",
"changed": true,
"conf": "# mode=ns\n# Generated by Dawnline: plain DNS for Home-only tunnel clients.\nport=53\nno-hosts\nbogus-priv\ncache-size=1000\npid-file=/var/run/dawnline-dns.pid\nuser=dnsmasq\ngroup=dnsmasq\nlisten-address=100.127.0.2\nbind-interfaces\nno-resolv\nserver=1.1.1.1@100.127.0.2\nserver=8.8.8.8@100.127.0.2\nserver=/lan/192.168.77.1\n",
"resolv": "nameserver 9.9.9.9\nnameserver 149.112.112.112\n",
"cmds": [
"ubus call network.interface.wan status",
"ubus call network.interface.wan6 status",
"ubus call network.interface.wan status",
"ubus call network.interface.wan6 status"
]
}
]
}
+7
View File
@@ -0,0 +1,7 @@
{
"sigs": [
"{ \"wan\": \"eth0\", \"lan\": \"br-lan\", \"addrs\": [ \"192.168.77.1/24\" ], \"servers\": { \"home\": { \"wan\": { \"dev\": \"eth0\", \"auto\": true, \"zone\": \"wan\", \"missing\": false }, \"home\": [ { \"dev\": \"dlhome\", \"auto\": false, \"nets\": [ \"192.168.50.0/24\" ], \"zone\": \"home\", \"missing\": false }, { \"dev\": \"br-lan\", \"auto\": false, \"nets\": [ \"192.168.77.0/24\" ], \"zone\": \"home\", \"missing\": false } ], \"nets\": [ \"192.168.50.0/24\", \"192.168.77.0/24\" ], \"zones\": [ \"home\" ] }, \"cabin\": { \"wan\": { \"dev\": \"eth0\", \"auto\": true, \"zone\": \"wan\", \"missing\": false }, \"home\": [ { \"dev\": \"dlhome\", \"auto\": false, \"nets\": [ \"192.168.50.0/24\" ], \"zone\": \"home\", \"missing\": false } ], \"nets\": [ \"192.168.50.0/24\" ], \"zones\": [ \"home\" ] }, \"open\": { \"wan\": { \"dev\": \"eth0\", \"auto\": true, \"zone\": \"wan\", \"missing\": false }, \"home\": [ { \"dev\": \"br-lan\", \"auto\": false, \"nets\": [ \"192.168.77.0/24\" ], \"zone\": \"home\", \"missing\": false } ], \"nets\": [ \"192.168.77.0/24\" ], \"zones\": [ \"home\" ] } }, \"dns\": \"192.168.77.1\", \"loop\": null }",
"{ \"wan\": \"eth0\", \"lan\": \"br-lan\", \"addrs\": [ \"192.168.77.1/24\" ], \"servers\": { \"home\": { \"wan\": { \"dev\": \"eth0\", \"auto\": true, \"zone\": \"wan\", \"missing\": false }, \"home\": [ { \"dev\": \"dlhome\", \"auto\": false, \"nets\": [ \"192.168.50.0/24\" ], \"zone\": \"home\", \"missing\": false }, { \"dev\": \"nope0\", \"auto\": false, \"nets\": [ ], \"zone\": null, \"missing\": true } ], \"nets\": [ \"192.168.50.0/24\" ], \"zones\": [ \"home\" ] }, \"cabin\": { \"wan\": { \"dev\": \"eth0\", \"auto\": true, \"zone\": \"wan\", \"missing\": false }, \"home\": [ { \"dev\": \"br-lan\", \"auto\": true, \"nets\": [ \"192.168.77.0/24\" ], \"zone\": \"home\", \"missing\": false }, { \"dev\": \"dlhome\", \"auto\": false, \"nets\": [ \"192.168.50.0/24\" ], \"zone\": \"home\", \"missing\": false } ], \"nets\": [ \"192.168.50.0/24\", \"192.168.77.0/24\" ], \"zones\": [ \"home\" ] }, \"open\": { \"wan\": { \"dev\": \"wg9\", \"auto\": false, \"zone\": \"wan\", \"missing\": false }, \"home\": [ { \"dev\": \"br-lan\", \"auto\": false, \"nets\": [ \"192.168.77.0/24\" ], \"zone\": \"home\", \"missing\": false } ], \"nets\": [ \"192.168.77.0/24\" ], \"zones\": [ \"home\" ] } }, \"dns\": \"192.168.77.1\", \"loop\": null }",
"{ \"wan\": \"eth0\", \"lan\": \"br-lan\", \"addrs\": [ \"192.168.77.1/24\" ], \"servers\": { \"home\": { \"wan\": { \"dev\": \"eth0\", \"auto\": true, \"zone\": \"wan\", \"missing\": false }, \"home\": [ { \"dev\": \"dlhome\", \"auto\": false, \"nets\": [ \"192.168.50.0/24\" ], \"zone\": \"home\", \"missing\": false }, { \"dev\": \"nope0\", \"auto\": false, \"nets\": [ ], \"zone\": null, \"missing\": true } ], \"nets\": [ \"192.168.50.0/24\" ], \"zones\": [ \"home\" ] }, \"cabin\": { \"wan\": { \"dev\": \"eth0\", \"auto\": true, \"zone\": \"wan\", \"missing\": false }, \"home\": [ { \"dev\": \"br-lan\", \"auto\": true, \"nets\": [ \"192.168.77.0/24\" ], \"zone\": \"home\", \"missing\": false }, { \"dev\": \"dlhome\", \"auto\": false, \"nets\": [ \"192.168.50.0/24\" ], \"zone\": \"home\", \"missing\": false } ], \"nets\": [ \"192.168.50.0/24\", \"192.168.77.0/24\" ], \"zones\": [ \"home\" ] }, \"open\": { \"wan\": { \"dev\": \"gone7\", \"auto\": false, \"zone\": \"wan\", \"missing\": true }, \"home\": [ { \"dev\": \"gone8\", \"auto\": false, \"nets\": [ ], \"zone\": null, \"missing\": true } ], \"nets\": [ ], \"zones\": [ ] } }, \"dns\": \"192.168.77.1\", \"loop\": null }"
]
}
+328
View File
@@ -0,0 +1,328 @@
{
"steps": [
{
"what": "no table yet: the update fails, the table is built",
"peers": {
"home": "ok",
"cabin": "ok",
"open": "ok"
},
"table": null,
"warning": null,
"states": {
"anna": "active",
"boris": "active",
"clara": "active",
"dima": "active",
"eva": "active",
"fedor": "active",
"gleb": "paused",
"hana": "active",
"ivan": "active",
"kira": "active",
"lev": "active",
"nora": "active"
},
"scripts": [
"table inet dawnline\ndelete table inet dawnline\ntable inet dawnline {\n\tset home_home { type ipv4_addr; flags interval; elements = { 192.168.50.0/24, 192.168.77.0/24 } }\n\tset home_cabin { type ipv4_addr; flags interval; elements = { 192.168.50.0/24 } }\n\tset home_open { type ipv4_addr; flags interval; elements = { 192.168.77.0/24 } }\n\tset tun_nets { type ipv4_addr; flags interval; elements = { 10.77.0.0/24, 10.78.0.0/24, 10.79.0.0/24 } }\n\tset lan_ok { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.7, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3, 10.77.0.11 } }\n\tset lan_all { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3 } }\n\tset lan_part { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.7 . 192.168.50.0/24, 10.77.0.11 . 192.168.77.0/24 } }\n\tset mesh_pairs { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.2 . 10.77.0.3, 10.77.0.2 . 10.77.0.5, 10.77.0.2 . 10.77.0.11, 10.77.0.3 . 10.77.0.2, 10.77.0.3 . 10.77.0.5, 10.77.0.3 . 10.77.0.11, 10.77.0.5 . 10.77.0.2, 10.77.0.5 . 10.77.0.3, 10.77.0.5 . 10.77.0.11, 10.77.0.11 . 10.77.0.2, 10.77.0.11 . 10.77.0.3, 10.77.0.11 . 10.77.0.5 } }\n\tset inet_ok { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.6, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3, 10.77.0.11 } }\n\tset svc_ok { type ipv4_addr . ipv4_addr . inet_service; flags interval; }\n\tset svc_host { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.8 . 192.168.77.5, 10.77.0.8 . 192.168.50.30 } }\n\tset dns_real { type ipv4_addr; flags interval; }\n\tchain pre {\n\t\ttype filter hook prerouting priority -160; policy accept;\n\t\tiifname { \"dawn0\", \"dawn1\", \"dawn2\" } jump guard\n\t}\n\tchain guard {\n\t\tmeta nfproto ipv6 drop\n\t\tct state related accept\n\t\tct status dnat accept\n\t\ticmp type { echo-request, echo-reply } fib daddr type local accept\n\t\tfib daddr type local meta l4proto { tcp, udp } th dport 53 accept\n\t\tfib daddr type local tcp dport { 4500, 4501 } accept\n\t\tfib daddr type local ip saddr @lan_all accept\n\t\tfib daddr type local ip saddr . ip daddr @lan_part accept\n\t\tfib daddr type local counter drop\n\t\tiifname \"dawn0\" ip daddr @home_home ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tiifname \"dawn1\" ip daddr @home_cabin ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tiifname \"dawn2\" ip daddr @home_open ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tip saddr . ip daddr @lan_part ip daddr != @tun_nets accept\n\t\tiifname \"dawn0\" ip saddr . ip daddr @mesh_pairs accept\n\t\tiifname \"dawn2\" ip saddr @lan_ok ip daddr @lan_ok accept\n\t\tmeta l4proto { tcp, udp } ip saddr . ip daddr . th dport @svc_ok accept\n\t\tip saddr . ip daddr @svc_host accept\n\t\tip daddr { 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 100.64.0.0/10, 169.254.0.0/16, 224.0.0.0/3 } counter drop\n\t\tip saddr @inet_ok accept\n\t\tcounter drop\n\t}\n\tchain inbound {\n\t\ttype filter hook forward priority filter - 5; policy accept;\n\t\toifname { \"dawn0\", \"dawn1\", \"dawn2\" } iifname != { \"dawn0\", \"dawn1\", \"dawn2\" } ct state new jump to_device\n\t}\n\tchain to_device {\n\t\tmeta nfproto ipv6 drop\n\t\tct status dnat accept\n\t\toifname \"dawn0\" ip saddr @home_home ip saddr != @tun_nets ip daddr @lan_all accept\n\t\toifname \"dawn1\" ip saddr @home_cabin ip saddr != @tun_nets ip daddr @lan_all accept\n\t\toifname \"dawn2\" ip saddr @home_open ip saddr != @tun_nets ip daddr @lan_all accept\n\t\tip daddr . ip saddr @lan_part ip saddr != @tun_nets accept\n\t\tcounter reject with icmpx admin-prohibited\n\t}\n\tchain dns {\n\t\ttype nat hook prerouting priority dstnat - 5; policy accept;\n\t\tiifname { \"dawn0\", \"dawn1\", \"dawn2\" } ip saddr @dns_real meta l4proto { tcp, udp } th dport 53 redirect to :5354\n\t}\n\tchain dns_lan {\n\t\ttype nat hook prerouting priority dstnat + 5; policy accept;\n\t\tiifname \"dawn0\" ip daddr 10.77.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t\tiifname \"dawn1\" ip daddr 10.78.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t\tiifname \"dawn2\" ip daddr 10.79.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t}\n}\n"
],
"confs": {
"dawn0": "[Interface]\nPrivateKey = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA=\nListenPort = 4500\n\n[Peer]\nPublicKey = BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBA=\nAllowedIPs = 10.77.0.2/32\n\n[Peer]\nPublicKey = CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCA=\nAllowedIPs = 10.77.0.3/32\n\n[Peer]\nPublicKey = EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEA=\nAllowedIPs = 10.77.0.5/32\n\n[Peer]\nPublicKey = FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA=\nAllowedIPs = 10.77.0.6/32\n\n[Peer]\nPublicKey = GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGA=\nAllowedIPs = 10.77.0.7/32\n\n[Peer]\nPublicKey = HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHA=\nAllowedIPs = 10.77.0.8/32\n\n[Peer]\nPublicKey = IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIA=\nAllowedIPs = 10.77.0.9/32\n\n[Peer]\nPublicKey = OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOA=\nAllowedIPs = 10.77.0.11/32\n",
"dawn1": "[Interface]\nPrivateKey = ccccccccccccccccccccccccccccccccccccccccccA=\nListenPort = 4600\n\n[Peer]\nPublicKey = KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKA=\nAllowedIPs = 10.78.0.2/32\n\n[Peer]\nPublicKey = LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLA=\nAllowedIPs = 10.78.0.3/32\n",
"dawn2": "[Interface]\nPrivateKey = eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeA=\nListenPort = 4700\n\n[Peer]\nPublicKey = MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMA=\nAllowedIPs = 10.79.0.2/32\n\n[Peer]\nPublicKey = NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNA=\nAllowedIPs = 10.79.0.3/32\n"
},
"hosts": "10.77.0.2 phone.anna.lan\n10.77.0.3 laptop.anna.lan\n10.77.0.4 old.anna.lan\n10.77.0.5 bphone.boris.lan\n10.77.0.6 cphone.clara.lan\n10.77.0.7 dphone.dima.lan\n10.77.0.8 ephone.eva.lan\n10.77.0.9 fphone.fedor.lan\n10.77.0.10 gphone.gleb.lan\n10.78.0.2 hphone.hana.lan\n10.78.0.3 iphone.ivan.lan\n10.79.0.2 kphone.kira.lan\n10.79.0.3 lphone.lev.lan\n10.77.0.11 nphone.nora.lan\n",
"hosts_mode": true,
"nft_err": null,
"present": true
},
{
"what": "again: the sets alone",
"peers": {
"home": "ok",
"cabin": "ok",
"open": "ok"
},
"table": null,
"warning": null,
"states": {
"anna": "active",
"boris": "active",
"clara": "active",
"dima": "active",
"eva": "active",
"fedor": "active",
"gleb": "paused",
"hana": "active",
"ivan": "active",
"kira": "active",
"lev": "active",
"nora": "active"
},
"scripts": [
"table inet dawnline\ndelete table inet dawnline\ntable inet dawnline {\n\tset home_home { type ipv4_addr; flags interval; elements = { 192.168.50.0/24, 192.168.77.0/24 } }\n\tset home_cabin { type ipv4_addr; flags interval; elements = { 192.168.50.0/24 } }\n\tset home_open { type ipv4_addr; flags interval; elements = { 192.168.77.0/24 } }\n\tset tun_nets { type ipv4_addr; flags interval; elements = { 10.77.0.0/24, 10.78.0.0/24, 10.79.0.0/24 } }\n\tset lan_ok { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.7, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3, 10.77.0.11 } }\n\tset lan_all { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3 } }\n\tset lan_part { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.7 . 192.168.50.0/24, 10.77.0.11 . 192.168.77.0/24 } }\n\tset mesh_pairs { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.2 . 10.77.0.3, 10.77.0.2 . 10.77.0.5, 10.77.0.2 . 10.77.0.11, 10.77.0.3 . 10.77.0.2, 10.77.0.3 . 10.77.0.5, 10.77.0.3 . 10.77.0.11, 10.77.0.5 . 10.77.0.2, 10.77.0.5 . 10.77.0.3, 10.77.0.5 . 10.77.0.11, 10.77.0.11 . 10.77.0.2, 10.77.0.11 . 10.77.0.3, 10.77.0.11 . 10.77.0.5 } }\n\tset inet_ok { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.6, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3, 10.77.0.11 } }\n\tset svc_ok { type ipv4_addr . ipv4_addr . inet_service; flags interval; }\n\tset svc_host { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.8 . 192.168.77.5, 10.77.0.8 . 192.168.50.30 } }\n\tset dns_real { type ipv4_addr; flags interval; }\n\tchain pre {\n\t\ttype filter hook prerouting priority -160; policy accept;\n\t\tiifname { \"dawn0\", \"dawn1\", \"dawn2\" } jump guard\n\t}\n\tchain guard {\n\t\tmeta nfproto ipv6 drop\n\t\tct state related accept\n\t\tct status dnat accept\n\t\ticmp type { echo-request, echo-reply } fib daddr type local accept\n\t\tfib daddr type local meta l4proto { tcp, udp } th dport 53 accept\n\t\tfib daddr type local tcp dport { 4500, 4501 } accept\n\t\tfib daddr type local ip saddr @lan_all accept\n\t\tfib daddr type local ip saddr . ip daddr @lan_part accept\n\t\tfib daddr type local counter drop\n\t\tiifname \"dawn0\" ip daddr @home_home ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tiifname \"dawn1\" ip daddr @home_cabin ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tiifname \"dawn2\" ip daddr @home_open ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tip saddr . ip daddr @lan_part ip daddr != @tun_nets accept\n\t\tiifname \"dawn0\" ip saddr . ip daddr @mesh_pairs accept\n\t\tiifname \"dawn2\" ip saddr @lan_ok ip daddr @lan_ok accept\n\t\tmeta l4proto { tcp, udp } ip saddr . ip daddr . th dport @svc_ok accept\n\t\tip saddr . ip daddr @svc_host accept\n\t\tip daddr { 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 100.64.0.0/10, 169.254.0.0/16, 224.0.0.0/3 } counter drop\n\t\tip saddr @inet_ok accept\n\t\tcounter drop\n\t}\n\tchain inbound {\n\t\ttype filter hook forward priority filter - 5; policy accept;\n\t\toifname { \"dawn0\", \"dawn1\", \"dawn2\" } iifname != { \"dawn0\", \"dawn1\", \"dawn2\" } ct state new jump to_device\n\t}\n\tchain to_device {\n\t\tmeta nfproto ipv6 drop\n\t\tct status dnat accept\n\t\toifname \"dawn0\" ip saddr @home_home ip saddr != @tun_nets ip daddr @lan_all accept\n\t\toifname \"dawn1\" ip saddr @home_cabin ip saddr != @tun_nets ip daddr @lan_all accept\n\t\toifname \"dawn2\" ip saddr @home_open ip saddr != @tun_nets ip daddr @lan_all accept\n\t\tip daddr . ip saddr @lan_part ip saddr != @tun_nets accept\n\t\tcounter reject with icmpx admin-prohibited\n\t}\n\tchain dns {\n\t\ttype nat hook prerouting priority dstnat - 5; policy accept;\n\t\tiifname { \"dawn0\", \"dawn1\", \"dawn2\" } ip saddr @dns_real meta l4proto { tcp, udp } th dport 53 redirect to :5354\n\t}\n\tchain dns_lan {\n\t\ttype nat hook prerouting priority dstnat + 5; policy accept;\n\t\tiifname \"dawn0\" ip daddr 10.77.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t\tiifname \"dawn1\" ip daddr 10.78.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t\tiifname \"dawn2\" ip daddr 10.79.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t}\n}\n"
],
"confs": {
"dawn0": "[Interface]\nPrivateKey = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA=\nListenPort = 4500\n\n[Peer]\nPublicKey = BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBA=\nAllowedIPs = 10.77.0.2/32\n\n[Peer]\nPublicKey = CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCA=\nAllowedIPs = 10.77.0.3/32\n\n[Peer]\nPublicKey = EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEA=\nAllowedIPs = 10.77.0.5/32\n\n[Peer]\nPublicKey = FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA=\nAllowedIPs = 10.77.0.6/32\n\n[Peer]\nPublicKey = GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGA=\nAllowedIPs = 10.77.0.7/32\n\n[Peer]\nPublicKey = HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHA=\nAllowedIPs = 10.77.0.8/32\n\n[Peer]\nPublicKey = IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIA=\nAllowedIPs = 10.77.0.9/32\n\n[Peer]\nPublicKey = OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOA=\nAllowedIPs = 10.77.0.11/32\n",
"dawn1": "[Interface]\nPrivateKey = ccccccccccccccccccccccccccccccccccccccccccA=\nListenPort = 4600\n\n[Peer]\nPublicKey = KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKA=\nAllowedIPs = 10.78.0.2/32\n\n[Peer]\nPublicKey = LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLA=\nAllowedIPs = 10.78.0.3/32\n",
"dawn2": "[Interface]\nPrivateKey = eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeA=\nListenPort = 4700\n\n[Peer]\nPublicKey = MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMA=\nAllowedIPs = 10.79.0.2/32\n\n[Peer]\nPublicKey = NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNA=\nAllowedIPs = 10.79.0.3/32\n"
},
"hosts": "10.77.0.2 phone.anna.lan\n10.77.0.3 laptop.anna.lan\n10.77.0.4 old.anna.lan\n10.77.0.5 bphone.boris.lan\n10.77.0.6 cphone.clara.lan\n10.77.0.7 dphone.dima.lan\n10.77.0.8 ephone.eva.lan\n10.77.0.9 fphone.fedor.lan\n10.77.0.10 gphone.gleb.lan\n10.78.0.2 hphone.hana.lan\n10.78.0.3 iphone.ivan.lan\n10.79.0.2 kphone.kira.lan\n10.79.0.3 lphone.lev.lan\n10.77.0.11 nphone.nora.lan\n",
"hosts_mode": true,
"nft_err": null,
"present": true
},
{
"what": "someone is paused",
"peers": {
"home": "ok",
"cabin": "ok",
"open": "ok"
},
"table": null,
"warning": null,
"states": {
"anna": "paused",
"boris": "active",
"clara": "active",
"dima": "active",
"eva": "active",
"fedor": "active",
"gleb": "paused",
"hana": "active",
"ivan": "active",
"kira": "active",
"lev": "active",
"nora": "active"
},
"scripts": [
"table inet dawnline\ndelete table inet dawnline\ntable inet dawnline {\n\tset home_home { type ipv4_addr; flags interval; elements = { 192.168.50.0/24, 192.168.77.0/24 } }\n\tset home_cabin { type ipv4_addr; flags interval; elements = { 192.168.50.0/24 } }\n\tset home_open { type ipv4_addr; flags interval; elements = { 192.168.77.0/24 } }\n\tset tun_nets { type ipv4_addr; flags interval; elements = { 10.77.0.0/24, 10.78.0.0/24, 10.79.0.0/24 } }\n\tset lan_ok { type ipv4_addr; flags interval; elements = { 10.77.0.5, 10.77.0.7, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3, 10.77.0.11 } }\n\tset lan_all { type ipv4_addr; flags interval; elements = { 10.77.0.5, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3 } }\n\tset lan_part { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.7 . 192.168.50.0/24, 10.77.0.11 . 192.168.77.0/24 } }\n\tset mesh_pairs { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.5 . 10.77.0.11, 10.77.0.11 . 10.77.0.5 } }\n\tset inet_ok { type ipv4_addr; flags interval; elements = { 10.77.0.5, 10.77.0.6, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3, 10.77.0.11 } }\n\tset svc_ok { type ipv4_addr . ipv4_addr . inet_service; flags interval; }\n\tset svc_host { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.8 . 192.168.77.5, 10.77.0.8 . 192.168.50.30 } }\n\tset dns_real { type ipv4_addr; flags interval; }\n\tchain pre {\n\t\ttype filter hook prerouting priority -160; policy accept;\n\t\tiifname { \"dawn0\", \"dawn1\", \"dawn2\" } jump guard\n\t}\n\tchain guard {\n\t\tmeta nfproto ipv6 drop\n\t\tct state related accept\n\t\tct status dnat accept\n\t\ticmp type { echo-request, echo-reply } fib daddr type local accept\n\t\tfib daddr type local meta l4proto { tcp, udp } th dport 53 accept\n\t\tfib daddr type local tcp dport { 4500, 4501 } accept\n\t\tfib daddr type local ip saddr @lan_all accept\n\t\tfib daddr type local ip saddr . ip daddr @lan_part accept\n\t\tfib daddr type local counter drop\n\t\tiifname \"dawn0\" ip daddr @home_home ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tiifname \"dawn1\" ip daddr @home_cabin ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tiifname \"dawn2\" ip daddr @home_open ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tip saddr . ip daddr @lan_part ip daddr != @tun_nets accept\n\t\tiifname \"dawn0\" ip saddr . ip daddr @mesh_pairs accept\n\t\tiifname \"dawn2\" ip saddr @lan_ok ip daddr @lan_ok accept\n\t\tmeta l4proto { tcp, udp } ip saddr . ip daddr . th dport @svc_ok accept\n\t\tip saddr . ip daddr @svc_host accept\n\t\tip daddr { 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 100.64.0.0/10, 169.254.0.0/16, 224.0.0.0/3 } counter drop\n\t\tip saddr @inet_ok accept\n\t\tcounter drop\n\t}\n\tchain inbound {\n\t\ttype filter hook forward priority filter - 5; policy accept;\n\t\toifname { \"dawn0\", \"dawn1\", \"dawn2\" } iifname != { \"dawn0\", \"dawn1\", \"dawn2\" } ct state new jump to_device\n\t}\n\tchain to_device {\n\t\tmeta nfproto ipv6 drop\n\t\tct status dnat accept\n\t\toifname \"dawn0\" ip saddr @home_home ip saddr != @tun_nets ip daddr @lan_all accept\n\t\toifname \"dawn1\" ip saddr @home_cabin ip saddr != @tun_nets ip daddr @lan_all accept\n\t\toifname \"dawn2\" ip saddr @home_open ip saddr != @tun_nets ip daddr @lan_all accept\n\t\tip daddr . ip saddr @lan_part ip saddr != @tun_nets accept\n\t\tcounter reject with icmpx admin-prohibited\n\t}\n\tchain dns {\n\t\ttype nat hook prerouting priority dstnat - 5; policy accept;\n\t\tiifname { \"dawn0\", \"dawn1\", \"dawn2\" } ip saddr @dns_real meta l4proto { tcp, udp } th dport 53 redirect to :5354\n\t}\n\tchain dns_lan {\n\t\ttype nat hook prerouting priority dstnat + 5; policy accept;\n\t\tiifname \"dawn0\" ip daddr 10.77.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t\tiifname \"dawn1\" ip daddr 10.78.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t\tiifname \"dawn2\" ip daddr 10.79.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t}\n}\n"
],
"confs": {
"dawn0": "[Interface]\nPrivateKey = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA=\nListenPort = 4500\n\n[Peer]\nPublicKey = EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEA=\nAllowedIPs = 10.77.0.5/32\n\n[Peer]\nPublicKey = FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA=\nAllowedIPs = 10.77.0.6/32\n\n[Peer]\nPublicKey = GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGA=\nAllowedIPs = 10.77.0.7/32\n\n[Peer]\nPublicKey = HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHA=\nAllowedIPs = 10.77.0.8/32\n\n[Peer]\nPublicKey = IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIA=\nAllowedIPs = 10.77.0.9/32\n\n[Peer]\nPublicKey = OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOA=\nAllowedIPs = 10.77.0.11/32\n",
"dawn1": "[Interface]\nPrivateKey = ccccccccccccccccccccccccccccccccccccccccccA=\nListenPort = 4600\n\n[Peer]\nPublicKey = KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKA=\nAllowedIPs = 10.78.0.2/32\n\n[Peer]\nPublicKey = LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLA=\nAllowedIPs = 10.78.0.3/32\n",
"dawn2": "[Interface]\nPrivateKey = eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeA=\nListenPort = 4700\n\n[Peer]\nPublicKey = MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMA=\nAllowedIPs = 10.79.0.2/32\n\n[Peer]\nPublicKey = NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNA=\nAllowedIPs = 10.79.0.3/32\n"
},
"hosts": "10.77.0.2 phone.anna.lan\n10.77.0.3 laptop.anna.lan\n10.77.0.4 old.anna.lan\n10.77.0.5 bphone.boris.lan\n10.77.0.6 cphone.clara.lan\n10.77.0.7 dphone.dima.lan\n10.77.0.8 ephone.eva.lan\n10.77.0.9 fphone.fedor.lan\n10.77.0.10 gphone.gleb.lan\n10.78.0.2 hphone.hana.lan\n10.78.0.3 iphone.ivan.lan\n10.79.0.2 kphone.kira.lan\n10.79.0.3 lphone.lev.lan\n10.77.0.11 nphone.nora.lan\n",
"hosts_mode": true,
"nft_err": null,
"present": true
},
{
"what": "the table will not load, the old one stays",
"peers": {
"home": "ok",
"cabin": "ok",
"open": "ok"
},
"table": "rules:1:1-5: Error: a made-up failure",
"warning": "Access rules couldn't be updated (rules:1:1-5: Error: a made-up failure): the previous rules stay, so this change isn't in effect yet. Open Overview → Health.",
"states": {
"anna": "active",
"boris": "active",
"clara": "active",
"dima": "active",
"eva": "active",
"fedor": "active",
"gleb": "paused",
"hana": "active",
"ivan": "active",
"kira": "active",
"lev": "active",
"nora": "active"
},
"scripts": [
"table inet dawnline\ndelete table inet dawnline\ntable inet dawnline {\n\tset home_home { type ipv4_addr; flags interval; elements = { 192.168.50.0/24, 192.168.77.0/24 } }\n\tset home_cabin { type ipv4_addr; flags interval; elements = { 192.168.50.0/24 } }\n\tset home_open { type ipv4_addr; flags interval; elements = { 192.168.77.0/24 } }\n\tset tun_nets { type ipv4_addr; flags interval; elements = { 10.77.0.0/24, 10.78.0.0/24, 10.79.0.0/24 } }\n\tset lan_ok { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.7, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3, 10.77.0.11 } }\n\tset lan_all { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3 } }\n\tset lan_part { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.7 . 192.168.50.0/24, 10.77.0.11 . 192.168.77.0/24 } }\n\tset mesh_pairs { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.2 . 10.77.0.3, 10.77.0.2 . 10.77.0.5, 10.77.0.2 . 10.77.0.11, 10.77.0.3 . 10.77.0.2, 10.77.0.3 . 10.77.0.5, 10.77.0.3 . 10.77.0.11, 10.77.0.5 . 10.77.0.2, 10.77.0.5 . 10.77.0.3, 10.77.0.5 . 10.77.0.11, 10.77.0.11 . 10.77.0.2, 10.77.0.11 . 10.77.0.3, 10.77.0.11 . 10.77.0.5 } }\n\tset inet_ok { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.6, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3, 10.77.0.11 } }\n\tset svc_ok { type ipv4_addr . ipv4_addr . inet_service; flags interval; }\n\tset svc_host { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.8 . 192.168.77.5, 10.77.0.8 . 192.168.50.30 } }\n\tset dns_real { type ipv4_addr; flags interval; }\n\tchain pre {\n\t\ttype filter hook prerouting priority -160; policy accept;\n\t\tiifname { \"dawn0\", \"dawn1\", \"dawn2\" } jump guard\n\t}\n\tchain guard {\n\t\tmeta nfproto ipv6 drop\n\t\tct state related accept\n\t\tct status dnat accept\n\t\ticmp type { echo-request, echo-reply } fib daddr type local accept\n\t\tfib daddr type local meta l4proto { tcp, udp } th dport 53 accept\n\t\tfib daddr type local tcp dport { 4500, 4501 } accept\n\t\tfib daddr type local ip saddr @lan_all accept\n\t\tfib daddr type local ip saddr . ip daddr @lan_part accept\n\t\tfib daddr type local counter drop\n\t\tiifname \"dawn0\" ip daddr @home_home ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tiifname \"dawn1\" ip daddr @home_cabin ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tiifname \"dawn2\" ip daddr @home_open ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tip saddr . ip daddr @lan_part ip daddr != @tun_nets accept\n\t\tiifname \"dawn0\" ip saddr . ip daddr @mesh_pairs accept\n\t\tiifname \"dawn2\" ip saddr @lan_ok ip daddr @lan_ok accept\n\t\tmeta l4proto { tcp, udp } ip saddr . ip daddr . th dport @svc_ok accept\n\t\tip saddr . ip daddr @svc_host accept\n\t\tip daddr { 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 100.64.0.0/10, 169.254.0.0/16, 224.0.0.0/3 } counter drop\n\t\tip saddr @inet_ok accept\n\t\tcounter drop\n\t}\n\tchain inbound {\n\t\ttype filter hook forward priority filter - 5; policy accept;\n\t\toifname { \"dawn0\", \"dawn1\", \"dawn2\" } iifname != { \"dawn0\", \"dawn1\", \"dawn2\" } ct state new jump to_device\n\t}\n\tchain to_device {\n\t\tmeta nfproto ipv6 drop\n\t\tct status dnat accept\n\t\toifname \"dawn0\" ip saddr @home_home ip saddr != @tun_nets ip daddr @lan_all accept\n\t\toifname \"dawn1\" ip saddr @home_cabin ip saddr != @tun_nets ip daddr @lan_all accept\n\t\toifname \"dawn2\" ip saddr @home_open ip saddr != @tun_nets ip daddr @lan_all accept\n\t\tip daddr . ip saddr @lan_part ip saddr != @tun_nets accept\n\t\tcounter reject with icmpx admin-prohibited\n\t}\n\tchain dns {\n\t\ttype nat hook prerouting priority dstnat - 5; policy accept;\n\t\tiifname { \"dawn0\", \"dawn1\", \"dawn2\" } ip saddr @dns_real meta l4proto { tcp, udp } th dport 53 redirect to :5354\n\t}\n\tchain dns_lan {\n\t\ttype nat hook prerouting priority dstnat + 5; policy accept;\n\t\tiifname \"dawn0\" ip daddr 10.77.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t\tiifname \"dawn1\" ip daddr 10.78.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t\tiifname \"dawn2\" ip daddr 10.79.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t}\n}\n"
],
"confs": {
"dawn0": "[Interface]\nPrivateKey = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA=\nListenPort = 4500\n\n[Peer]\nPublicKey = BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBA=\nAllowedIPs = 10.77.0.2/32\n\n[Peer]\nPublicKey = CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCA=\nAllowedIPs = 10.77.0.3/32\n\n[Peer]\nPublicKey = EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEA=\nAllowedIPs = 10.77.0.5/32\n\n[Peer]\nPublicKey = FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA=\nAllowedIPs = 10.77.0.6/32\n\n[Peer]\nPublicKey = GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGA=\nAllowedIPs = 10.77.0.7/32\n\n[Peer]\nPublicKey = HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHA=\nAllowedIPs = 10.77.0.8/32\n\n[Peer]\nPublicKey = IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIA=\nAllowedIPs = 10.77.0.9/32\n\n[Peer]\nPublicKey = OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOA=\nAllowedIPs = 10.77.0.11/32\n",
"dawn1": "[Interface]\nPrivateKey = ccccccccccccccccccccccccccccccccccccccccccA=\nListenPort = 4600\n\n[Peer]\nPublicKey = KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKA=\nAllowedIPs = 10.78.0.2/32\n\n[Peer]\nPublicKey = LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLA=\nAllowedIPs = 10.78.0.3/32\n",
"dawn2": "[Interface]\nPrivateKey = eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeA=\nListenPort = 4700\n\n[Peer]\nPublicKey = MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMA=\nAllowedIPs = 10.79.0.2/32\n\n[Peer]\nPublicKey = NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNA=\nAllowedIPs = 10.79.0.3/32\n"
},
"hosts": "10.77.0.2 phone.anna.lan\n10.77.0.3 laptop.anna.lan\n10.77.0.4 old.anna.lan\n10.77.0.5 bphone.boris.lan\n10.77.0.6 cphone.clara.lan\n10.77.0.7 dphone.dima.lan\n10.77.0.8 ephone.eva.lan\n10.77.0.9 fphone.fedor.lan\n10.77.0.10 gphone.gleb.lan\n10.78.0.2 hphone.hana.lan\n10.78.0.3 iphone.ivan.lan\n10.79.0.2 kphone.kira.lan\n10.79.0.3 lphone.lev.lan\n10.77.0.11 nphone.nora.lan\n",
"hosts_mode": true,
"nft_err": "rules:1:1-5: Error: a made-up failure",
"present": true
},
{
"what": "the table will not load and there is none: nobody is loaded",
"peers": {
"home": "ok",
"cabin": "ok",
"open": "ok"
},
"table": "rules:1:1-5: Error: a made-up failure",
"warning": "Access rules couldn't load (rules:1:1-5: Error: a made-up failure): no device is loaded into the tunnels until they do. Open Overview → Health.",
"states": {
"anna": "active",
"boris": "active",
"clara": "active",
"dima": "active",
"eva": "active",
"fedor": "active",
"gleb": "paused",
"hana": "active",
"ivan": "active",
"kira": "active",
"lev": "active",
"nora": "active"
},
"scripts": [
"table inet dawnline\ndelete table inet dawnline\ntable inet dawnline {\n\tset home_home { type ipv4_addr; flags interval; elements = { 192.168.50.0/24, 192.168.77.0/24 } }\n\tset home_cabin { type ipv4_addr; flags interval; elements = { 192.168.50.0/24 } }\n\tset home_open { type ipv4_addr; flags interval; elements = { 192.168.77.0/24 } }\n\tset tun_nets { type ipv4_addr; flags interval; elements = { 10.77.0.0/24, 10.78.0.0/24, 10.79.0.0/24 } }\n\tset lan_ok { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.7, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3, 10.77.0.11 } }\n\tset lan_all { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3 } }\n\tset lan_part { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.7 . 192.168.50.0/24, 10.77.0.11 . 192.168.77.0/24 } }\n\tset mesh_pairs { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.2 . 10.77.0.3, 10.77.0.2 . 10.77.0.5, 10.77.0.2 . 10.77.0.11, 10.77.0.3 . 10.77.0.2, 10.77.0.3 . 10.77.0.5, 10.77.0.3 . 10.77.0.11, 10.77.0.5 . 10.77.0.2, 10.77.0.5 . 10.77.0.3, 10.77.0.5 . 10.77.0.11, 10.77.0.11 . 10.77.0.2, 10.77.0.11 . 10.77.0.3, 10.77.0.11 . 10.77.0.5 } }\n\tset inet_ok { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.6, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3, 10.77.0.11 } }\n\tset svc_ok { type ipv4_addr . ipv4_addr . inet_service; flags interval; }\n\tset svc_host { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.8 . 192.168.77.5, 10.77.0.8 . 192.168.50.30 } }\n\tset dns_real { type ipv4_addr; flags interval; }\n\tchain pre {\n\t\ttype filter hook prerouting priority -160; policy accept;\n\t\tiifname { \"dawn0\", \"dawn1\", \"dawn2\" } jump guard\n\t}\n\tchain guard {\n\t\tmeta nfproto ipv6 drop\n\t\tct state related accept\n\t\tct status dnat accept\n\t\ticmp type { echo-request, echo-reply } fib daddr type local accept\n\t\tfib daddr type local meta l4proto { tcp, udp } th dport 53 accept\n\t\tfib daddr type local tcp dport { 4500, 4501 } accept\n\t\tfib daddr type local ip saddr @lan_all accept\n\t\tfib daddr type local ip saddr . ip daddr @lan_part accept\n\t\tfib daddr type local counter drop\n\t\tiifname \"dawn0\" ip daddr @home_home ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tiifname \"dawn1\" ip daddr @home_cabin ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tiifname \"dawn2\" ip daddr @home_open ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tip saddr . ip daddr @lan_part ip daddr != @tun_nets accept\n\t\tiifname \"dawn0\" ip saddr . ip daddr @mesh_pairs accept\n\t\tiifname \"dawn2\" ip saddr @lan_ok ip daddr @lan_ok accept\n\t\tmeta l4proto { tcp, udp } ip saddr . ip daddr . th dport @svc_ok accept\n\t\tip saddr . ip daddr @svc_host accept\n\t\tip daddr { 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 100.64.0.0/10, 169.254.0.0/16, 224.0.0.0/3 } counter drop\n\t\tip saddr @inet_ok accept\n\t\tcounter drop\n\t}\n\tchain inbound {\n\t\ttype filter hook forward priority filter - 5; policy accept;\n\t\toifname { \"dawn0\", \"dawn1\", \"dawn2\" } iifname != { \"dawn0\", \"dawn1\", \"dawn2\" } ct state new jump to_device\n\t}\n\tchain to_device {\n\t\tmeta nfproto ipv6 drop\n\t\tct status dnat accept\n\t\toifname \"dawn0\" ip saddr @home_home ip saddr != @tun_nets ip daddr @lan_all accept\n\t\toifname \"dawn1\" ip saddr @home_cabin ip saddr != @tun_nets ip daddr @lan_all accept\n\t\toifname \"dawn2\" ip saddr @home_open ip saddr != @tun_nets ip daddr @lan_all accept\n\t\tip daddr . ip saddr @lan_part ip saddr != @tun_nets accept\n\t\tcounter reject with icmpx admin-prohibited\n\t}\n\tchain dns {\n\t\ttype nat hook prerouting priority dstnat - 5; policy accept;\n\t\tiifname { \"dawn0\", \"dawn1\", \"dawn2\" } ip saddr @dns_real meta l4proto { tcp, udp } th dport 53 redirect to :5354\n\t}\n\tchain dns_lan {\n\t\ttype nat hook prerouting priority dstnat + 5; policy accept;\n\t\tiifname \"dawn0\" ip daddr 10.77.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t\tiifname \"dawn1\" ip daddr 10.78.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t\tiifname \"dawn2\" ip daddr 10.79.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t}\n}\n"
],
"confs": {
"dawn0": "[Interface]\nPrivateKey = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA=\nListenPort = 4500\n",
"dawn1": "[Interface]\nPrivateKey = ccccccccccccccccccccccccccccccccccccccccccA=\nListenPort = 4600\n",
"dawn2": "[Interface]\nPrivateKey = eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeA=\nListenPort = 4700\n"
},
"hosts": "10.77.0.2 phone.anna.lan\n10.77.0.3 laptop.anna.lan\n10.77.0.4 old.anna.lan\n10.77.0.5 bphone.boris.lan\n10.77.0.6 cphone.clara.lan\n10.77.0.7 dphone.dima.lan\n10.77.0.8 ephone.eva.lan\n10.77.0.9 fphone.fedor.lan\n10.77.0.10 gphone.gleb.lan\n10.78.0.2 hphone.hana.lan\n10.78.0.3 iphone.ivan.lan\n10.79.0.2 kphone.kira.lan\n10.79.0.3 lphone.lev.lan\n10.77.0.11 nphone.nora.lan\n",
"hosts_mode": true,
"nft_err": "rules:1:1-5: Error: a made-up failure",
"present": false
},
{
"what": "the same failure again: told once",
"peers": {
"home": "ok",
"cabin": "ok",
"open": "ok"
},
"table": "rules:1:1-5: Error: a made-up failure",
"warning": "Access rules couldn't load (rules:1:1-5: Error: a made-up failure): no device is loaded into the tunnels until they do. Open Overview → Health.",
"states": {
"anna": "active",
"boris": "active",
"clara": "active",
"dima": "active",
"eva": "active",
"fedor": "active",
"gleb": "paused",
"hana": "active",
"ivan": "active",
"kira": "active",
"lev": "active",
"nora": "active"
},
"scripts": [
"table inet dawnline\ndelete table inet dawnline\ntable inet dawnline {\n\tset home_home { type ipv4_addr; flags interval; elements = { 192.168.50.0/24, 192.168.77.0/24 } }\n\tset home_cabin { type ipv4_addr; flags interval; elements = { 192.168.50.0/24 } }\n\tset home_open { type ipv4_addr; flags interval; elements = { 192.168.77.0/24 } }\n\tset tun_nets { type ipv4_addr; flags interval; elements = { 10.77.0.0/24, 10.78.0.0/24, 10.79.0.0/24 } }\n\tset lan_ok { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.7, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3, 10.77.0.11 } }\n\tset lan_all { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3 } }\n\tset lan_part { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.7 . 192.168.50.0/24, 10.77.0.11 . 192.168.77.0/24 } }\n\tset mesh_pairs { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.2 . 10.77.0.3, 10.77.0.2 . 10.77.0.5, 10.77.0.2 . 10.77.0.11, 10.77.0.3 . 10.77.0.2, 10.77.0.3 . 10.77.0.5, 10.77.0.3 . 10.77.0.11, 10.77.0.5 . 10.77.0.2, 10.77.0.5 . 10.77.0.3, 10.77.0.5 . 10.77.0.11, 10.77.0.11 . 10.77.0.2, 10.77.0.11 . 10.77.0.3, 10.77.0.11 . 10.77.0.5 } }\n\tset inet_ok { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.6, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3, 10.77.0.11 } }\n\tset svc_ok { type ipv4_addr . ipv4_addr . inet_service; flags interval; }\n\tset svc_host { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.8 . 192.168.77.5, 10.77.0.8 . 192.168.50.30 } }\n\tset dns_real { type ipv4_addr; flags interval; }\n\tchain pre {\n\t\ttype filter hook prerouting priority -160; policy accept;\n\t\tiifname { \"dawn0\", \"dawn1\", \"dawn2\" } jump guard\n\t}\n\tchain guard {\n\t\tmeta nfproto ipv6 drop\n\t\tct state related accept\n\t\tct status dnat accept\n\t\ticmp type { echo-request, echo-reply } fib daddr type local accept\n\t\tfib daddr type local meta l4proto { tcp, udp } th dport 53 accept\n\t\tfib daddr type local tcp dport { 4500, 4501 } accept\n\t\tfib daddr type local ip saddr @lan_all accept\n\t\tfib daddr type local ip saddr . ip daddr @lan_part accept\n\t\tfib daddr type local counter drop\n\t\tiifname \"dawn0\" ip daddr @home_home ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tiifname \"dawn1\" ip daddr @home_cabin ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tiifname \"dawn2\" ip daddr @home_open ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tip saddr . ip daddr @lan_part ip daddr != @tun_nets accept\n\t\tiifname \"dawn0\" ip saddr . ip daddr @mesh_pairs accept\n\t\tiifname \"dawn2\" ip saddr @lan_ok ip daddr @lan_ok accept\n\t\tmeta l4proto { tcp, udp } ip saddr . ip daddr . th dport @svc_ok accept\n\t\tip saddr . ip daddr @svc_host accept\n\t\tip daddr { 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 100.64.0.0/10, 169.254.0.0/16, 224.0.0.0/3 } counter drop\n\t\tip saddr @inet_ok accept\n\t\tcounter drop\n\t}\n\tchain inbound {\n\t\ttype filter hook forward priority filter - 5; policy accept;\n\t\toifname { \"dawn0\", \"dawn1\", \"dawn2\" } iifname != { \"dawn0\", \"dawn1\", \"dawn2\" } ct state new jump to_device\n\t}\n\tchain to_device {\n\t\tmeta nfproto ipv6 drop\n\t\tct status dnat accept\n\t\toifname \"dawn0\" ip saddr @home_home ip saddr != @tun_nets ip daddr @lan_all accept\n\t\toifname \"dawn1\" ip saddr @home_cabin ip saddr != @tun_nets ip daddr @lan_all accept\n\t\toifname \"dawn2\" ip saddr @home_open ip saddr != @tun_nets ip daddr @lan_all accept\n\t\tip daddr . ip saddr @lan_part ip saddr != @tun_nets accept\n\t\tcounter reject with icmpx admin-prohibited\n\t}\n\tchain dns {\n\t\ttype nat hook prerouting priority dstnat - 5; policy accept;\n\t\tiifname { \"dawn0\", \"dawn1\", \"dawn2\" } ip saddr @dns_real meta l4proto { tcp, udp } th dport 53 redirect to :5354\n\t}\n\tchain dns_lan {\n\t\ttype nat hook prerouting priority dstnat + 5; policy accept;\n\t\tiifname \"dawn0\" ip daddr 10.77.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t\tiifname \"dawn1\" ip daddr 10.78.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t\tiifname \"dawn2\" ip daddr 10.79.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t}\n}\n"
],
"confs": {
"dawn0": "[Interface]\nPrivateKey = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA=\nListenPort = 4500\n",
"dawn1": "[Interface]\nPrivateKey = ccccccccccccccccccccccccccccccccccccccccccA=\nListenPort = 4600\n",
"dawn2": "[Interface]\nPrivateKey = eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeA=\nListenPort = 4700\n"
},
"hosts": "10.77.0.2 phone.anna.lan\n10.77.0.3 laptop.anna.lan\n10.77.0.4 old.anna.lan\n10.77.0.5 bphone.boris.lan\n10.77.0.6 cphone.clara.lan\n10.77.0.7 dphone.dima.lan\n10.77.0.8 ephone.eva.lan\n10.77.0.9 fphone.fedor.lan\n10.77.0.10 gphone.gleb.lan\n10.78.0.2 hphone.hana.lan\n10.78.0.3 iphone.ivan.lan\n10.79.0.2 kphone.kira.lan\n10.79.0.3 lphone.lev.lan\n10.77.0.11 nphone.nora.lan\n",
"hosts_mode": true,
"nft_err": "rules:1:1-5: Error: a made-up failure",
"present": false
},
{
"what": "it loads again; a tunnel refuses its devices",
"peers": {
"home": "Line unrecognized: a made-up refusal",
"cabin": "ok",
"open": "ok"
},
"table": null,
"warning": "Couldn't load devices into Home: Line unrecognized: a made-up refusal. Open Overview → Health.",
"states": {
"anna": "active",
"boris": "active",
"clara": "active",
"dima": "active",
"eva": "active",
"fedor": "active",
"gleb": "paused",
"hana": "active",
"ivan": "active",
"kira": "active",
"lev": "active",
"nora": "active"
},
"scripts": [
"table inet dawnline\ndelete table inet dawnline\ntable inet dawnline {\n\tset home_home { type ipv4_addr; flags interval; elements = { 192.168.50.0/24, 192.168.77.0/24 } }\n\tset home_cabin { type ipv4_addr; flags interval; elements = { 192.168.50.0/24 } }\n\tset home_open { type ipv4_addr; flags interval; elements = { 192.168.77.0/24 } }\n\tset tun_nets { type ipv4_addr; flags interval; elements = { 10.77.0.0/24, 10.78.0.0/24, 10.79.0.0/24 } }\n\tset lan_ok { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.7, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3, 10.77.0.11 } }\n\tset lan_all { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3 } }\n\tset lan_part { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.7 . 192.168.50.0/24, 10.77.0.11 . 192.168.77.0/24 } }\n\tset mesh_pairs { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.2 . 10.77.0.3, 10.77.0.2 . 10.77.0.5, 10.77.0.2 . 10.77.0.11, 10.77.0.3 . 10.77.0.2, 10.77.0.3 . 10.77.0.5, 10.77.0.3 . 10.77.0.11, 10.77.0.5 . 10.77.0.2, 10.77.0.5 . 10.77.0.3, 10.77.0.5 . 10.77.0.11, 10.77.0.11 . 10.77.0.2, 10.77.0.11 . 10.77.0.3, 10.77.0.11 . 10.77.0.5 } }\n\tset inet_ok { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.6, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3, 10.77.0.11 } }\n\tset svc_ok { type ipv4_addr . ipv4_addr . inet_service; flags interval; }\n\tset svc_host { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.8 . 192.168.77.5, 10.77.0.8 . 192.168.50.30 } }\n\tset dns_real { type ipv4_addr; flags interval; }\n\tchain pre {\n\t\ttype filter hook prerouting priority -160; policy accept;\n\t\tiifname { \"dawn0\", \"dawn1\", \"dawn2\" } jump guard\n\t}\n\tchain guard {\n\t\tmeta nfproto ipv6 drop\n\t\tct state related accept\n\t\tct status dnat accept\n\t\ticmp type { echo-request, echo-reply } fib daddr type local accept\n\t\tfib daddr type local meta l4proto { tcp, udp } th dport 53 accept\n\t\tfib daddr type local tcp dport { 4500, 4501 } accept\n\t\tfib daddr type local ip saddr @lan_all accept\n\t\tfib daddr type local ip saddr . ip daddr @lan_part accept\n\t\tfib daddr type local counter drop\n\t\tiifname \"dawn0\" ip daddr @home_home ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tiifname \"dawn1\" ip daddr @home_cabin ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tiifname \"dawn2\" ip daddr @home_open ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tip saddr . ip daddr @lan_part ip daddr != @tun_nets accept\n\t\tiifname \"dawn0\" ip saddr . ip daddr @mesh_pairs accept\n\t\tiifname \"dawn2\" ip saddr @lan_ok ip daddr @lan_ok accept\n\t\tmeta l4proto { tcp, udp } ip saddr . ip daddr . th dport @svc_ok accept\n\t\tip saddr . ip daddr @svc_host accept\n\t\tip daddr { 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 100.64.0.0/10, 169.254.0.0/16, 224.0.0.0/3 } counter drop\n\t\tip saddr @inet_ok accept\n\t\tcounter drop\n\t}\n\tchain inbound {\n\t\ttype filter hook forward priority filter - 5; policy accept;\n\t\toifname { \"dawn0\", \"dawn1\", \"dawn2\" } iifname != { \"dawn0\", \"dawn1\", \"dawn2\" } ct state new jump to_device\n\t}\n\tchain to_device {\n\t\tmeta nfproto ipv6 drop\n\t\tct status dnat accept\n\t\toifname \"dawn0\" ip saddr @home_home ip saddr != @tun_nets ip daddr @lan_all accept\n\t\toifname \"dawn1\" ip saddr @home_cabin ip saddr != @tun_nets ip daddr @lan_all accept\n\t\toifname \"dawn2\" ip saddr @home_open ip saddr != @tun_nets ip daddr @lan_all accept\n\t\tip daddr . ip saddr @lan_part ip saddr != @tun_nets accept\n\t\tcounter reject with icmpx admin-prohibited\n\t}\n\tchain dns {\n\t\ttype nat hook prerouting priority dstnat - 5; policy accept;\n\t\tiifname { \"dawn0\", \"dawn1\", \"dawn2\" } ip saddr @dns_real meta l4proto { tcp, udp } th dport 53 redirect to :5354\n\t}\n\tchain dns_lan {\n\t\ttype nat hook prerouting priority dstnat + 5; policy accept;\n\t\tiifname \"dawn0\" ip daddr 10.77.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t\tiifname \"dawn1\" ip daddr 10.78.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t\tiifname \"dawn2\" ip daddr 10.79.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t}\n}\n"
],
"confs": {
"dawn0": "[Interface]\nPrivateKey = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA=\nListenPort = 4500\n\n[Peer]\nPublicKey = BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBA=\nAllowedIPs = 10.77.0.2/32\n\n[Peer]\nPublicKey = CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCA=\nAllowedIPs = 10.77.0.3/32\n\n[Peer]\nPublicKey = EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEA=\nAllowedIPs = 10.77.0.5/32\n\n[Peer]\nPublicKey = FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA=\nAllowedIPs = 10.77.0.6/32\n\n[Peer]\nPublicKey = GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGA=\nAllowedIPs = 10.77.0.7/32\n\n[Peer]\nPublicKey = HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHA=\nAllowedIPs = 10.77.0.8/32\n\n[Peer]\nPublicKey = IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIA=\nAllowedIPs = 10.77.0.9/32\n\n[Peer]\nPublicKey = OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOA=\nAllowedIPs = 10.77.0.11/32\n",
"dawn1": "[Interface]\nPrivateKey = ccccccccccccccccccccccccccccccccccccccccccA=\nListenPort = 4600\n\n[Peer]\nPublicKey = KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKA=\nAllowedIPs = 10.78.0.2/32\n\n[Peer]\nPublicKey = LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLA=\nAllowedIPs = 10.78.0.3/32\n",
"dawn2": "[Interface]\nPrivateKey = eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeA=\nListenPort = 4700\n\n[Peer]\nPublicKey = MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMA=\nAllowedIPs = 10.79.0.2/32\n\n[Peer]\nPublicKey = NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNA=\nAllowedIPs = 10.79.0.3/32\n"
},
"hosts": "10.77.0.2 phone.anna.lan\n10.77.0.3 laptop.anna.lan\n10.77.0.4 old.anna.lan\n10.77.0.5 bphone.boris.lan\n10.77.0.6 cphone.clara.lan\n10.77.0.7 dphone.dima.lan\n10.77.0.8 ephone.eva.lan\n10.77.0.9 fphone.fedor.lan\n10.77.0.10 gphone.gleb.lan\n10.78.0.2 hphone.hana.lan\n10.78.0.3 iphone.ivan.lan\n10.79.0.2 kphone.kira.lan\n10.79.0.3 lphone.lev.lan\n10.77.0.11 nphone.nora.lan\n",
"hosts_mode": true,
"nft_err": null,
"present": true
},
{
"what": "a tunnel is down",
"peers": {
"home": "ok",
"cabin": "down",
"open": "ok"
},
"table": null,
"warning": null,
"states": {
"anna": "active",
"boris": "active",
"clara": "active",
"dima": "active",
"eva": "active",
"fedor": "active",
"gleb": "paused",
"hana": "active",
"ivan": "active",
"kira": "active",
"lev": "active",
"nora": "active"
},
"scripts": [
"table inet dawnline\ndelete table inet dawnline\ntable inet dawnline {\n\tset home_home { type ipv4_addr; flags interval; elements = { 192.168.50.0/24, 192.168.77.0/24 } }\n\tset home_cabin { type ipv4_addr; flags interval; elements = { 192.168.50.0/24 } }\n\tset home_open { type ipv4_addr; flags interval; elements = { 192.168.77.0/24 } }\n\tset tun_nets { type ipv4_addr; flags interval; elements = { 10.77.0.0/24, 10.78.0.0/24, 10.79.0.0/24 } }\n\tset lan_ok { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.7, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3, 10.77.0.11 } }\n\tset lan_all { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3 } }\n\tset lan_part { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.7 . 192.168.50.0/24, 10.77.0.11 . 192.168.77.0/24 } }\n\tset mesh_pairs { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.2 . 10.77.0.3, 10.77.0.2 . 10.77.0.5, 10.77.0.2 . 10.77.0.11, 10.77.0.3 . 10.77.0.2, 10.77.0.3 . 10.77.0.5, 10.77.0.3 . 10.77.0.11, 10.77.0.5 . 10.77.0.2, 10.77.0.5 . 10.77.0.3, 10.77.0.5 . 10.77.0.11, 10.77.0.11 . 10.77.0.2, 10.77.0.11 . 10.77.0.3, 10.77.0.11 . 10.77.0.5 } }\n\tset inet_ok { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.6, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3, 10.77.0.11 } }\n\tset svc_ok { type ipv4_addr . ipv4_addr . inet_service; flags interval; }\n\tset svc_host { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.8 . 192.168.77.5, 10.77.0.8 . 192.168.50.30 } }\n\tset dns_real { type ipv4_addr; flags interval; }\n\tchain pre {\n\t\ttype filter hook prerouting priority -160; policy accept;\n\t\tiifname { \"dawn0\", \"dawn1\", \"dawn2\" } jump guard\n\t}\n\tchain guard {\n\t\tmeta nfproto ipv6 drop\n\t\tct state related accept\n\t\tct status dnat accept\n\t\ticmp type { echo-request, echo-reply } fib daddr type local accept\n\t\tfib daddr type local meta l4proto { tcp, udp } th dport 53 accept\n\t\tfib daddr type local tcp dport { 4500, 4501 } accept\n\t\tfib daddr type local ip saddr @lan_all accept\n\t\tfib daddr type local ip saddr . ip daddr @lan_part accept\n\t\tfib daddr type local counter drop\n\t\tiifname \"dawn0\" ip daddr @home_home ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tiifname \"dawn1\" ip daddr @home_cabin ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tiifname \"dawn2\" ip daddr @home_open ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tip saddr . ip daddr @lan_part ip daddr != @tun_nets accept\n\t\tiifname \"dawn0\" ip saddr . ip daddr @mesh_pairs accept\n\t\tiifname \"dawn2\" ip saddr @lan_ok ip daddr @lan_ok accept\n\t\tmeta l4proto { tcp, udp } ip saddr . ip daddr . th dport @svc_ok accept\n\t\tip saddr . ip daddr @svc_host accept\n\t\tip daddr { 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 100.64.0.0/10, 169.254.0.0/16, 224.0.0.0/3 } counter drop\n\t\tip saddr @inet_ok accept\n\t\tcounter drop\n\t}\n\tchain inbound {\n\t\ttype filter hook forward priority filter - 5; policy accept;\n\t\toifname { \"dawn0\", \"dawn1\", \"dawn2\" } iifname != { \"dawn0\", \"dawn1\", \"dawn2\" } ct state new jump to_device\n\t}\n\tchain to_device {\n\t\tmeta nfproto ipv6 drop\n\t\tct status dnat accept\n\t\toifname \"dawn0\" ip saddr @home_home ip saddr != @tun_nets ip daddr @lan_all accept\n\t\toifname \"dawn1\" ip saddr @home_cabin ip saddr != @tun_nets ip daddr @lan_all accept\n\t\toifname \"dawn2\" ip saddr @home_open ip saddr != @tun_nets ip daddr @lan_all accept\n\t\tip daddr . ip saddr @lan_part ip saddr != @tun_nets accept\n\t\tcounter reject with icmpx admin-prohibited\n\t}\n\tchain dns {\n\t\ttype nat hook prerouting priority dstnat - 5; policy accept;\n\t\tiifname { \"dawn0\", \"dawn1\", \"dawn2\" } ip saddr @dns_real meta l4proto { tcp, udp } th dport 53 redirect to :5354\n\t}\n\tchain dns_lan {\n\t\ttype nat hook prerouting priority dstnat + 5; policy accept;\n\t\tiifname \"dawn0\" ip daddr 10.77.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t\tiifname \"dawn1\" ip daddr 10.78.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t\tiifname \"dawn2\" ip daddr 10.79.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t}\n}\n"
],
"confs": {
"dawn0": "[Interface]\nPrivateKey = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA=\nListenPort = 4500\n\n[Peer]\nPublicKey = BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBA=\nAllowedIPs = 10.77.0.2/32\n\n[Peer]\nPublicKey = CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCA=\nAllowedIPs = 10.77.0.3/32\n\n[Peer]\nPublicKey = EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEA=\nAllowedIPs = 10.77.0.5/32\n\n[Peer]\nPublicKey = FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA=\nAllowedIPs = 10.77.0.6/32\n\n[Peer]\nPublicKey = GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGA=\nAllowedIPs = 10.77.0.7/32\n\n[Peer]\nPublicKey = HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHA=\nAllowedIPs = 10.77.0.8/32\n\n[Peer]\nPublicKey = IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIA=\nAllowedIPs = 10.77.0.9/32\n\n[Peer]\nPublicKey = OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOA=\nAllowedIPs = 10.77.0.11/32\n",
"dawn2": "[Interface]\nPrivateKey = eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeA=\nListenPort = 4700\n\n[Peer]\nPublicKey = MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMA=\nAllowedIPs = 10.79.0.2/32\n\n[Peer]\nPublicKey = NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNA=\nAllowedIPs = 10.79.0.3/32\n"
},
"hosts": "10.77.0.2 phone.anna.lan\n10.77.0.3 laptop.anna.lan\n10.77.0.4 old.anna.lan\n10.77.0.5 bphone.boris.lan\n10.77.0.6 cphone.clara.lan\n10.77.0.7 dphone.dima.lan\n10.77.0.8 ephone.eva.lan\n10.77.0.9 fphone.fedor.lan\n10.77.0.10 gphone.gleb.lan\n10.78.0.2 hphone.hana.lan\n10.78.0.3 iphone.ivan.lan\n10.79.0.2 kphone.kira.lan\n10.79.0.3 lphone.lev.lan\n10.77.0.11 nphone.nora.lan\n",
"hosts_mode": true,
"nft_err": null,
"present": true
},
{
"what": "all is well",
"peers": {
"home": "ok",
"cabin": "ok",
"open": "ok"
},
"table": null,
"warning": null,
"states": {
"anna": "active",
"boris": "active",
"clara": "active",
"dima": "active",
"eva": "active",
"fedor": "active",
"gleb": "paused",
"hana": "active",
"ivan": "active",
"kira": "active",
"lev": "active",
"nora": "active"
},
"scripts": [
"table inet dawnline\ndelete table inet dawnline\ntable inet dawnline {\n\tset home_home { type ipv4_addr; flags interval; elements = { 192.168.50.0/24, 192.168.77.0/24 } }\n\tset home_cabin { type ipv4_addr; flags interval; elements = { 192.168.50.0/24 } }\n\tset home_open { type ipv4_addr; flags interval; elements = { 192.168.77.0/24 } }\n\tset tun_nets { type ipv4_addr; flags interval; elements = { 10.77.0.0/24, 10.78.0.0/24, 10.79.0.0/24 } }\n\tset lan_ok { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.7, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3, 10.77.0.11 } }\n\tset lan_all { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3 } }\n\tset lan_part { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.7 . 192.168.50.0/24, 10.77.0.11 . 192.168.77.0/24 } }\n\tset mesh_pairs { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.2 . 10.77.0.3, 10.77.0.2 . 10.77.0.5, 10.77.0.2 . 10.77.0.11, 10.77.0.3 . 10.77.0.2, 10.77.0.3 . 10.77.0.5, 10.77.0.3 . 10.77.0.11, 10.77.0.5 . 10.77.0.2, 10.77.0.5 . 10.77.0.3, 10.77.0.5 . 10.77.0.11, 10.77.0.11 . 10.77.0.2, 10.77.0.11 . 10.77.0.3, 10.77.0.11 . 10.77.0.5 } }\n\tset inet_ok { type ipv4_addr; flags interval; elements = { 10.77.0.2, 10.77.0.3, 10.77.0.5, 10.77.0.6, 10.77.0.9, 10.78.0.2, 10.78.0.3, 10.79.0.2, 10.79.0.3, 10.77.0.11 } }\n\tset svc_ok { type ipv4_addr . ipv4_addr . inet_service; flags interval; }\n\tset svc_host { type ipv4_addr . ipv4_addr; flags interval; elements = { 10.77.0.8 . 192.168.77.5, 10.77.0.8 . 192.168.50.30 } }\n\tset dns_real { type ipv4_addr; flags interval; }\n\tchain pre {\n\t\ttype filter hook prerouting priority -160; policy accept;\n\t\tiifname { \"dawn0\", \"dawn1\", \"dawn2\" } jump guard\n\t}\n\tchain guard {\n\t\tmeta nfproto ipv6 drop\n\t\tct state related accept\n\t\tct status dnat accept\n\t\ticmp type { echo-request, echo-reply } fib daddr type local accept\n\t\tfib daddr type local meta l4proto { tcp, udp } th dport 53 accept\n\t\tfib daddr type local tcp dport { 4500, 4501 } accept\n\t\tfib daddr type local ip saddr @lan_all accept\n\t\tfib daddr type local ip saddr . ip daddr @lan_part accept\n\t\tfib daddr type local counter drop\n\t\tiifname \"dawn0\" ip daddr @home_home ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tiifname \"dawn1\" ip daddr @home_cabin ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tiifname \"dawn2\" ip daddr @home_open ip daddr != @tun_nets ip saddr @lan_all accept\n\t\tip saddr . ip daddr @lan_part ip daddr != @tun_nets accept\n\t\tiifname \"dawn0\" ip saddr . ip daddr @mesh_pairs accept\n\t\tiifname \"dawn2\" ip saddr @lan_ok ip daddr @lan_ok accept\n\t\tmeta l4proto { tcp, udp } ip saddr . ip daddr . th dport @svc_ok accept\n\t\tip saddr . ip daddr @svc_host accept\n\t\tip daddr { 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 100.64.0.0/10, 169.254.0.0/16, 224.0.0.0/3 } counter drop\n\t\tip saddr @inet_ok accept\n\t\tcounter drop\n\t}\n\tchain inbound {\n\t\ttype filter hook forward priority filter - 5; policy accept;\n\t\toifname { \"dawn0\", \"dawn1\", \"dawn2\" } iifname != { \"dawn0\", \"dawn1\", \"dawn2\" } ct state new jump to_device\n\t}\n\tchain to_device {\n\t\tmeta nfproto ipv6 drop\n\t\tct status dnat accept\n\t\toifname \"dawn0\" ip saddr @home_home ip saddr != @tun_nets ip daddr @lan_all accept\n\t\toifname \"dawn1\" ip saddr @home_cabin ip saddr != @tun_nets ip daddr @lan_all accept\n\t\toifname \"dawn2\" ip saddr @home_open ip saddr != @tun_nets ip daddr @lan_all accept\n\t\tip daddr . ip saddr @lan_part ip saddr != @tun_nets accept\n\t\tcounter reject with icmpx admin-prohibited\n\t}\n\tchain dns {\n\t\ttype nat hook prerouting priority dstnat - 5; policy accept;\n\t\tiifname { \"dawn0\", \"dawn1\", \"dawn2\" } ip saddr @dns_real meta l4proto { tcp, udp } th dport 53 redirect to :5354\n\t}\n\tchain dns_lan {\n\t\ttype nat hook prerouting priority dstnat + 5; policy accept;\n\t\tiifname \"dawn0\" ip daddr 10.77.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t\tiifname \"dawn1\" ip daddr 10.78.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t\tiifname \"dawn2\" ip daddr 10.79.0.1 meta l4proto { tcp, udp } th dport 53 dnat ip to 192.168.77.1:53\n\t}\n}\n"
],
"confs": {
"dawn0": "[Interface]\nPrivateKey = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA=\nListenPort = 4500\n\n[Peer]\nPublicKey = BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBA=\nAllowedIPs = 10.77.0.2/32\n\n[Peer]\nPublicKey = CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCA=\nAllowedIPs = 10.77.0.3/32\n\n[Peer]\nPublicKey = EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEA=\nAllowedIPs = 10.77.0.5/32\n\n[Peer]\nPublicKey = FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA=\nAllowedIPs = 10.77.0.6/32\n\n[Peer]\nPublicKey = GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGA=\nAllowedIPs = 10.77.0.7/32\n\n[Peer]\nPublicKey = HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHA=\nAllowedIPs = 10.77.0.8/32\n\n[Peer]\nPublicKey = IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIA=\nAllowedIPs = 10.77.0.9/32\n\n[Peer]\nPublicKey = OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOA=\nAllowedIPs = 10.77.0.11/32\n",
"dawn1": "[Interface]\nPrivateKey = ccccccccccccccccccccccccccccccccccccccccccA=\nListenPort = 4600\n\n[Peer]\nPublicKey = KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKA=\nAllowedIPs = 10.78.0.2/32\n\n[Peer]\nPublicKey = LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLA=\nAllowedIPs = 10.78.0.3/32\n",
"dawn2": "[Interface]\nPrivateKey = eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeA=\nListenPort = 4700\n\n[Peer]\nPublicKey = MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMA=\nAllowedIPs = 10.79.0.2/32\n\n[Peer]\nPublicKey = NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNA=\nAllowedIPs = 10.79.0.3/32\n"
},
"hosts": "10.77.0.2 phone.anna.lan\n10.77.0.3 laptop.anna.lan\n10.77.0.4 old.anna.lan\n10.77.0.5 bphone.boris.lan\n10.77.0.6 cphone.clara.lan\n10.77.0.7 dphone.dima.lan\n10.77.0.8 ephone.eva.lan\n10.77.0.9 fphone.fedor.lan\n10.77.0.10 gphone.gleb.lan\n10.78.0.2 hphone.hana.lan\n10.78.0.3 iphone.ivan.lan\n10.79.0.2 kphone.kira.lan\n10.79.0.3 lphone.lev.lan\n10.77.0.11 nphone.nora.lan\n",
"hosts_mode": true,
"nft_err": null,
"present": true
}
],
"settings": "\nconfig settings 'settings'\n\toption portal_enabled '1'\n\toption portal_port '4500'\n\toption portal_host 'vpn.example.org'\n\tlist portal_alt '203.0.113.7'\n\nconfig server 'home'\n\toption name 'Home'\n\toption ifname 'dawn0'\n\toption port '4500'\n\toption subnet '10.77.0.0/24'\n\toption private_key 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA='\n\toption public_key 'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbA='\n\toption auto_lan '0'\n\tlist lan_device 'dlhome'\n\tlist lan_device 'br-lan'\n\toption mesh 'circles'\n\toption lan_like '0'\n\nconfig server 'cabin'\n\toption name 'Cabin'\n\toption ifname 'dawn1'\n\toption port '4600'\n\toption subnet '10.78.0.0/24'\n\toption private_key 'ccccccccccccccccccccccccccccccccccccccccccA='\n\toption public_key 'ddddddddddddddddddddddddddddddddddddddddddA='\n\toption auto_lan '0'\n\tlist lan_device 'dlhome'\n\toption mesh 'off'\n\nconfig server 'open'\n\toption name 'Open'\n\toption ifname 'dawn2'\n\toption port '4700'\n\toption subnet '10.79.0.0/24'\n\toption private_key 'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeA='\n\toption public_key 'ffffffffffffffffffffffffffffffffffffffffffA='\n\toption auto_lan '0'\n\tlist lan_device 'br-lan'\n\toption mesh 'all'\n\nconfig circle 'fam'\n\toption server 'home'\n\toption name 'Family'\n\nconfig circle 'work'\n\toption server 'home'\n\toption name 'Work'\n\nconfig service 'nas'\n\toption name 'NAS'\n\toption address '192.168.77.5'\n\tlist ports '445'\n\tlist ports '139'\n\nconfig service 'cam'\n\toption name 'Camera'\n\toption address '192.168.50.30'\n\nconfig person 'anna'\n\toption server 'home'\n\toption name 'Anna'\n\toption access 'both'\n\toption circle 'fam'\n\nconfig person 'boris'\n\toption server 'home'\n\toption name 'Boris'\n\toption access 'both'\n\toption circle 'fam'\n\nconfig person 'clara'\n\toption server 'home'\n\toption name 'Clara'\n\toption access 'internet'\n\nconfig person 'dima'\n\toption server 'home'\n\toption name 'Dima'\n\toption access 'lan'\n\tlist home_net 'dlhome'\n\nconfig person 'eva'\n\toption server 'home'\n\toption name 'Eva'\n\toption access 'lan'\n\tlist service 'nas'\n\tlist service 'cam'\n\nconfig person 'fedor'\n\toption server 'home'\n\toption name 'Fedor'\n\toption access 'both'\n\toption circle 'work'\n\nconfig person 'gleb'\n\toption server 'home'\n\toption name 'Gleb'\n\toption access 'both'\n\toption paused '1'\n\nconfig person 'hana'\n\toption server 'cabin'\n\toption name 'Hana'\n\toption access 'both'\n\nconfig person 'ivan'\n\toption server 'cabin'\n\toption name 'Ivan'\n\toption access 'both'\n\nconfig person 'kira'\n\toption server 'open'\n\toption name 'Kira'\n\toption access 'both'\n\nconfig person 'lev'\n\toption server 'open'\n\toption name 'Lev'\n\toption access 'both'\n\nconfig person 'nora'\n\toption server 'home'\n\toption name 'Nora'\n\toption access 'both'\n\toption circle 'fam'\n\tlist home_net 'br-lan'\n\nconfig device 'phone'\n\toption person 'anna'\n\toption name 'Phone'\n\toption address '10.77.0.2'\n\toption public_key 'BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBA='\n\nconfig device 'laptop'\n\toption person 'anna'\n\toption name 'Laptop'\n\toption address '10.77.0.3'\n\toption public_key 'CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCA='\n\toption lan_bypass '1'\n\toption kind 'computer'\n\nconfig device 'old'\n\toption person 'anna'\n\toption name 'Old'\n\toption address '10.77.0.4'\n\toption public_key 'DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDA='\n\toption disabled '1'\n\nconfig device 'bphone'\n\toption person 'boris'\n\toption name 'Bphone'\n\toption address '10.77.0.5'\n\toption public_key 'EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEA='\n\nconfig device 'cphone'\n\toption person 'clara'\n\toption name 'Cphone'\n\toption address '10.77.0.6'\n\toption public_key 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA='\n\nconfig device 'dphone'\n\toption person 'dima'\n\toption name 'Dphone'\n\toption address '10.77.0.7'\n\toption public_key 'GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGA='\n\nconfig device 'ephone'\n\toption person 'eva'\n\toption name 'Ephone'\n\toption address '10.77.0.8'\n\toption public_key 'HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHA='\n\nconfig device 'fphone'\n\toption person 'fedor'\n\toption name 'Fphone'\n\toption address '10.77.0.9'\n\toption public_key 'IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIA='\n\nconfig device 'gphone'\n\toption person 'gleb'\n\toption name 'Gphone'\n\toption address '10.77.0.10'\n\toption public_key 'JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJA='\n\nconfig device 'hphone'\n\toption person 'hana'\n\toption name 'Hphone'\n\toption address '10.78.0.2'\n\toption public_key 'KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKA='\n\nconfig device 'iphone'\n\toption person 'ivan'\n\toption name 'Iphone'\n\toption address '10.78.0.3'\n\toption public_key 'LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLA='\n\nconfig device 'kphone'\n\toption person 'kira'\n\toption name 'Kphone'\n\toption address '10.79.0.2'\n\toption publicLine truncated
}