bersama catatan peribadi & teknikalnya.

#Tapdevice

Network Sharing for Qemu via WiFi
How To Set It Up with Tap Device

This is only applicable for BSD-based operating systems as Guest OSs.

I created simple bash scripts for all the below steps and then executed them from the terminal:-

    From Host OS:

  1. Create a tap device and allow permission to the user, set the device up, assign a manual ip address to be used by the guest OS (in my case, it is 192.168.0.50), and forward the ARP proxy to the tap device.
    #!/usr/bin/env zsh
    
    # Add a new TAP (network tap) devices in TAP mode
    sudo ip tuntap add dev tap0 mode tap
    
    # Bring up the tap device, making it active
    sudo ip link set dev tap0 up
    
    # Add a route to the assigned IP address
    sudo ip route add 192.168.0.100 dev tap0
  2. Set up the firewall. Please refer to the UFW configuration from one of my latest posts as provided in the "Lihat juga:" section below.

  3. In Guest OS:

  4. Add the manual address that has previously been created in the host OS, and then add the IP address of the host's WLAN card as a default gateway to the guest OS, add the nameserver to resolv.conf file in /etc directory, and ping google to see if it succeeds.
    #!/usr/bin/env bash 
    
    # Add the assigned IP address for the VM
    sudo ifconfig vtnet0 192.168.0.100/24
    
    # Add the host IP address as the gateway 
    sudo route add default 192.168.0.50
    
    # Add a DNS server and ping any web address
    echo 'nameserver 8.8.8.8' >> /etc/resolv.conf
    ping -c3 google.com
  5. For an automatic connection on boot, comment out the ifconfig_DEFAULT line and add the following entries in the /etc/rc.conf file.
    #ifconfig_DEFAULT="DHCP inet6 accept_rtadv"
    ifconfig_vtnet0="inet 192.168.0.100 netmask 255.255.255.0"
    defaultrouter="192.168.0.50"
    sshd_enable="YES"


Top