Skip to content

Instantly share code, notes, and snippets.

@truthadjustr
Created September 18, 2018 06:31
Show Gist options
  • Save truthadjustr/a4caf38c08ee9dbf1a7f60a5ea8228b8 to your computer and use it in GitHub Desktop.
Save truthadjustr/a4caf38c08ee9dbf1a7f60a5ea8228b8 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