#!/bin/sh # # Copyright IBM, Corp. 2010 # # Authors: # Anthony Liguori # # This work is licensed under the terms of the GNU GPL, version 2. See # the COPYING file in the top-level directory. # TODO's: # Please make sure to install bridge-utils before using this script # Please make also sure that you added 'allow br0' to your etc/qemu/bridge.conf # Set to the name of your bridge BRIDGE=br0 # Network information NETWORK=10.0.0.0 NETMASK=255.255.255.0 GATEWAY=10.0.0.1 # Optionally parameters to enable PXE support TFTPROOT= BOOTP= do_brctl() { brctl "$@" } do_ifconfig() { ifconfig "$@" } do_dd() { dd "$@" } do_iptables_restore() { iptables-restore "$@" } do_dnsmasq() { dnsmasq "$@" } check_bridge() { if do_brctl show | grep "^$1" > /dev/null 2> /dev/null; then return 1 else return 0 fi } create_bridge() { do_brctl addbr "$1" do_brctl stp "$1" off do_brctl setfd "$1" 0 do_ifconfig "$1" "$GATEWAY" netmask "$NETMASK" up } enable_ip_forward() { echo 1 | do_dd of=/proc/sys/net/ipv4/ip_forward > /dev/null } add_filter_rules() { do_iptables_restore <