-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Ethan Dye <[email protected]>
- Loading branch information
Showing
2 changed files
with
44 additions
and
9 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [[ $EUID != 0 ]] | ||
then echo "Run this script as root" | ||
exit | ||
fi | ||
|
||
BRIDGE="br0" | ||
TAP="tap0" | ||
INTERFACE="eth0" | ||
|
||
echo "Adding bridge $BRIDGE" | ||
ip link add name $BRIDGE type bridge | ||
|
||
echo "Flushing interface $INTERFACE" | ||
ip addr flush dev $INTERFACE | ||
|
||
echo "Setting $BRIDGE as master of $INTERFACE" | ||
ip link set $INTERFACE master $BRIDGE | ||
|
||
echo "Adding tap $TAP" | ||
ip tuntap add $TAP mode tap | ||
|
||
echo "Setting $BRIDGE as master of $TAP" | ||
ip link set $TAP master $BRIDGE | ||
|
||
echo "Setting $INTERFACE, $BRIDGE and $TAP up" | ||
ip link set up dev $INTERFACE | ||
ip link set up dev $TAP | ||
ip link set up dev $BRIDGE | ||
|
||
echo "Stopping NetworkManager" | ||
systemctl stop NetworkManager | ||
|
||
echo "Requesting ip for $BRIDGE" | ||
|
||
if dhclient $BRIDGE; then | ||
echo "Requesting ip for $INTERFACE" | ||
dhclient $INTERFACE | ||
echo "Killing dhclient and starting NetworkManager" | ||
pkill -9 dhclient | ||
systemctl start NetworkManager | ||
fi |