跳到主要內容

用 qemu 讓虛擬機可以直接用實體網卡

手上的機器有 10Gb 以上的網卡,但是虛擬機的虛擬網卡只能模擬到 1Gb
為了讓虛擬機能用到 10Gb ,於是查到可以直接 Assign PCI device 給虛擬機使用
目前測試 qemu 是 ok 的,另外 CPU 也要有支援 VT-d 才行

# enable Intel IOMMU in kernel and BIOS MUST enable Virtualizaion
sudo vim /etc/default/grub
add "intel_iommu=on"
sudo update-grub
sudo reboot

# Create qcow image
qemu-img create -f qcow2 test.qcow 10G

# Download pciestub script from GitHub
wget https://raw.githubusercontent.com/smilejay/kvm-book/master/scripts/pcistub.sh
chomd u+x pcistub.sh



# use lspci to find PCIE address
sudo ./pcistub.sh -h <PCIE address>

# Install OS to VM
# e.q. sudo qemu-system-x86_64 -m 16384 -smp 8 -boot order=cd -hda ./test.qcow -cdrom ./ubuntu-16.04.iso -device pci-assign,host=84:00.0,id=mynic --enable-kvm -vnc :1
sudo qemu-system-x86_64 -m <memory in MB> -smp <number of CPU> -boot order=<1st boot device> -hda <first disk> -cdrom <ISO file of Ubuntu > -device pci-assign,host=<PCI Address>,id=<Custom Device Name> --enable-kvm -vnc :1


# Launch VM with Intel IOMMU in kernel and output in VNC
# e.q. sudo qemu-system-x86_64 -m 16384 -smp 8 -hda ./test.qcow -device pci-assign,host=84:00.0,id=mynic --enable-kvm -vnc :1
# vnc :1 means port 5901,  vnc :2 means port 5902, ...etc.
sudo qemu-system-x86_64 -m <memory in MB> -smp <number of CPU> -hda <first disk> -device pci-assign,host=<PCI Address>,id=<Custom Device Name> --enable-kvm -vnc :1

留言

這個網誌中的熱門文章

scapy + python 好用的封包產生器,快速生成 udp packet

範例:  往 192.168.10.10 打 udp packet , src ip 是 192.168.1.0 .. 遞增 1024,UDP dest port 是 8001~8010, UDP src port  是 10001 ~ 10010, payload 是 'hello world',packet 從 eth0 出去 import struct, socket from scapy.all import *  #在這邊用  all 速度會變慢一些 ip2int = lambda ipstr: struct.unpack('!I', socket.inet_aton(ipstr))[0] int2ip = lambda n: socket.inet_ntoa(struct.pack('!I', n)) src_ip_base="192.168.1.0" src_ip_list=[ int2ip(a+ip2int("192.168.1.0")) for a in range(1024)] payload='hello world' packet=Ether(dst="00:e0:4c:68:00:66",src="00:1e:8c:74:b9:47")/ \        IP(dst="192.168.10.10",src=src_ip_list)/ \        UDP(sport=[i+10001 for i in range(10)],dport=[i+8001 for i in range(10)])/ \        payload sendp(packet,iface="eth0")

windows 上 wireshark 抓不到剛插入的 USB 網卡

有時後會遇到新插入 USB 網卡後,打開 Wireshark 沒看到這張網卡 https://osqa-ask.wireshark.org/questions/12192/usb-to-ethernet-adapter-doesnt-show-under-interfaces 根據這篇 wireshark 官網的連結,這是 windows 上的限制,通常是要 reboot 才會出現新網卡 可以試試看文章中下方提到的步驟 net stop npf net start npf tshark -D

IPv6 Multicast Address 整理(草稿)

rfc 4291 Reserved Multicast Addresses:   FF0X::0 All Nodes Addresses:     FF01:0:0:0:0:0:0:1   FF02:0:0:0:0:0:0:1 All Routers Addresses:     FF01:0:0:0:0:0:0:2   FF02:0:0:0:0:0:0:2   FF05:0:0:0:0:0:0:2 Solicited-Node Address:   FF02:0:0:0:0:1:FFXX:XXXX    +--------+----+----+---------------------------------------------+    |   8    |  4 |  4 |                  112 bits                   |    +------ -+----+----+---------------------------------------------+    |11111111|flgs|scop|                  group ID                   |    +--------+----+----+---------------------------------------------+ flags:                   ...