Version 8 (modified by adherelinux, 13 years ago) (diff) |
---|
qemu-pxe
系統:Ubuntu10.10-i386 硬體:Dell OPTIPLEX 980
這邊我們引用Stan http://superstanwu.blog.ithome.com.tw/post/775/76131
利用指令檢查cpu是否支援,目前的機器幾乎都有支援
egrep '(vmx|svm)' --color=always /proc/cpuinfo
應該要出現vmx字眼
安裝qemu,uml-utilities是為了模擬虛擬網路(tun)及虛擬網卡(tap)
sudo apt-get install vde2 uml-utilities
安裝dhcp server,tftp server 是為了PXE伺服器
sudo apt-get install dhcp3-server tftpd-hpa
下載PXE的韌體
cd /usr/share/qemu wget -O pxe-ne2k_pci.bin http://svn.savannah.gnu.org/viewvc/*checkout*/trunk/pc-bios/pxe-ne2k_pci.bin?root=qemu wget -O pxe-rtl8139.bin http://svn.savannah.gnu.org/viewvc/*checkout*/trunk/pc-bios/pxe-rtl8139.bin?root=qemu wget -O pxe-e1000.bin http://svn.savannah.gnu.org/viewvc/*checkout*/trunk/pc-bios/pxe-e1000.bin?root=qemu
增加虛擬網卡tap0,並且啟動
sudo chmod 666 /dev/net/tun sudo tunctl -u vm1(我的使用者) -t tp0 sudo ifconfig tap0 10.0.0.1 up
檢查tap0是否啟動起來
sudo ifconfig -a
下載網路開機設定檔Ubuntu10.10如下
cd wget http://archive.ubuntu.com/ubuntu/dists/maverick/main/installer-i386/current/images/netboot/netboot.tar.gz .
下載網路開機設定檔Debian如下
cd
把下載的檔案複製並且解壓縮到/var/lib/tftpboot目錄裡。
sudo tar zxvf netboot.tar.gz /var/lib/tftpboot/
設定dhcp server,讓dhcp只指定到tap0
cd /etc/default sudo emacs dhcp3-server 修改內容如下 INTERFACES="tap0"
設定 dhcpd.conf
cd /etc/dhcp3 sudo emacs dhcpd.conf 修改內容如下 subnet 10.0.0.0 netmask 255.255.255.0 { range 10.0.0.10 10.0.0.200; option routers 10.0.0.1; next-server 10.0.0.1; filename "pxelinux.0"; }
重新啟動tftp,dhcp
sudo /etc/init.d/dhcp3-server start sudo /etc/init.d/tftpd-hpa start
啟動NA讓tap0上的封包轉發到eth0
sudo bash -c 'echo 1 > /proc/sys/net/ipv4/ip_forward' iptables -F iptables -X iptables -t nat -F iptables -t nat -X iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT iptables -t nat -A POSTROUTING -o eth0 -s 10.0.0.0/24 -j MASQUERADE iptables -L
利用qemu指令作網路開機
qemu -boot n -option-rom /usr/share/qemu/pxe-ne2k_pci.bin -m 512 -net nic -net tap,ifname=tap0,script=no
Attachments (4)
- Ubuntu網路開機1.jpg (20.6 KB) - added by adherelinux 13 years ago.
- Ubuntu網路開機2.jpg (40.9 KB) - added by adherelinux 13 years ago.
- Debian網路開機1.jpg (19.1 KB) - added by adherelinux 13 years ago.
- Debian網路開機2.jpg (23.9 KB) - added by adherelinux 13 years ago.
Download all attachments as: .zip