Last active
January 4, 2020 17:35
-
-
Save tuklusan/dfbb2442f989760ae463cc14000f455b to your computer and use it in GitHub Desktop.
vde-switch.sh (FreeBSD) - Sets up VDE Switch and Bridged Tap Interfaces on FreeBSD Host for Virtual Guest Networking, details: http://bit.ly/freebsd-virtualbox
This file contains hidden or 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
#!/bin/sh | |
# ------------------------------ | |
# vde-switch.sh | |
# Setup VDE switch and bridged tap interfaces | |
# FreeBSD 12-RELEASE | |
# Uses vde2 package | |
# | |
# ***** | |
# MUST RUN AS ROOT! | |
# ***** | |
# | |
# More information: | |
# http://bit.ly/freebsd-virtualbox | |
# | |
# Basically does this: | |
# | |
# +---------+ +----+ | |
# |VDE |---|tap0| (VDE tap, has local IP) | |
# |SWITCH | +----+ | |
# |"vde-ip" | +-----------------------------------+ | |
# | |===========| +-----------------------------------+ | |
# +---------+ | +-----------------------------------+ | |
# | | Oracle VirtualBox Virtual Machines| | |
# +----+ +-----------------------------------+ | |
# |tap1| (VDE Plug) | |
# +----+ | |
# | | |
# | +--------+ | |
# +----------|bridge | | |
# |bridge0 | | |
# +--------+ | |
# | +--------+ | |
# +--------| tap2 | <--> QEMU SliTaz Linux | |
# | +--------+ | |
# | | |
# | +--------+ | |
# +--------| tap3 | <--> QEMU Debian/HP parisc | |
# | +--------+ | |
# | | |
# | +--------+ | |
# +--------| tap4 | <--> QEMU HPUX 11.11/HP parisc | |
# | +--------+ | |
# | | |
# | +--------+ | |
# +--------| tap5 | <--> QEMU XENIX 386 | |
# | +--------+ | |
# | | |
# | +--------+ | |
# +--------| tap6 | <--> QEMU HPUX 10.20/HP parisc | |
# +--------+ | |
# | | |
# | +--------+ | |
# +--------| tap7 | <--> Future Emulator | |
# +--------+ | |
# | | |
# | +--------+ | |
# +--------| tap8 | <--> Future Emulator | |
# +--------+ | |
# | | |
# | +--------+ | |
# +--------| tap9 | <--> Future Emulator | |
# +--------+ | |
# | |
# --- | |
# /boot/loader.conf needs: | |
# if_bridge_load="YES" | |
# if_tap_load="YES" | |
# kqemu_load="YES" | |
# vboxdrv_load="YES" | |
# | |
# -- | |
# /etc/rc.conf needs: | |
# kqemu_enable="YES" | |
# vboxnet_enable="YES" | |
# | |
# --- | |
# Example usage of tap2 interface from QEMU (SliTaz Linux virtual machine): | |
# qemu-system-x86_64 -m 1024 -hda slitaz.qcow2.4GB.disk -boot c -net nic -net tap,ifname=tap2,script=no -nographic -vnc :0 | |
# | |
# --- | |
# Example usage of VDE switch in Oracle VirtualBox compiled with VDE support: | |
# vboxmanage modifyvm TrueOS --nic1 generic | |
# vboxmanage modifyvm TrueOS --nicgenericdrv1 VDE | |
# vboxmanage modifyvm TrueOS --nicproperty1 network=/tmp/vde-ip.ctl | |
# | |
# --- | |
# Supratim Sanyal | |
# supratim at riseup dot net | |
# http://tuklusan.decsystem.org/ | |
# ------------------------------ | |
ifconfig tap0 create | |
chmod 0666 /dev/tap0 | |
ifconfig tap0 10.42.2.252/24 promisc up | |
ifconfig tap1 create | |
chmod 0666 /dev/tap1 | |
ifconfig tap1 0.0.0.0 promisc up | |
/usr/local/bin/vde_switch -t tap0 -s /tmp/vde-ip.ctl -m 666 --mgmt /tmp/vde-ip.mgmt --mgmtmode 666 --daemon --fstp | |
/usr/local/bin/vde_plug2tap -s /tmp/vde-ip.ctl -m 666 -d tap1 | |
sysctl net.link.tap.user_open=1 | |
sysctl net.link.tap.up_on_open=1 | |
# --- | |
# Now create a bridge, and bridge vdeplug "tap1" to additional "tap2" ... "tapx" interfaces for | |
# qemu or other emulators that use tap | |
# --- | |
ifconfig tap2 create | |
ifconfig tap3 create | |
ifconfig tap4 create | |
ifconfig tap5 create | |
ifconfig tap6 create | |
ifconfig tap7 create | |
ifconfig tap8 create | |
ifconfig tap9 create | |
chmod 0666 /dev/tap2 | |
chmod 0666 /dev/tap3 | |
chmod 0666 /dev/tap4 | |
chmod 0666 /dev/tap5 | |
chmod 0666 /dev/tap6 | |
chmod 0666 /dev/tap7 | |
chmod 0666 /dev/tap8 | |
chmod 0666 /dev/tap9 | |
ifconfig tap2 0.0.0.0 promisc up | |
ifconfig tap3 0.0.0.0 promisc up | |
ifconfig tap4 0.0.0.0 promisc up | |
ifconfig tap5 0.0.0.0 promisc up | |
ifconfig tap6 0.0.0.0 promisc up | |
ifconfig tap7 0.0.0.0 promisc up | |
ifconfig tap8 0.0.0.0 promisc up | |
ifconfig tap9 0.0.0.0 promisc up | |
ifconfig bridge0 create | |
ifconfig bridge0 addm tap1 up | |
ifconfig bridge0 addm tap2 | |
ifconfig bridge0 addm tap3 | |
ifconfig bridge0 addm tap4 | |
ifconfig bridge0 addm tap5 | |
ifconfig bridge0 addm tap6 | |
ifconfig bridge0 addm tap7 | |
ifconfig bridge0 addm tap8 | |
ifconfig bridge0 addm tap9 | |
sync;sync;sync | |
# EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment