Skip to content

Commit d23cb71

Browse files
authored
Merge pull request #96 from linuxserver/peers
change ip when subnet changes
2 parents 94c5b3d + f28a854 commit d23cb71

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
291291

292292
## Versions
293293

294+
* **11.02.21:** - Fix bug related to changing internal subnet and named peer confs not updating.
294295
* **06.10.20:** - Disable CoreDNS in client mode, or if port 53 is already in use in server mode.
295296
* **04.10.20:** - Allow to specify a list of names as PEERS and add ALLOWEDIPS environment variable. Also, add peer name/id to each one of the peer sections in wg0.conf. Important: Existing users need to delete `/config/templates/peer.conf` and restart
296297
* **27.09.20:** - Cleaning service binding example to have accurate PreDown script.

readme-vars.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ app_setup_block: |
103103
104104
# changelog
105105
changelogs:
106+
- { date: "11.02.21:", desc: "Fix bug related to changing internal subnet and named peer confs not updating." }
106107
- { date: "06.10.20:", desc: "Disable CoreDNS in client mode, or if port 53 is already in use in server mode." }
107108
- { date: "04.10.20:", desc: "Allow to specify a list of names as PEERS and add ALLOWEDIPS environment variable. Also, add peer name/id to each one of the peer sections in wg0.conf. Important: Existing users need to delete `/config/templates/peer.conf` and restart" }
108109
- { date: "27.09.20:", desc: "Cleaning service binding example to have accurate PreDown script." }

root/etc/cont-init.d/30-config

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,13 @@ DUDE"
185185
fi
186186
if [ -f "/config/${PEER_ID}/${PEER_ID}.conf" ]; then
187187
CLIENT_IP=$(cat /config/${PEER_ID}/${PEER_ID}.conf | grep "Address" | awk '{print $NF}')
188+
if [ -n "${ORIG_INTERFACE}" ] && [ "${INTERFACE}" != "${ORIG_INTERFACE}" ]; then
189+
CLIENT_IP=$(echo "${CLIENT_IP}" | sed "s|${ORIG_INTERFACE}|${INTERFACE}|")
190+
fi
188191
else
189192
for idx in {2..254}; do
190193
PROPOSED_IP="${INTERFACE}.${idx}"
191-
if ! grep -q -R "${PROPOSED_IP}" /config/peer*/*.conf; then
194+
if ! grep -q -R "${PROPOSED_IP}" /config/peer*/*.conf && ([ -z "${ORIG_INTERFACE}" ] || ! grep -q -R "${ORIG_INTERFACE}.${idx}" /config/peer*/*.conf); then
192195
CLIENT_IP="${PROPOSED_IP}"
193196
break
194197
fi

0 commit comments

Comments
 (0)