Created
June 13, 2017 14:22
-
-
Save batonius/886317dabca284cc4be2ea0c6cdcd5c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/mk/qemu.mk b/mk/qemu.mk | |
index a76d9f9..4ab960b 100644 | |
--- a/mk/qemu.mk | |
+++ b/mk/qemu.mk | |
@@ -8,6 +8,8 @@ else | |
endif | |
ifeq ($(net),no) | |
QEMUFLAGS+=-net none | |
+else ifeq ($(net), bridge) | |
+ QEMUFLAGS+=-net nic,model=e1000 -net bridge,br=br0 -net dump,file=build/network.pcap | |
else | |
QEMUFLAGS+=-net nic,model=e1000 -net user -net dump,file=build/network.pcap | |
ifeq ($(net),redir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
ip link add br0 type bridge | |
ip addr add 10.0.2.20/24 dev br0 | |
ip link set br0 up | |
mkdir -p /etc/qemu/ | |
echo "allow br0" > /etc/qemu/bridge.conf | |
#optional: DHCP and DNS | |
dnsmasq --interface=br0 --bind-interfaces --dhcp-range=10.0.2.10,10.0.2.19 | |
#optional: NAT | |
sysctl -w net.ipv4.ip_forward=1 | |
sudo iptables -t nat -A POSTROUTING -o enp3s0 -j MASQUERADE | |
sudo iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT | |
sudo iptables -A FORWARD -i enp3s0 -o br0 -j ACCEPT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment