Skip to content

Instantly share code, notes, and snippets.

@frafra
Last active April 13, 2021 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frafra/05614928d8c40242a59c to your computer and use it in GitHub Desktop.
Save frafra/05614928d8c40242a59c to your computer and use it in GitHub Desktop.
Wifi connection over ethernet (Fedora setup)
export in_dev="eno1"
export out_dev="wlp0s20u7"
nmcli dev set ${in_dev} managed no
cat << EOF > /etc/dnsmasq.conf
# Only listen to routers' LAN NIC. Doing so opens up tcp/udp port 53 to
# localhost and udp port 67 to world:
interface=${in_dev}
# dnsmasq will open tcp/udp port 53 and udp port 67 to world to help with
# dynamic interfaces (assigning dynamic ips). Dnsmasq will discard world
# requests to them, but the paranoid might like to close them and let the
# kernel handle them:
bind-interfaces
# Dynamic range of IPs to make available to LAN pc
dhcp-range=192.168.1.2,192.168.1.5,24h
# If you’d like to have dnsmasq assign static IPs, bind the LAN computer's
# NIC MAC address:
#dhcp-host=aa:bb:cc:dd:ee:ff,192.168.111.50
EOF
sysctl net.ipv4.ip_forward=1
ifconfig ${in_dev} 192.168.1.1 up
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
iptables -t nat -A POSTROUTING -o ${out_dev} -j MASQUERADE
iptables -A FORWARD -i ${in_dev} -o ${out_dev} -j ACCEPT
iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
systemctl restart dnsmasq.service # dnf install dnsmasq
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment