44 lines
1.5 KiB
Bash
Executable file
44 lines
1.5 KiB
Bash
Executable file
#!/usr/bin/bash
|
|
|
|
|
|
|
|
# Set global variables
|
|
|
|
Usage="
|
|
set-tap.sh [PARAMETTER] [OPTION]
|
|
|
|
set up a bridge and a tap interface. Use either doas or sudo to get the root access. Please make sure that you account have access to theses commands.
|
|
|
|
PARAMETTER available
|
|
-h, --help Print this help message and quit
|
|
-v, --version Print the version of this program and quit
|
|
|
|
|
|
OPTION available
|
|
--bridge-id=<bridge-id> Set the name for the new bridge interface, usually it is br0, br1, etc
|
|
--tap-id=<tap-id> Set the tap id. Usually it is tap0, tap1, tap2, etc
|
|
--addr=<address> Set an external address on the bridge. The external address have to be on the same network as one of the host network interface. e.g. if eth0, wlan0, etc is on 192.168.0.2/24, you should put the address on the network 192.168.0.0/24
|
|
--replace=<interface> In case you want to replace the main connexion of your computer so that only the vm will be able to reach the external network, replace interface by the interface you want to replace, and make sure that the --addr is set to one of the ip on the interace. Please not that it will be possible for your host to lost all connection to the external internet with this parametter.
|
|
"
|
|
Version="1.0"
|
|
|
|
|
|
# detect the parametters
|
|
for i in $@; do
|
|
case "$i" in
|
|
"-h" | "--help")
|
|
echo "$Usage"
|
|
exit 0
|
|
;;
|
|
"-v" | "--version")
|
|
echo "$(basename $0) $Version"
|
|
exit 0
|
|
;;
|
|
esac
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
|