Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the --macaddress option to specify the MAC address of the tap int…
…erface. Signed-off-by: Brian Koehmstedt <bkoehm@gmail.com>
- Loading branch information
Brian Koehmstedt
committed
Feb 24, 2021
1 parent
6dc0186
commit a37ca4a
Showing
6 changed files
with
121 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
set -xeuo pipefail | ||
|
||
. $(dirname $0)/common.sh | ||
MACADDRESS="0e:d4:18:d9:38:fb" | ||
|
||
unshare -r -n sleep infinity & | ||
child=$! | ||
|
||
wait_for_network_namespace $child | ||
|
||
function cleanup { | ||
kill -9 $child $slirp_pid | ||
} | ||
trap cleanup EXIT | ||
|
||
slirp4netns -c --macaddress $MACADDRESS $child tun11 & | ||
slirp_pid=$! | ||
|
||
wait_for_network_device $child tun11 | ||
|
||
result=$(nsenter --preserve-credentials -U -n --target=$child ip addr show tun11 | grep -o "ether $MACADDRESS") | ||
|
||
if [ -z "$result" ]; then | ||
printf "expecting %s MAC address on the interface but didn't get it" "$MACADDRESS" | ||
exit 1 | ||
fi | ||
|
||
cleanup |