Skip to content

Commit

Permalink
common: Add notes about how MAC is generated
Browse files Browse the repository at this point in the history
  • Loading branch information
tschettervictor authored Jan 24, 2025
1 parent 10c8296 commit 2c45c51
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions usr/local/share/bastille/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,9 @@ generate_static_mac() {
local jail_name="${1}"
local external_interface="${2}"
local external_interface_mac="$(ifconfig ${external_interface} | grep ether | awk '{print $2}')"
# Use FreeBSD vendor prefix for jail MAC prefix
# Use FreeBSD vendor MAC prefix (58:9c:fc) for jail MAC prefix
local macaddr_prefix="58:9c:fc"
# Use hash of interface+jailname for jail MAC suffix
local macaddr_suffix="$(echo -n "${external_interface_mac}${jail_name}" | sed 's#:##g' | sha256 | cut -b -5 | sed 's/\([0-9a-fA-F][0-9a-fA-F]\)\([0-9a-fA-F][0-9a-fA-F]\)\([0-9a-fA-F]\)/\1:\2:\3/')"
if [ -z "${macaddr_prefix}" ] || [ -z "${macaddr_suffix}" ]; then
error_notify "Failed to generate MAC address."
Expand Down Expand Up @@ -364,4 +365,4 @@ checkyesno() {
return 1
;;
esac
}
}

0 comments on commit 2c45c51

Please sign in to comment.