Skip to content

Commit 9c81156

Browse files
authored
Merge pull request #688 from michaelw/mw/att-ipv6-unifios5
fix: update dhcpcd installation for ATT IPv6 for UnifiOS 5.x
2 parents 423b13f + 21cdd6c commit 9c81156

File tree

2 files changed

+34
-23
lines changed

2 files changed

+34
-23
lines changed

att-ipv6/10-att-ipv6.sh

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,9 @@ vlans="br0" # "br0 br100 br101..."
3030
domain="example.invalid" # DNS domain
3131
dns6="[2001:4860:4860::8888],[2001:4860:4860::8844]" # Google
3232

33-
CONTAINER=att-ipv6
3433
confdir=${DATA_DIR}/att-ipv6
3534

3635
# main
37-
mkdir -p "${confdir}/dhcpcd"
38-
3936
test -f "${confdir}/dhcpcd.conf" || {
4037
: >"${confdir}/dhcpcd.conf.tmp"
4138
cat >>"${confdir}/dhcpcd.conf.tmp" <<EOF
@@ -90,12 +87,32 @@ EOF
9087
mv "${confdir}/att-ipv6-dnsmasq.conf.tmp" "${confdir}/att-ipv6-dnsmasq.conf"
9188
}
9289

93-
if podman container exists "$CONTAINER"; then
94-
podman start "$CONTAINER"
95-
else
96-
podman run -d --restart=always --name "$CONTAINER" -v "${confdir}/dhcpcd.conf:/etc/dhcpcd.conf" -v "${confdir}/dhcpcd:/var/lib/dhcpcd" --net=host --privileged ghcr.io/michaelw/dhcpcd
90+
if ! dpkg -s dhcpcd5 >/dev/null 2>&1; then
91+
apt-get update
92+
DEBIAN_FRONTEND=noninteractive apt-get install -y dhcpcd5
93+
fi
94+
95+
restart_dhcpcd=0
96+
if [ ! -f /etc/dhcpcd.conf ] || ! cmp -s "${confdir}/dhcpcd.conf" /etc/dhcpcd.conf; then
97+
cp "${confdir}/dhcpcd.conf" /etc/dhcpcd.conf
98+
restart_dhcpcd=1
99+
fi
100+
101+
if [ "$restart_dhcpcd" -eq 1 ]; then
102+
start-stop-daemon -K -x /usr/sbin/dhcpcd
103+
fi
104+
105+
# Warn if UniFi's DHCPv6 client is still active; this setup expects it disabled in UI.
106+
if pgrep -x odhcp6c >/dev/null 2>&1; then
107+
echo "WARNING: odhcp6c is running. Disable WAN/network DHCPv6 in the UniFi UI to avoid conflicts with att-ipv6." >&2
97108
fi
98109

99-
# Fix DHCP, assumes DHCPv6 is turned off in UI
100-
cp "${confdir}/att-ipv6-dnsmasq.conf" /run/dnsmasq.conf.d/
110+
# Fix DHCP
111+
if [ -d /run/dnsmasq.dhcp.conf.d ]; then
112+
# UniFi Network > 9.3.29 (commonly on UniFi OS 5.x)
113+
cp "${confdir}/att-ipv6-dnsmasq.conf" /run/dnsmasq.dhcp.conf.d/att-ipv6.conf
114+
else
115+
# older versions
116+
cp "${confdir}/att-ipv6-dnsmasq.conf" /run/dnsmasq.conf.d/att-ipv6.conf
117+
fi
101118
start-stop-daemon -K -q -x /usr/sbin/dnsmasq

att-ipv6/README.md

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Near the top of `10-att-ipv6.sh`:
3333

3434
This generates configuration files in directory `/data/att-ipv6`, if they don't exist.
3535
The files can be edited, or regenerated by deleting them and re-running the script.
36+
The script installs `dhcpcd5` via `apt` (if needed), copies `/data/att-ipv6/dhcpcd.conf` to `/etc/dhcpcd.conf`, and restarts `dhcpcd` when that configuration changes.
37+
For dnsmasq, it writes `att-ipv6.conf` to `/run/dnsmasq.dhcp.conf.d/` on newer UniFi Network releases (post-`9.3.29`), and falls back to `/run/dnsmasq.conf.d/` on older versions.
3638

3739
## Installation
3840

@@ -43,11 +45,9 @@ The files can be edited, or regenerated by deleting them and re-running the scri
4345
./10-att-ipv6.sh
4446
```
4547

46-
The dhcpcd container being used is built [here](https://github.com/michaelw/dhcpcd-container/pkgs/container/dhcpcd)
47-
4848
## Validation
4949

50-
Running the script starts dhcpcd within the `att-ipv6` container on `eth8` (WAN1) and only for the default network (`br0`). This can be customized, see above.
50+
Running the script configures and runs `dhcpcd` directly on the host for `eth8` (WAN1) and only for the default network (`br0`). This can be customized, see above.
5151

5252
To check that everything is working as expected, and the ATT RG delegates multiple prefixes:
5353

@@ -65,7 +65,7 @@ $ ip -6 r # should see a default route on the WAN interface, and a
6565
```
6666

6767
```sh
68-
$ podman logs att-ipv6 # should see dhcpcd successfully acquiring prefixes
68+
$ journalctl -u dhcpcd -n 200 --no-pager # should see dhcpcd successfully acquiring prefixes
6969
[...]
7070
eth9: writing lease `/var/lib/dhcpcd/eth9.lease6'
7171
eth9: delegated prefix 2600:1700:X:yyyf::/64
@@ -110,21 +110,15 @@ On BGW320-500, check https://192.168.1.254/cgi-bin/lanstatistics.ha for multiple
110110
On clients:
111111

112112
```
113-
ip -6 addr show # should see SLAAC and/or DHCPv6 addresses received (if not, check dnsmasq configuration in `/run/dnsmasq.conf.d`)
113+
ip -6 addr show # should see SLAAC and/or DHCPv6 addresses received (if not, check dnsmasq configuration in `/run/dnsmasq.dhcp.conf.d/att-ipv6.conf` or `/run/dnsmasq.conf.d/att-ipv6.conf`)
114114
```
115115

116116
### Useful commands
117117

118118
```sh
119-
# View dhcpcd logs to verify the container is running without error (ipv6 logs from dhcpcd are normal).
120-
podman logs att-ipv6
119+
# View dhcpcd logs to verify dhcpcd is running without error (ipv6 logs from dhcpcd are normal).
120+
journalctl -u dhcpcd -n 200 --no-pager
121121
122122
# Restart dhcpcd (e.g., after configuration change)
123-
podman exec -it dhcpcd -x
124-
125-
# Stop the container
126-
podman stop att-ipv6
127-
128-
# Remove the container
129-
podman rm att-ipv6
123+
systemctl restart dhcpcd
130124
```

0 commit comments

Comments
 (0)