跳到主要內容

發表文章

Vim 新手筆記

一直以來都是用 sublime text,不過開發時偶爾還是會有需要用到 vim 的時候,無意間發現這兩個東西 對於想進一步使用 vim 的新手,通常都會上網隨便找一些人家分享的 .vimrc 的檔案來套用,推薦可以直接用這個作者提供功能 https://github.com/tpope/vim-sensible 另外像 Sublime, VS Code, ATOM  都有的 packages search/installation,也有人做出這種功能, https://github.com/junegunn/vim-plug 照著安裝就可以有方便的套件安裝工具了

openstack nfs volume attach 筆記

在操作 openstack NFS volume 時,遇到較多的問題都在於 permission case 1: 當要 attach volume 到 instance 時,遇到 ERROR Device is busy 從 compute node 上的 nova log 看到這些錯誤訊息 2017-01-03 14:25:44.550 46261 ERROR nova.virt.block_device [instance: 35bedaff-07a9-41d7-bdfa-930fc569cdef]   File "/openstack/venvs/nova-13.3.10/lib/python2.7/site-packages/nova/virt/libvirt/driver.py", line 1355, in attach_volume 2017-01-03 14:25:44.550 46261 ERROR nova.virt.block_device [instance: 35bedaff-07a9-41d7-bdfa-930fc569cdef]     raise exception.DeviceIsBusy(device=disk_dev) 2017-01-03 14:25:44.550 46261 ERROR nova.virt.block_device [instance: 35bedaff-07a9-41d7-bdfa-930fc569cdef] DeviceIsBusy: The supplied device (vdb) is busy. 解決方式: 先把 instance shutdown 就可以 attach 了 case 2: 當 attach volume 完成後,要 start instance 發生的 ERROR qemu-system-x86_64: -drive file=/var/lib/nova/mnt/6d38f8c2da18e2e39ce88cca0f73414a/volume-947f95f1-d90b-41a2-b9ce-c3b03ad1dcdd,if=none,id=drive-virtio-disk1,format=raw,serial=947f95f1-d90...

用 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...

Linux Traffic Control 讀書筆記

http://linux-ip.net/articles/Traffic-Control-HOWTO/components.html 4.1.  qdisc For traffic accepted on an interface, the  ingress  qdisc is traversed. With its limited utility, it allows no child  class  to be created, and only exists as an object onto which a  filter  can be attached. For practical purposes, the  ingress  qdisc is merely a convenient object onto which to attach a  policer  to limit the amount of traffic accepted on a network interface. In short, you can do much more with an egress qdisc because it contains a real qdisc and the full power of the traffic control system. An  ingress  qdisc can only support a policer. The remainder of the documentation will concern itself with traffic control structures attached to the  root  qdisc unless otherwise specified. 刪除 eth0 上的 filter sudo tc qdisc del dev eth0 root sudo tc qdisc del dev eth0 ingress tc filter show dev eth0 ingress tc...

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")