Wednesday, December 28, 2011

QEMU Networking

Summary:

{/etc/qemu-ifup}
#!/bin/sh
#switch=$(/sbin/ip route list | awk '/^default / { print $5 }') -- error/remove
switch=virbr0 -- correct
/sbin/ifconfig $1 0.0.0.0 up -- keep
/usr/sbin/brctl addif ${switch} $1 -- keep

{/etc/qemu-ifdown}
#!/bin/sh
#switch=$(/sbin/ip route list | awk '/^default / { print $5 }') -- error/remove
swtich=virbr0 -- correct
/usr/sbin/brctl delif $switch $1 -- keep
/sbin/ifconfig $1 0.0.0.0 down -- keep

add these parameters to qemu: -net nic,vlan=0 -net tap,vlan=0

Previous Writing:
Write 2 network scripts as below: ( don't forget the chmod +x on each file. )

[root@sitedesign ~]# cat /etc/qemu-ifdown
#!/bin/sh
/sbin/ifconfig virbr0 down
/sbin/ifconfig down $1
/sbin/ifup eth0

[root@sitedesign ~]# cat /etc/qemu-ifup
#!/bin/sh
/sbin/ifconfig $1 0.0.0.0 promisc up
/usr/sbin/brctl addif virbr0 $1

Then to start the VM:

as root:
#~> qemu-kvm -net nic,vlan=0 -net,tap,vlan=0 -hda winxp.img -hdb winxp_disk2.img -usb -usbdevice tablet -localtime -daemonize
That should start you up with a connection to the default virbr that gets made by fedora at boot time.

(original link)

2 comments:

  1. Thank you for sharing this kind of informative post i your content helped me alot apart that if anyone looking for best institute for Linux training so contact here +91- 9311002620 or visit https://htsindia.com/Courses/modular-courses/linux-training-institute

    ReplyDelete
  2. I really appreciate your information which you shared with us. If anyone who want to create his/her career in python So Contact Here-+91-9311002620 Or Visit our website https://www.htsindia.com/Courses/python/python-training-institute-in-delhi

    ReplyDelete