Skip to content

Commit

Permalink
Merge pull request #45 from davidgibbons/fix_docker_network_cidr
Browse files Browse the repository at this point in the history
  • Loading branch information
binhex authored Nov 4, 2024
2 parents 043fdd2 + 3a6ecc6 commit 0c490b2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion run/local/tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ function get_docker_networking() {
docker_mask=$(ifconfig "${docker_interface}" | grep -P -o -m 1 '(?<=netmask\s)[^\s]+')

# convert netmask into cidr format, strip leading spaces
docker_network_cidr=$(ipcalc "${docker_ip}" "${docker_mask}" | grep -P -o -m 1 "(?<=Network:)\s+[^\s]+" | sed -e 's/^[[:space:]]*//')
if [[ "${docker_mask}" == "255.255.255.255" ]]; then
# edge case where ipcalc does not work for networks with a single host, so we specify the cidr mask manually
docker_network_cidr="${docker_ip}/32"
else
docker_network_cidr=$(ipcalc "${docker_ip}" "${docker_mask}" | grep -P -o -m 1 "(?<=Network:)\s+[^\s]+" | sed -e 's/^[[:space:]]*//')
fi

# append docker interface, gateway adapter, gateway ip, ip, mask and cidr to string
docker_networking+="${docker_interface},${default_gateway_adapter},${default_gateway_ip},${docker_ip},${docker_mask},${docker_network_cidr} "
Expand Down

0 comments on commit 0c490b2

Please sign in to comment.