#!/bin/bash . driglibash-base if [ "$#" -ne 2 ] ; then yell "Missing 2 parameters" die "Usage: $0 " fi root_or_die local_iface="$1" net_iface="$2" run sysctl net.ipv4.ip_forward=1 clean "sysctl net.ipv4.ip_forward=1" run nmcli device set "$local_iface" managed no clean "nmcli device set "$local_iface" managed yes" run ip a add 192.168.238.254/24 dev "$local_iface" clean "ip a del 192.168.238.254/24 dev $local_iface" # For dhcp offers run iptables -A OUTPUT -d 255.255.255.255/32 -j ACCEPT run iptables -A OUTPUT -d 192.168.238.0/24 -j ACCEPT run iptables -A INPUT -s 192.168.238.0/24 -j ACCEPT run iptables -A INPUT -s 255.255.255.255 -j ACCEPT run iptables -A INPUT -i "$local_iface" -j ACCEPT run iptables -t nat -A POSTROUTING -o "$net_iface" -j MASQUERADE run iptables -A FORWARD -i $net_iface -o $local_iface -m state --state RELATED,ESTABLISHED -j ACCEPT run iptables -A FORWARD -i $local_iface -o $net_iface -j ACCEPT run dnsmasq --dhcp-range=192.168.238.100,192.168.238.199,10m -d --server=9.9.9.9 --listen-address 192.168.238.254 --interface "$local_iface" -p0 clean