-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathrun-crosvm-net.sh
More file actions
35 lines (30 loc) · 1.51 KB
/
Copy pathrun-crosvm-net.sh
File metadata and controls
35 lines (30 loc) · 1.51 KB
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
#!/system/bin/sh
cd /data/local/tmp
ifname=crosvm_tap
if [ ! -d /sys/class/net/$ifname ]; then
ip tuntap add mode tap vnet_hdr $ifname
ip addr add 192.168.8.1/24 dev $ifname
ip link set $ifname up
ip r a table wlan0 192.168.8.0/24 via 192.168.8.1 dev $ifname
iptables -D INPUT -j ACCEPT -i $ifname
iptables -D OUTPUT -j ACCEPT -o $ifname
iptables -I INPUT -j ACCEPT -i $ifname
iptables -I OUTPUT -j ACCEPT -o $ifname
iptables -t nat -D POSTROUTING -j MASQUERADE -o wlan0 -s 192.168.8.0/24
iptables -t nat -I POSTROUTING -j MASQUERADE -o wlan0 -s 192.168.8.0/24
sysctl -w net.ipv4.ip_forward=1
ip rule add from all fwmark 0/0x1ffff iif wlan0 lookup wlan0
ip rule add iif $ifname lookup wlan0
iptables -j ACCEPT -D FORWARD -i $ifname -o wlan0
iptables -j ACCEPT -D FORWARD -m state --state ESTABLISHED,RELATED -i wlan0 -o $ifname
iptables -j ACCEPT -D FORWARD -m state --state ESTABLISHED,RELATED -o wlan0 -i $ifname
iptables -j ACCEPT -I FORWARD -i $ifname -o wlan0
iptables -j ACCEPT -I FORWARD -m state --state ESTABLISHED,RELATED -i wlan0 -o $ifname
iptables -j ACCEPT -I FORWARD -m state --state ESTABLISHED,RELATED -o wlan0 -i $ifname
fi
ulimit -l unlimited
LD_PRELOAD=./libbinder_ndk.so:./libbinder.so /data/local/tmp/crosvm-a16 --log-level debug run \
--disable-sandbox --no-balloon --protected-vm-without-firmware --swiotlb 64 \
--params 'root=/dev/vda' --mem 4096 --cpus 4 \
--net tap-name=$ifname \
--rwdisk root_part /data/local/tmp/kernel