Skip to content

Instantly share code, notes, and snippets.

@lpohl
Created June 11, 2012 18:10
Show Gist options
  • Save lpohl/2911688 to your computer and use it in GitHub Desktop.
Save lpohl/2911688 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Sample /etc/qemu-ifup to have bridged networking between qemu instances and your real net
# You need "youruser ALL=(root) NOPASSWD: /etc/qemu-ifup" in /etc/sudoers
# You also need enough rights on /dev/tun
BRIDGE=br0
if [ -z "$1" ]; then
exit 1
fi
if [ $UID -ne 0 ]
then
sudo $0 $1
exit
fi
/sbin/ifconfig $1 promisc 0.0.0.0 >/dev/null 2>&1
#if ! /sbin/ifconfig $BRIDGE
#then
# /sbin/brctl addbr $BRIDGE
# /sbin/brctl addif $BRIDGE eth0
# /sbin/ifconfig $BRIDGE up
# addr=`/sbin/ip addr | grep eth0 | grep inet | sed -e 's/eth0/dev $BRIDGE/' -e s/inet//`
# /sbin/ip addr add $addr
#fi
/sbin/brctl addif $BRIDGE $1
/sbin/brctl stp $BRIDGE off
/sbin/brctl setfd $BRIDGE 1
/sbin/brctl sethello $BRIDGE 1
#/sbin/ip route | grep eth0 | while read route
#do
#newroute=`echo $route | sed s/eth0/$BRIDGE/ `
#/sbin/ip route del $route
#/sbin/ip route add $newroute
#done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment