192 Commits

Author SHA1 Message Date
Michael Stapelberg
13e1c1bbb4 netconfig: move /tmp/resolv.conf symlink out of the way
Commit 0f75b1cbef6d0ec4853a6a02d96d4b57ce478769 was incomplete.
2025-01-27 08:26:03 +01:00
Michael Stapelberg
0f75b1cbef netconfigd: write /tmp/resolv.conf only once, do not clobber
This fixes tailscale name resolution breaking again and again.
2025-01-26 10:16:38 +01:00
Michael Stapelberg
07325dde93 netconfigd: do not hardcode 10.0.0.0/24 netmask for hairpinning
related to https://github.com/rtr7/router7/issues/53
2025-01-12 10:29:42 +01:00
Michael Stapelberg
f835cdf1d6 netconfig: do not re-create nftables ruleset from scratch
The current behavior stomps on the rules that programs like
podman or tailscale set up for port forwarding.

With this change, we split port forwardings into a separate chain,
which allows us to create the ruleset once at startup and then only
update the port forwardings specifically (the only dynamic part
of router7’s nftables ruleset).
2024-05-09 10:06:23 +02:00
Michael Stapelberg
b2db10d68b dhcp4d: allow handing out static leases outside of the pool 2023-03-12 09:06:02 +01:00
Michael Stapelberg
a8a12cafc9 diagd: remove ping4/ping6 to external targets in favor of tcp4/tcp6
External ICMP does not necessarily work.
It typically does, but not always.
Last week, for a day or two, ICMP traffic was dropped by Google.

So now we use ICMP only for network equipment targets (default gateway),
and instead use TCP for external connectivity checks.

fixes #77
2022-09-28 22:39:20 +02:00
Michael Stapelberg
196e3f9fd7 netconfig: make forward error correction (FEC) configurable 2022-08-30 21:58:55 +02:00
Michael Stapelberg
db15477448 disable icmp ratelimit
Otherwise, traceroute mysteriously times out sometimes.

https://twitter.com/zekjur/status/924248132837347330
2022-06-21 18:30:53 +02:00
Michael Stapelberg
ce66287189 netconfig: make the MTU configurable
Just in case we need to set it on an uplink0 interface at some point, for example.
2022-06-15 23:19:43 +02:00
Michael Stapelberg
225c8e6abd radvd: ignore requests from other interfaces than the configured one
Announcing networks into uplinks is never a good idea 🙈
2022-06-08 17:42:55 +02:00
Michael Stapelberg
f4dd972e54 netconfig: WireGuard: set up host routes instead of DHCP default
related to https://github.com/rtr7/router7/issues/52
2022-06-07 23:22:08 +02:00
Michael Stapelberg
7d936f4844 allow configuring extra routes
Useful for routing IPv6 subnets through a WireGuard tunnel.

related to https://github.com/rtr7/router7/issues/52
2022-06-06 14:25:25 +02:00
Michael Stapelberg
f52deeed03 allow configuring extra addresses on interfaces
Useful when you need IPv6 and IPv4 addresses on a WireGuard tunnel.
2022-06-06 14:25:25 +02:00
Michael Stapelberg
ef7089dc61 radvd: switch to netip package for mdlayher/ndp 2022-03-25 09:09:26 +01:00
Michael Stapelberg
2014da4ca3 dhcp4d: display active devices based on LastACK
This has the advantage that it also works for static DHCP leases,
provided the device obtains a DHCP lease at all (and isn’t configured with a
static IP address, like the shelly motion sensors for example).
2022-03-12 17:38:16 +01:00
Michael Stapelberg
593cd8c12d export input/output nftables counters as well as forwarded
Thus far, we have only had forwarded bytes metrics.

Notably, forwarded bytes does not include bytes that were sent by the router
itself, e.g. by the webserver or rsync server running on the machine.

fixes https://github.com/rtr7/router7/issues/71
2022-03-08 22:47:18 +01:00
Michael Stapelberg
8dc93c66c4 netconfig: enable NAT hairpinning for port forwardings
fixes https://github.com/rtr7/router7/issues/53
2022-03-08 09:32:09 +01:00
Matt Layher
6d41b077a9
internal/dhcp*: switch to github.com/mdlayher/packet (#70)
* internal/dhcp*: switch to github.com/mdlayher/packet
* internal/dhcp4d: update test constructor name to avoid packet conflict

Signed-off-by: Matt Layher <mdlayher@gmail.com>
2022-02-21 23:39:06 +01:00
Michael Stapelberg
e07002721d teelogger: make writes to /dev/console non-blocking
fixes https://github.com/rtr7/router7/issues/68
2021-09-19 11:45:19 +02:00
Michael Stapelberg
575a14c394 dyndns: add zone to record name
Otherwise, already existing records are not recognized correctly.
2021-09-01 09:37:12 +02:00
Michael Stapelberg
20dd872fbe backup: skip “nobackup” and “srv” directories 2021-09-01 09:27:49 +02:00
Michael Stapelberg
b88ddd41c3 netconfig: don’t try to add bridge to itself 2021-06-12 22:24:38 +02:00
Michael Stapelberg
bfb94377f4 netconfig: move bridge creation into its own function
also don’t short-circuit the rest of the configuration if bridge config fails
2021-06-12 18:25:37 +02:00
Michael Stapelberg
cffd872346 netconfig: implement bridge configuration
fixes https://github.com/rtr7/router7/issues/65
2021-06-06 15:43:55 +02:00
Robert Obryk
f8d1b4c8f2
internal/dhcp4: make persistent errors actally persistent (#62)
Previously, a permanent error would not be persisted for future
invocations of ObtainOrRenew. In practice, the daemon immediately
exited, so this made no difference.
2020-11-23 09:35:00 +01:00
Robert Obryk
8de4eb7ba1
internal/dns: prevent upstreams from being lost during reordering (#63)
If upstreams were reordered between start of an upstream request and its
conclusion, the move-to-front operation would likely incorrectly reorder
upstreams: duplicate one and remove another. Instead, we abandon the
move-to-front operation if that was about to happen.
2020-11-23 09:34:04 +01:00
Robert Obryk
0507d93b3d
dhcp4d: ensure that SetHostname operates on the correct lease (#64)
Previously SetHostname could operate on an expired lease, or even on a
lease for a different hwaddr, if the lease for the correct hwaddr
expired and the same lease ID was given away to someone else.

That's though mostly a theoretical concern, given the actual usage of
SetHostname and the time scales involved.
2020-11-23 09:32:42 +01:00
Michael Stapelberg
7f135438b8 dhcp4d: mention apple-suggested lease time of 1 hour 2020-11-01 19:24:24 +01:00
Michael Stapelberg
a8fce3cbbc diag: drain ping reply channel to avoid goroutine leak 2020-09-14 22:10:09 +02:00
Michael Stapelberg
416c1a58f6 diag: plug socket leak by adding missing Close() 2020-09-14 22:10:07 +02:00
Michael Stapelberg
876f8e320f netconfig: de-configure old DHCPv4 addresses from uplink0
It is generally not a good idea to have multiple IP addresses on the same
interface unless managing their relative priorities via metrics etc.

During an outage, I noticed that with multiple IP addresses,
Linux was using the old obsolete one to send out packets,
which does not work with the ISP.

With this change,
we still hold on to IP addresses for as long as possible,
but no longer.

fixes issue #57
2020-09-12 19:58:47 +02:00
Michael Stapelberg
ae8cfee616 dhcp6: inspect server advertisment IAPD and report error, if any
The fiber7 DHCPv6 servers (sometimes?) use this field for reporting errors.
2020-07-02 22:06:55 +02:00
Michael Stapelberg
aa14d119e6 dyndns: add log message when records are updated
Now both cases are covered.
2020-05-28 17:24:51 +02:00
Michael Stapelberg
decb0978d7 dyndns: update to newer libdns/cloudflare, remove workaround 2020-05-28 17:22:24 +02:00
Michael Stapelberg
7950291db6 dyndns: tweak up-to-date message output 2020-05-28 09:42:55 +02:00
Michael Stapelberg
4a5f55a5de defense in depth: verify hex.DecodeString length
related to #49
2020-05-27 09:50:04 +02:00
Matt Layher
ead58ad72c
cmd/dyndns: prototype for dynamic DNS daemon (#50)
Updates #46.

Signed-off-by: Matt Layher <mdlayher@gmail.com>
2020-05-23 23:06:21 +02:00
Matt Layher
7aeb51e9ec
internal/dhcp4d: handle DHCPDECLINE and fix bug regarding MacBook declining leases (#48)
Fixes #40

Signed-off-by: Matt Layher <mdlayher@gmail.com>
2020-05-23 20:53:13 +02:00
Matt Layher
fe68c2dd52
internal/radvd: add support for DNSSL (#47)
Signed-off-by: Matt Layher <mdlayher@gmail.com>
2020-05-23 19:52:52 +02:00
Michael Stapelberg
53c495091e quirk: enforce minimum lease time of 1 hour for Nintendo devices
The Nintendo Switch has been observed to hold on to IP addresses even after
their expiration. My guess is that this is an oversight: likely the device
enters power saving mode with a configured IP address and just sleeps through
the expiration time.

As the device seems to wake up once every hour, we enforce a minimum lease time
of 1 hour, but only for affected devices. The rest of the network gets short
lease times.

https://twitter.com/zekjur/status/1263949112036282374
2020-05-23 09:07:17 +02:00
Matt Layher
61174cde06
internal/netconfig: add missing error check
Signed-off-by: Matt Layher <mdlayher@gmail.com>
2020-05-09 17:04:31 -04:00
Matt Layher
9f6257b046
internal/dns: fix staticcheck issues
Signed-off-by: Matt Layher <mdlayher@gmail.com>
2020-05-09 17:02:33 -04:00
Matt Layher
b8c40958e8
internal/dhcp6: fix error case
Signed-off-by: Matt Layher <mdlayher@gmail.com>
2020-05-09 17:00:43 -04:00
Matt Layher
411780cd8e
internal/dhcp4: fix error case
Signed-off-by: Matt Layher <mdlayher@gmail.com>
2020-05-09 17:00:07 -04:00
Matt Layher
dd7c3a8a5f
internal/testing/dnsmasq: panic in goroutine instead of fatal
Signed-off-by: Matt Layher <mdlayher@gmail.com>
2020-05-09 16:55:46 -04:00
Matt Layher
8efea22943
internal/radvd: remove dead types
Signed-off-by: Matt Layher <mdlayher@gmail.com>
2020-05-09 16:52:52 -04:00
Matt Layher
e1f2b975a1
internal/dhcp4d: fix staticcheck issues
Signed-off-by: Matt Layher <mdlayher@gmail.com>
2020-05-09 16:51:32 -04:00
Matt Layher
107a8f0425
internal/radvd: switch to github.com/mdlayher/ndp types (#43)
Signed-off-by: Matt Layher <mdlayher@gmail.com>
2020-05-09 22:50:44 +02:00
Michael Stapelberg
2b6ab5b2bd dhcp4d: make hostname override settable from status page 2020-04-12 10:33:11 +02:00
Chris K
4f0efc7b18
dhcp6: use new IAPD & Prefix getters (#41)
Signed-off-by: Chris Koch <chrisko@google.com>
2020-03-13 08:47:38 +01:00