Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #
- # Scrict basic code was taken from http://en.wikibooks.org/wiki/QEMU/Networking and modified.
- # All copyrights belong to the original authors of the wikibooks article
- #
- # script to bring up the tun device in QEMU in bridged mode
- # first parameter is name of tap device (e.g. tap0)
- # second parameter is the name of the user that runs the script
- #
- #
- # Redistribution and use in source and binary forms, with or without
- # modification, are permitted provided that the following conditions are
- # met:
- #
- # * Redistributions of source code must retain the above copyright
- # notice, this list of conditions and the following disclaimer.
- # * Redistributions in binary form must reproduce the above
- # copyright notice, this list of conditions and the following disclaimer
- # in the documentation and/or other materials provided with the
- # distribution.
- # * Neither the name of the authors nor the names of its
- # contributors may be used to endorse or promote products derived from
- # this software without specific prior written permission.
- #
- # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- #
- echo "0/6. START QEMU NETWORK CONNECTION ----- ----- ----- ----- ----- START QEMU NETWORK CONNECTION"
- sbinPath=/usr/sbin
- #
- # First take eth0 down, then bring it up with IP 0.0.0.0
- #
- echo "1/6. First take eth0 down, then bring it up with IP 0.0.0.0 "
- ifconfig eth0 down
- ifconfig eth0 0.0.0.0 promisc up
- #
- # Bring up the tap device (name specified as first argument, by QEMU)
- #
- echo "2/6. Bring up the tap device $1 for the user $2"
- ${sbinPath}/openvpn --mktun --dev $1 --user $2
- ifconfig $1 0.0.0.0 promisc up
- #
- # create the bridge between eth0 and the tap device
- #
- echo "3/6. Create the bridge between eth0 and the tap device"
- ${sbinPath}/brctl addbr br0
- ${sbinPath}/brctl addif br0 eth0
- ${sbinPath}/brctl addif br0 $1
- #
- # only a single bridge so loops are not possible, turn off spanning tree protocol
- #
- echo "4/6. Only a single bridge so loops are not possible, turn off spanning tree protocol"
- ${sbinPath}/brctl stp br0 off
- #
- # Bring up the bridge with dhclient
- #
- echo "5/6. Bring up the bridge with dhclient (this may take a few seconds..)"
- #dhclient -r br0
- dhclient br0
- #
- # stop firewall - comment this out if you don't use Firestarter ... disabled
- #
- #/sbin/service firestarter stop
- echo "6/6. FINISHED ----- ----- ----- ----- ----- ----- ----- ----- FINISHED"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement