I created simple
bash scripts for all the below steps and then executed them from the terminal:-
hostOS: Create a
tapdevice and allow permission to the user, set the device up, assign a
manual ip addressto be used by the
guestOS (in my case, it is
192.168.1.2), and forward the ARP proxy to the tap device.
#!/bin/sh sudo ip tuntap add dev tap0 mode tap user raihan group wheel sudo chown root.raihan /dev/net/tun sudo ip link set dev tap0 up sudo ip route add 192.168.1.2 dev tap0 sudo sysctl net.ipv4.conf.tap0.proxy_arp=1 net.ipv4.conf.wlp2s0.proxy_arp=1 net.ipv4.ip_forward=1 #sudo sysctl net.ipv4.ip_forward=1 net.ipv6.conf.default.forwarding=1 net.ipv6.conf.all.forwarding=1
guestOS: Add the manual address that has previously been created in the
hostOS, and then add the
IP addressof the
host's WLAN cardas a default gateway to the
guestOS, add the
/etcdirectory, and ping google to see if it succeeds.
#!/bin/sh sudo ifconfig em0 192.168.1.2 sudo route add default 192.168.1.6 #(which would be the IP address of the host's wlan card) echo 'nameserver 192.168.1.1' >> /etc/resolv.conf ping -c 3 www.google.com
hostOS: Set the firewall up for safety purposes.
#!/bin/sh # Allow all outgoing traffic from the guest to the LAN or internet. sudo iptables -A FORWARD -i tap0 -o wlp2s0 -j ACCEPT
Qemu/KVMhas finished, do not forget to set the loaded
tapdevice down and delete it from the
#!/bin/sh sudo ip route flush dev tap0 sudo sysctl net.ipv4.conf.tap0.proxy_arp=0 net.ipv4.conf.wlp2s0.proxy_arp=0 net.ipv4.ip_forward=0 #sudo sysctl net.ipv4.ip_forward=0 net.ipv6.conf.default.forwarding=0 net.ipv6.conf.all.forwarding=0 sudo ip link set dev tap0 down sudo ip link del dev tap0 sudo ip tuntap del dev tap0 mode tap