#!/bin/bash # Set to the name of your tap device TAP=tap0 # Network information NETWORK=192.168.99.0 NETMASK=255.255.255.0 GATEWAY=192.168.99.1 DHCPRANGE=192.168.99.2,192.168.99.10 check_tap() { if ip link show | grep $TAP > /dev/null; then return else exit 1 fi } enable_ip_forward() { echo 1 | dd of=/proc/sys/net/ipv4/ip_forward > /dev/null } start_dnsmasq(){ dnsmasq \ --strict-order \ --interface=$TAP \ --listen-address=$GATEWAY \ --bind-interfaces \ --dhcp-range=$DHCPRANGE \ --dhcp-no-override \ --pid-file=/var/run/qemu-dnsmasq-$TAP.pid } add_iptable_rules() { iptables-restore -n <