-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkvm-networking
executable file
·60 lines (49 loc) · 1.01 KB
/
kvm-networking
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
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
#
# Setups up a proxy aRP bridge to wlan0
#
#
# Note this will need to be chnaged to your user
KVM_USER=ewhite
kvm_if_up() {
tunctl -u $KVM_USER -t tap0
sysctl net.ipv4.ip_forward=1
sysctl net.ipv4.conf.wlan0.proxy_arp=1
sysctl net.ipv4.conf.tap0.proxy_arp=1
ip link set dev tap0 up
if [ -z ${KVM_IP_STATIC} ]; then
echo "No route to guest configured!"
echo "***"
echo "Add one using:"
echo " sudo route add <IP> dev tap0"
echo "***"
else
echo "Setting up a route to guest: ${KVM_IP_STATIC}"
route add -host ${KVM_IP_STATIC} dev tap0
fi
route -n
}
kvm_if_dn() {
sysctl net.ipv4.ip_forward=0
sysctl net.ipv4.conf.wlan0.proxy_arp=0
sysctl net.ipv4.conf.tap0.proxy_arp=0
ip link set dev tap0 down
tunctl -d tap0
}
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
else
case "$1" in
start)
kvm_if_up
;;
stop)
kvm_if_dn
;;
*)
echo "Usage: $0 {start|stop}"
;;
esac
fi
exit 0