Skip to content

Instantly share code, notes, and snippets.

@mykola2312
Created November 29, 2024 22:42
Show Gist options
  • Save mykola2312/f78de1e61bf826a9fb0ad50bc9134703 to your computer and use it in GitHub Desktop.
Save mykola2312/f78de1e61bf826a9fb0ad50bc9134703 to your computer and use it in GitHub Desktop.
Linux NAT networking for QEMU VMs
interface=vnet0
listen-address=10.1.0.1,127.0.0.1
dhcp-range=10.1.0.2,10.1.0.254,12h
dhcp-host=52:54:00:12:34:56,win7,10.1.0.2
dhcp-option=option:dns-server,8.8.8.8
# iptables-restore vnet0
*filter
-A FORWARD -o vnet0 -j ACCEPT
-A FORWARD -i vnet0 -j ACCEPT
COMMIT
*nat
-A POSTROUTING -o enp3s0f3u1 -s 10.1.0.0/24 -j SNAT --to 192.168.100.3
COMMIT
[NetDev]
Name=vnet0
Kind=bridge
[Match]
Name=vnet0
[Network]
DNS=8.8.8.8
Address=10.1.0.1/24
[Match]
Name=vnet0tap*
[Network]
Bridge=vnet0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment