From 2f30196609c9ef1c7e0b03fc0f6a7a60c0c5526e Mon Sep 17 00:00:00 2001 From: Silvino Silva Date: Sun, 25 Sep 2016 01:03:53 +0100 Subject: network revision --- tools/qemu.html | 70 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 34 deletions(-) (limited to 'tools/qemu.html') diff --git a/tools/qemu.html b/tools/qemu.html index ce1b66d..8c53ce7 100644 --- a/tools/qemu.html +++ b/tools/qemu.html @@ -97,45 +97,53 @@
The VDE networking backend.
- -

2.1. Tap interfaces

-
         KERNEL=="tun", GROUP="kvm", MODE="0660", OPTIONS+="static_node=net/tun"
         
-

Automatic creation of tap interface with - correct permissions set for user and group, - you can set only user or group;

-
-        # tunctl -u username -g kvm -t tap0
-        
+

2.1. Public Bridge

-

Set permissions to existing tap interface;

+

Create bridge, create new + tap and add it to bridge;

-        # tunctl -u username -t tap0
+        # DEV="br0"
+        # TAP="tap5"
         
- -

Manual creation of tap interface;

+
+        # ip tuntap add ${TAP} mode tap group kvm
+        # ip link set ${TAP} up
+        
-        # ip tuntap add name tap0 mode tap
-        # chmod 0666 /dev/tap0
-        # chown root:username /dev/tap0
+        # ip link set ${TAP} master ${DEV}
         
+

See scripts/system-qemu.sh, + as template. Run virtual machine that uses above tap device;

+
-        # ip addr add 10.0.2.1/24 dev tap0
-        # ip link set dev tap0 up
-        # ip link show
+        $ ISO=~/crux-3.2.iso
+        $ IMG=~/crux-img.qcow2
+
+        $ qemu-system-x86_64 \
+            -enable-kvm \
+            -m 1024 \
+            -boot d \
+            -cdrom ${ISO} \
+            -hda ${IMG} \
+            -net nic,model=virtio -net tap,ifname=${TAP},script=no,downscript=no
         
+

2.2. Routing

+ +

Create interface with correct permissions set for kvm group.

+
         # sysctl -w net.ipv4.ip_forward=1
-        # iptables -t nat -A POSTROUTING -s 10.0.2.0/24 -o eth0 -j MASQUERADE
+        # iptables -t nat -A POSTROUTING -s 10.0.0.0/24 -o eth0 -j MASQUERADE
         

Guest System

@@ -143,22 +151,16 @@

Start qemu with 512 of ram, mydisk.img as disk and boot from iso

-        $ qemu-system-x86_64 \
-        -enable-kvm \
-        -m 512 \
-        -boot d -cdrom image.iso \
-        -hda mydisk.img
-        
+ $ ISO=~/crux-3.2.iso + $ IMG=~/crux-img.qcow2 -

Start qemu with 1024 of ram, network configured using tap0 - interface device no host and boot from crux.qcow2;

- -
         $ qemu-system-x86_64 \
-        -enable-kvm \
-        -m 1024 \
-        -hda c9/local/crux.qcow2 \
-        -net nic,model=virtio -net tap,ifname=tap0,script=no,downscript=no
+            -enable-kvm \
+            -m 1024 \
+            -boot d \
+            -cdrom ${ISO} \
+            -hda ${IMG} \
+            -net nic,model=virtio -net tap,ifname=${TAP},script=no,downscript=no
         
Tools Index -- cgit