跳到主要內容

發表文章

目前顯示的是 2016的文章

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

利用 Bokeh + Python 速成網頁統計圖

最近剛好有需求在想要如何將透過 rest api get 回來的資料做成統計表 原本想從 Chrome plugin 找,不過似乎沒找到相關的工具 無意間發現這個 Bokeh 是個可以速成又簡單的工具 只要幾行 code ,就能畫出各種統計圖 <measurement> <server> 192.168.10.240 </server> <cpu> 0 </cpu> <memory> 75 </memory> </measurement> <measurement> <server> 192.168.10.131 </server> <cpu> 5 </cpu> <memory> 91 </memory> 原本透過 rest api get 的資料,在 Chrome 只能如上這樣顯示,看起來十分不清楚 經過處理後,可以直接輸出成 html ,並且顯示精美的統計圖 讓 web 前後端都沒碰過的我,也能夠方便的在 html 上產生這種統計圖 參考網址: Bokeh 官網 http://bokeh.pydata.org/en/latest/ Python 上前端!利用 Bokeh 與 Python 製作網頁互動視覺化 http://blog.infographics.tw/2016/04/interactive-visualization-with-bokeh-and-python/

iptables, iproute2 與 OVS 常用指令

iptables -t nat -A POSTROUTING -s DUT_IP/mask -o eth0 -j MASQUERADE 顯示+行號: sudo iptables -L --line-numbers -t nat 刪除: sudo iptables -t nat -D POSTROUTING 1 把 eth0 up ip link set dev eth0 up 列出與 controller 的狀態 ovs-vsctl list controller 看 switch 上的 port ovs-vsctl show 看 switch 上的 protocol ovs-vsctl get bridge ovs-br protocols 用 netcast 送 udp nc -u host.example.com 53 < /dev/random

新生兒保單

最近在研究新生兒保單,網路上大多建議使用所謂的罐頭保單,而不是僅僅在一家做到完 好處是 範圍廣,便宜,理賠金額也較高 罐頭保單就是從各家保險公司,依照保險應該的方針去挑選好的保單,另外保證續保也是一項重要的考量,保險公司就不會改保單內容 推薦 Mobile01 的文章 [心得] 2016年各家保險公司規劃新生兒罐頭保單 待續...

新生兒保單

最近在研究新生兒保單,網路上大多建議使用所謂的罐頭保單,而不是僅僅在一家做到完 好處是 範圍廣,便宜,理賠金額也較高 罐頭保單就是從各家保險公司,依照保險應該的方針去挑選好的保單,另外保證續保也是一項重要的考量,保險公司就不會改保單內容 推薦 Mobile01 的文章 [心得] 2016年各家保險公司規劃新生兒罐頭保單 待續...

USB 開機做 BIOS 更新,遇到 Bootmgr Missing 的錯誤

今天將公司的老主機 Dell OptiPlex 170L 更新一下 BIOS 想說看能否開啟 Intel P4 CPU 64bit 的功能 中間遇到了一些問題,因此來記錄一下 主機目前是跑 Ubuntu,但是 Dell 官網 BIOS 只有提供 .EXE 的安裝方式 參考了官網建議的方式: 使用 UNetbootin + FreeDOS 來製作開機 USB Disk 但是卻一直遇到 Bootmgr Missing 的問題 試了幾次才發現,原來是我 USB Disk 格式的問題 重新格式化成 FAT32 就可以成功 Boot 了 可惜的是 CPU 還是無法支援 64-bit 明明官網的 Instruction Set 是寫 64-bit 為什麼無法用 64-bit 啊啊啊啊啊 Link -->  非 windows 主機更新 BIOS 更新教學 in Dell 官網 Link -->  OptiPlex 170L BIOS A09 Link -->  Intel CPU Pentium 4 516 SL8J9 官網

Shadowsocks Reference

Shadowsocks 的維基百科 http://shadowsocks.blogspot.tw https://www.zxc.so/shadowsocks-ladder.html https://ericfu.me/fight-with-greatwall-conclusion/ 科学上网三大神器--shadowsocks、Lantern、Psiphon

Python send multicast udp from specific interface

import socket MCAST_GRP = '224.1.1.2' MCAST_PORT = 5007 sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP) sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, 2) # specific interface ip and bind to socket sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF, socket.inet_aton("192.168.20.1")) sock.sendto("this is message", (MCAST_GRP, MCAST_PORT)) ==== RAW , IGMP import socket s = socket.socket(socket.AF_PACKET, socket.SOCK_RAW, 0x8100) s.bind(('VLAN1', 0x8100)) res='' temp='01 00 5E 00 43 67 00 02 B3 C8 7F 44 81 00 00 01 08 00 46 00 00 20 00 01 00 00 01 02 36 4C C0 A8 0a 7b EA 00 43 67 94 04 00 00 16 00 BC 97 EA 00 43 67' for i in temp.split(' '): res+=chr(int(i, 16)) s.send(res)

Ansible 學習筆記

按照範例操作中 ## 安裝 ansible sudo apt-get install ansible ## Inventory, default 是 /etc/ansible/hosts ## 把所有 hosts 的 ip address 寫到 Inventory ## host 之後可以加一下 ansible-user 之類的參數來做變化 vim /etc/ansible/hosts ## 產生 ssh key,並且複製 Public key 到 ~/.ssh/authorized_keys ssh-keygen ssh-agent bash ssh-add ~/.ssh/id_rsa cp ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys ## 把 public key 寫入其他的 remote host,所有 hosts 都要做 cat ~/.ssh/id_rsa.pub | ssh user@hostname 'cat >> .ssh/authorized_keys' sudo chmod 700 ~/.ssh/ sudo chmod 600 ~/.ssh/* ## ping 測試,成功的話就表示 hosts 之間可以連通了,如下面的樣子 ## 加 -vvvv 可以印出 debug message ansible all -m ping 192.168.1.131 | success >> { "changed": false, "ping": "pong" } 192.168.1.254 | success >> { "changed": false, "ping": "pong" } Playboo...