forked from tomx4096/baremetal-lwip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqemu-ifup
executable file
·50 lines (42 loc) · 1.01 KB
/
qemu-ifup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
#
# script to bring up the tun device in QEMU in bridged mode
# first parameter is name of tap device (e.g. tap0)
#
# some constants specific to the local host ? change to suit your host
#
ETHNAME='eth0'
ETH0IP=10.0.2.15
NETMASK=255.255.0.0
BROADCAST=10.0.2.255
GATEWAY=10.0.2.2
#
# First take eth0 down, then bring it up with IP 0.0.0.0
#
ifconfig $ETHNAME down
ifconfig $ETHNAME 0.0.0.0 promisc up
#
# Bring up the tap device (name specified as first argument, by QEMU)
#
openvpn --mktun --dev $1 -user 'id -un'
ifconfig $1 0.0.0.0 promisc up
#
# create the bridge between eth0 and the tap device
#
brctl addbr br0
brctl addif br0 $ETHNAME
brctl addif br0 $1
#
# only a single bridge so loops are not possible, turn off spanning
# tree protocol
#
brctl stp br0 off
#
# Bring up the bridge with ETH0IP and add the default route
#
ifconfig br0 $ETH0IP netmask $NETMASK broadcast $BROADCAST
route add default gw $GATEWAY
#
# stop firewall ? comment this out if you don't use Firestarter
#
#service firestarter stop