Skip to content

Instantly share code, notes, and snippets.

@dezren39
Forked from truthadjustr/qemu_setup.sh
Created November 8, 2024 07:12
Show Gist options
  • Save dezren39/02a0b44d63022ed17f3fbc0c76479c8c to your computer and use it in GitHub Desktop.
Save dezren39/02a0b44d63022ed17f3fbc0c76479c8c to your computer and use it in GitHub Desktop.
nixos qemu networking
#!/bin/sh
#
tunctl -u dx -t tap0
ifconfig tap0 102.168.100.1 up
# qemu-kvm -hda nixos-disc.img -m 1024 -net nic -net tap,ifname=tap0,script=no
# *** Inside the Qemu guest ***
# ip addr set 192.168.100.2 dev ens3
# route add default gw 192.168.100.1
# echo 'nameserver 8.8.8.8' >> /etc/resolv.conf
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o wlp0s3 -j MASQUERADE
iptables -I FORWARD 1 -i tap0 -j ACCEPT
iptables -I FORWARD 1 -o tap0 -m state --state RELATED,ESTABLISHED -j ACCEPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment