remove tap from set-tap.sh, add mac in conffiles change parametters

This commit is contained in:
primardj 2024-02-01 02:45:49 +00:00
parent 6cd83509f6
commit 5400d15b13
2 changed files with 14 additions and 16 deletions

View file

@ -18,7 +18,6 @@ PARAMETTER available
OPTION available OPTION available
--bridge-id=<bridge-id> Set the name for the new bridge interface, usually it is br0, br1, etc --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. Please not that the CIDR notation have to be use. #TODO --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. Please not that the CIDR notation have to be use. #TODO
--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. --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.
" "
@ -30,20 +29,22 @@ main() {
echo "add bridge interface ${bridge}" echo "add bridge interface ${bridge}"
read -p "use ctrl-C to cancel, or any other key to continue." jaaj read -p "use ctrl-C to cancel, or any other key to continue." jaaj
${rooter} ip link add ${bridge} type bridge ${rooter} ip link add ${bridge} type bridge
echo "add tap interface ${tap}"
read -p "use ctrl-C to cancel, or any other key to continue." jaaj
${rooter} ip tuntap add dev ${tap} mode tap
echo "link bridge ${bridge} to tap ${tap}"
read -p "use ctrl-C to cancel, or any other key to continue." jaaj
${rooter} ip link set dev ${tap} master ${bridge}
echo "no interface to link with bridge ${bridge}" echo "no interface to link with bridge ${bridge}"
#$rooter ip link set dev wlan0 master br0 #$rooter ip link set dev wlan0 master br0
echo "activate ${bridge}" echo "authorise qemu to use as interface ${bridge} as bridge"
if cat /etc/qemu/bridge.conf | grep -q "${bridge}"
then
echo "pass, bridge already authorised"
else
echo "allow ${bridge}" | doas tee -a /etc/qemu/bridge.conf
echo "entry added to /etc/qemu/bridge.conf"
fi
echo "activate bridge ${bridge}"
read -p "use ctrl-C to cancel, or any other key to continue." jaaj read -p "use ctrl-C to cancel, or any other key to continue." jaaj
$rooter ip link set dev ${bridge} up ${rooter} ip link set dev ${bridge} up
} }
@ -71,10 +72,6 @@ for i in $@; do
bridge="${i#*=}" bridge="${i#*=}"
echo "${bridge}" echo "${bridge}"
;; ;;
"--tap-id")
tap="${i#*=}"
echo "${tap}"
;;
"--addr") "--addr")
address="${i#*=}" address="${i#*=}"
echo "${address}" echo "${address}"
@ -90,9 +87,9 @@ for i in $@; do
esac esac
done done
if [ "${bridge}" == "" ] || [ "${tap}" == "" ] if [ "${bridge}" == "" ]
then then
echo "Error, --bridge-id and --tap-id have to be both specified to make the tap address" >&2 echo "Error, --bridge-id have to be specified to make the bridge" >&2
exit exit
fi fi

View file

@ -94,6 +94,7 @@ NPROC="${NPROC}"
MEMORY="${MEMORY}" MEMORY="${MEMORY}"
FORWARD="${FORWARD}" FORWARD="${FORWARD}"
LOCATION="\${NAME}-sandbox" LOCATION="\${NAME}-sandbox"
mac="00:00:00:00:00:00"
EOF EOF
chmod +x "conf/$NAME-vm_var.sh" chmod +x "conf/$NAME-vm_var.sh"