2018年8月30日 星期四

ubuntu 安裝完kubernetes後做apt-get update會出現錯誤

root@k8s02:~# sudo apt-get update
已有:1 http://tw.archive.ubuntu.com/ubuntu xenial InRelease
已有:2 http://tw.archive.ubuntu.com/ubuntu xenial-updates InRelease
已有:3 http://tw.archive.ubuntu.com/ubuntu xenial-backports InRelease
已有:4 https://download.docker.com/linux/ubuntu xenial InRelease
下載:6 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB]
已有:5 https://packages.cloud.google.com/apt kubernetes-xenial InRelease
取得 107 kB 用了 1s (68.6 kB/s)
正在讀取套件清單... 完成
N: Skipping acquire of configured file 'stable/binary-i386/Packages' as repository 'https://download.docker.com/linux/ubuntu xenial InRelease' doesn't support architecture 'i386'

解決方式:
root@k8s01:/etc/apt# vi /etc/apt/sources.list

deb https://download.docker.com/linux/ubuntu xenial stable
改成
deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable

玩Docker httpd image

1.下載ˇ官方httpd image
 #docker pull httpd
root@k8s02:/container/www1# docker pull httpd
root@k8s02:/container/www1# docker images
REPOSITORY                         TAG                 IMAGE ID            CREATED             SIZE
httpd                              latest              11426a19f1a2        4 weeks ago         178 MB

2.建立並啟動容器
root@k8s02:/container/www1/conf# docker run -p 80:80 -d httpd

3.檢查容器內相關檔案路徑
root@k8s02:/container/www1/conf# docker exec -ti b0659d224641 pwd
/usr/local/apache2

root@k8s02:/container/www1/conf# docker exec -ti b0659d224641 ls
bin  build  cgi-bin  conf  error  htdocs  icons  include  logs  modules

root@k8s02:/container/www1/conf# docker exec -ti b0659d224641 ls /usr/local/apache2/htdocs
index.html
容器中網頁存放在/usr/local/apache2/htdoc中

root@k8s02:/container/www1/conf# docker exec -ti b0659d224641 ls /usr/local/apache2/conf
extra  httpd.conf  magic  mime.types  original
apache設定檔httpd.conf存放在/usr/local/apache2/conf中

4.將相關檔案放在HOST上維護,在做移轉時較方便
在HOST上建立相關目錄

mkdir /container/www1/
mkdir /container/www1/web1
mkdir /container/www1/web2
mkdir /container/www1/web3
mkdir /container/www1/conf
mkdir /container/www1/logs

分別修改3個web的index.html
cd mkdir /container/www1/web1
vi index.html

Hello,web1



(web2 以及web3)

cd /container/www1/conf

將https container的httpd.conf 轉出到HOST上
root@k8s02:/container/www1/conf# docker exec -ti b0659d224641 cat /usr/local/apache2/conf/httpd.conf > httpd.conf


5.建立容器
建立並啟動第一個httpd容器,由HOST的8001port進入
docker run -p 8001:80 -d -v /container/www1/web1/:/usr/local/apache2/htdocs/ -v /container/www1/conf/httpd.conf:/usr/local/apache2/conf/httpd.conf -v /container/www1/logs/:/usr/local/apache2/logs/ --name web1 httpd

瀏覽器網址輸入http://10.88.1.134:8001,即會導到容器1的80 port
瀏覽器顯示Hello,web1

建立並啟動第二個httpd容器,由HOST的8002port進入
docker run -p 8002:80 -d -v /container/www1/web2/:/usr/local/apache2/htdocs/ -v /container/www1/conf/httpd.conf:/usr/local/apache2/conf/httpd.conf -v /container/www1/logs/:/usr/local/apache2/logs/ --name web2 httpd

瀏覽器網址輸入http://10.88.1.134:8002,即會導到容器2的80 port
瀏覽器顯示Hello,web2

建立並啟動第三個httpd容器,由HOST的8003port進入
docker run -p 8003:80 -d -v /container/www1/web3/:/usr/local/apache2/htdocs/ -v /container/www1/conf/httpd.conf:/usr/local/apache2/conf/httpd.conf -v /container/www1/logs/:/usr/local/apache2/logs/ --name web3 httpd

瀏覽器網址輸入http://10.88.1.134:8003,即會導到容器3的80 port
瀏覽器顯示Hello,web3


6.建立HAproxy
查出3個https容器的內部IP
root@k8s02:/container/haproxy17/conf# docker exec -it web1 ip a
ip為 172.17.0.2
root@k8s02:/container/haproxy17/conf# docker exec -it web2 ip a
ip為 172.17.0.3
root@k8s02:/container/haproxy17/conf# docker exec -it web3 ip a
ip為 172.17.0.4

haproxy.cfg設定檔會用到


mkdir /container/haproxy17
cd /container/haproxy17
vi Dockerfile

FROM haproxy:1.7
# 為了要把haproxy.cfg設定檔放在HOST方便修改,所以在容器中刪除原先設定檔再建一個設定檔連結到從HOST掛載的目錄上,建立容器時再將HOST存放haproxy.cfg的路徑掛載到容器中使用
RUN rm -f /usr/local/etc/haproxy/haproxy.cfg
RUN ln -s /usr/local/etc/haproxy/conf/haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg


mkdir conf
cd conf
vi haproxy.cfg

global
    daemon
    maxconn 4096
defaults
    mode http
    timeout connect 5000
    timeout client 5000
    timeout server 5000
frontend main
    bind *:80
    stats uri /haproxy?stats
    mode http
    balance roundrobin
    option httpclose
    option forwardfor
    server web1 172.17.0.2:80 check weight 1 maxconn 50
    server web2 172.17.0.3:80 check weight 1 maxconn 30
    server web1 172.17.0.4:80 check weight 1 maxconn 50
    option redispatch
    retries         3

建立haproxy image
root@k8s02:/container/haproxy17# docker build -t my-haproxy .

建立並啟用haproxy容器
root@k8s02:/container/haproxy17# docker run -d --name my-haproxy -p 80:80 my-haproxy

開啟瀏覽器輸入10.88.1.134,就會輪流顯示web1、web2、web3

查看haproxy status
http://10.88.1.134/haproxy?stats









2018年8月6日 星期一

windows 10 install mysql ODBC Driver 連接MySQL

1.到mysql網站下載並安裝Connector/ODBC
https://dev.mysql.com/downloads/connector/odbc/

2.使用Cortana search box 搜尋ODBC,並選擇 "設定ODBC資料來源(64位元)"

3.出現ODBC資料來源管理員畫面,選擇 "系統資料來源名稱"頁籤,按新增按紐。
4.選擇最新的驅動程式

5.設定mysql主機IP及資料庫帳密。

6.按test測試是否連線成功
7.完成

2018年7月3日 星期二

用python接收udp資訊

為了檢查是否有漏封包,寫了一支python程式接收UDP證券行情資訊,並拆解行情封包,監控並記錄接收到的資料

# -*- coding: utf-8 -*-
# 若要在程式中加入中文,需要加入上行
import sys
from socket import *
from datetime import *

multicast_group = sys.argv[1]
multicast_port  = int(sys.argv[2])
interface_ip    = '10.168.100.233'
f = open('tse001.txt', 'a')

s = socket(AF_INET, SOCK_DGRAM )
s.setsockopt(SOL_SOCKET,SO_REUSEADDR,1)  #要讓程式可以重複使用位址及port,必須設定此行`
s.bind((multicast_group, multicast_port ))
mreq = inet_aton(multicast_group) + inet_aton(interface_ip)
s.setsockopt(IPPROTO_IP, IP_ADD_MEMBERSHIP, str(mreq))

while 1:
    now = datetime.today()
    str1 = s.recv(1500)
    msg = now.strftime('%Y%m%d%H%M%S')
    m_2_1_1 = bin(ord(str1[1]))[2:].zfill(8)
    m_2_1_1a = chr(int("0b0011" + m_2_1_1[1:4].zfill(4),2))
    m_2_1_1b = chr(int("0b0011" + m_2_1_1[5:8].zfill(4),2))
    m_2_1_2 = bin(ord(str1[2]))[2:].zfill(8)
    m_2_1_2a = chr(int("0b0011" + m_2_1_2[1:4].zfill(4),2))
    m_2_1_2b = chr(int("0b0011" + m_2_1_2[5:8].zfill(4),2))
    m_2_2_1 = bin(ord(str1[3]))[2:].zfill(8)
    m_2_2_1a = chr(int("0b0011" + m_2_2_1[1:4].zfill(4),2))
    m_2_2_1b = chr(int("0b0011" + m_2_2_1[5:8].zfill(4),2))
    m_2_3_1 = bin(ord(str1[4]))[2:].zfill(8)
    m_2_3_1a = chr(int("0b0011" + m_2_3_1[1:4].zfill(4),2))
    m_2_3_1b = chr(int("0b0011" + m_2_3_1[5:8].zfill(4),2))
    m_2_4_1 = bin(ord(str1[5]))[2:].zfill(8)
    m_2_4_1a = chr(int("0b0011" + m_2_4_1[1:4].zfill(4),2))
    m_2_4_1b = chr(int("0b0011" + m_2_4_1[5:8].zfill(4),2))
    m_2_5_1 = bin(ord(str1[6]))[2:].zfill(8)
    m_2_5_1a = chr(int("0b0011" + m_2_5_1[1:4].zfill(4),2))
    m_2_5_1b = chr(int("0b0011" + m_2_5_1[5:8].zfill(4),2))
    m_2_5_2 = bin(ord(str1[7]))[2:].zfill(8)
    m_2_5_2a = chr(int("0b0011" + m_2_5_2[1:4].zfill(4),2))
    m_2_5_2b = chr(int("0b0011" + m_2_5_2[5:8].zfill(4),2))
    m_2_5_3 = bin(ord(str1[8]))[2:].zfill(8)
    m_2_5_3a = chr(int("0b0011" + m_2_5_3[1:4].zfill(4),2))
    m_2_5_3b = chr(int("0b0011" + m_2_5_3[5:8].zfill(4),2))
    m_2_5_4 = bin(ord(str1[9]))[2:].zfill(8)
    m_2_5_4a = chr(int("0b0011" + m_2_5_4[1:4].zfill(4),2))
    m_2_5_4b = chr(int("0b0011" + m_2_5_4[5:8].zfill(4),2))
    m_2_5 = m_2_5_1a + m_2_5_1b + m_2_5_2a + m_2_5_2b + m_2_5_3a + m_2_5_3b + m_2_5_4a + m_2_5_4b
    msg = msg + m_2_1_1a + m_2_1_1b + m_2_1_2a + m_2_1_2b + m_2_2_1a + m_2_2_1b + m_2_3_1a + m_2_3_1b + m_2_4_1a + m_2_4_1b + m_2_5
    print "msg     =", msg
    f.write(msg)
    f.write('\n')


其中加了一行
s.setsockopt(SOL_SOCKET,SO_REUSEADDR,1) 

這是因為socket 預設不得重複占用位址,若要重複使用需調整程式中增加socket參數設定
socket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)


若有大量重複使用位址的需求,須直接調整系統網路參數設定,否則會有大量timeout或waitting狀況

系統網路參數調整方式:

vi  /etc/sysctl.conf

加入
net.ipv4.tcp_syncookies = 1    #這一行配置文件里如果有就不用添加了
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 5

然後執行以下命令,讓設定生效
/sbin/sysctl -p



2018年6月6日 星期三

監控目錄中檔案的異動

為符合資安要求,程式更版必須控管,並留存上線紀錄,同時為避免未經核可的程式更版發生,必須監控程式的異動。

監控的部分,這次規劃用Directort Monitor免費版,搭配自己寫的script達到監控發現程式異動時,立即用email及Line notify進行通報
Directory Monotor 專業版有mail功能但沒有Line Notify功能,費用說評估如下
Directory Monotor 專業版 每台主機USD149(以主機生命週期計算)
Directory Monotor 專業版 每台主機USD79(以每年計算)

若一台主機使用5年,有10台主機,5年費用為
以主機生命週期計算:149*10=1490USD
以每年計算:79*10*5=3950USD

安裝說明如下:

1.mkdir c:\dm
2.copy sendmail.bat sendmail.ps1 is_ready.wsf inc.js c:\dm
sendmail.bat  通報主程式
sendmail.ps1 寄信主程式
is_ready.wsf  Line notify主程式

inc.js              Line notify 副程式

3.到Directory Monitor網站下載並安裝 Directory Monitor
 會自動安裝.net framework 4.0,若電腦無法上網,需要先下載安裝

執行Directory Monitor
Add設定要監控的目錄
設定Main
指定要監控的目錄、EventsOptionsTypesFilter
Filter過濾掉*.tmp~*.*,因為Office文件異動會產生暫存檔,造成監控不斷發出通報。

設定Text Log
啟用log
設定log存放路徑及檔名c:\dm\dirmon.txt
設定Timestamp,選擇Daily,可將log每天存成1各檔,檔名加上日期
設定紀錄內容


設定Execute
設定發現異動時要執行的程式,應指定到c:\dm\sendmail.bat (圖片上目錄有誤)
參數和程式有關,不可變更,否則會造成程式執行異常。

其他頁簽功能無法使用,因為是免費版。


系統其他設定
選擇Options…

Monitoring兩個方框都不要選取,否則發現異動螢幕會跳出警告,干擾作業。

當要進行程式大量更新時(如廠商換版),請先將監控停止或暫停,以免突然收到大量通報。

若要啟用email通知功能,需告知網管部要收到email通知的人員的email,網管人員在程式中設定。
若要啟用Line通知功能,要收到通知的人必須先到Line Notify網站上註冊申請Token,然後將Token告知網管人員,網管人員於程式中加入Token,同時要收到通知的人必須在Line中將Line Notify加入好友,才能收到Line Notify



2018年5月16日 星期三

npm 學習筆記

NPM 是 Node Package Manager 的簡稱,它是一個線上套件庫,可以下載各式各樣的 Javascript 套件來使用。


建立一個新專案 
https://medium.com/html-test/%E5%BE%9E%E9%9B%B6%E9%96%8B%E5%A7%8B-%E4%BD%BF%E7%94%A8npm%E5%A5%97%E4%BB%B6-317beefdf182


切換到DOS mode,建立一個新目錄
D:\npm-project>mkdir p001
D:\npm-project>cd p001
D:\npm-project\p001


初始化專案資料夾並產生package.json (package.json 是掌管 專案資訊的重要檔案)

執行npm init,詢問都用預設值。

name: 就是該專案的名字,它預設就是該目錄名。
description: 專案描述。
entry point: 專案切入點,這有點複雜,之後再說。
test command: 專案測試指令,之後說。
git repository: 專案原始碼的版本控管位置。
keywoard: 專案關鍵字
author: 專案作者,以 author-name 寫之。
license: 專案版權。

用編輯器檢視package.json內容


再來安裝javascript套件,這次示範安裝 jquery套件

發現有2個警告訊息,可直接編輯package.json加入內容後載重新安裝套件,也可不用理會。
repository 裡的 url 要先去 github 建立一個空白的專案

安裝套件,也可以加入--save  參數。
會將安裝的套件版本寫入package.json

檢查package.json會發現多了iquery版本資訊

每個用 npm 安裝的套件,一律放在 node_modules 資料夾裡,以剛剛安裝的 jquery 來說,我們可以在 node_modules/jquery/dist/jquery.min.js 找到 最小化的 jquery 的版本。


編輯index.html測試 jquery是否可用

用瀏覽器開啟index.html

測試成功













2018年5月8日 星期二

install lubuntu-18.04-desktop-amd64

1.download lubuntu-18.04-desktop-amd64 from https://lubuntu.net/ 2.install lubuntu-18.04-desktop-amd64 3.安裝完後有幾個問題 無線網路無法使用 解決方式: 1.先用有線網路上網 2.開啟終端機執行 sudo apt-get install firmware-b43-installer reboot 中文輸入法無法使用 lubuntu 預設會安裝 fcitx 輸入法管理工具,但沒安裝輸入法 開啟Synaptic Package Manager 套件管理工具 搜尋fcitx 勾選及安裝 fcitx-chewing (注音輸入法) 重新啟動 fcitx 螢幕右下角狀態列會出現小鍵盤圖示 在圖示上點選滑鼠左鍵,出現選單,選擇Input Method -> 新酷音 螢幕右下角狀態列會出現紅色(酷)圖示,表示已切換至新酷音輸入法 按Shift鍵(或Ctrl+空白)可切換中英輸入模式

2017年6月20日 星期二

趨勢防毒軟體Officescan發現行為違規

某個使用者自己寫了WORD巨集,執行時被防毒軟體Officescan判定為行為違規(弱點攻擊),跳出警告視窗並終止巨集的執行。
使用者反映此問題,要求協助排除~~

檢查Officescan主機log,發現該台電腦有以下行為紀錄

若要排除此問題,必須將違規執行的程式加入例外清單

出現行為監控設定畫面,將違規程式(含路徑)加入例外清單並儲存。
然後請使用者開啟Officescan用戶端主控台,點選更新按鈕,更新主機的設定

再請使用者執行所設計的WORD巨集程式,就部會再被阻擋了。


但此設定等於關閉WORD巨集檢查,該台電腦將部會阻擋巨集病毒,使用者必須注意。

2017年6月19日 星期一

windows 2008 校時服務

今天發現一台QNAP網路校時失敗,檢查發見校時主機windows 2008的windows time service不見了,
 


再檢查register發現
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config\AnnounceFlags 值設為a


其意義為:此設定會強制 PDC 主機宣告本身為可靠的時間來源,並使用內建的 CMOS 時間而不使用外部時間來源。亦即表示不會與其他主機校時。

用以下方式讓校時服務重新恢復運作。

  1. Click Start, click Run, type regedit, and then click OK.
  2. Locate and then click the following registry entry:
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config\
  3. In the right pane, right-click AnnounceFlags, and then click Modify.
  4. In the Edit DWORD Value dialog box, under Value data, type 5, and then click OK.
  5. Enable NTPServer.
    1. Locate and then click the following registry subkey:
      HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ 
                                                      Services\W32Time\TimeProviders\NtpServer\
    2. In the right pane, right-click Enabled, and then click Modify.
    3. In the Edit DWORD Value dialog box, type 1 under Value data, and then click OK.
  6. Exit Registry Editor.
  7. At the command prompt, type the following command to restart the Windows Time service, and then press ENTER:
    net stop w32time && net start w32time
  8. 設定上層校時伺服器  c:>w32tm /config /manualpeerlist:"time.stdtime.gov.tw clock.stdtime.gov.tw tick.stdtime.gov.tw watch.stdtime.gov.tw" /syncfromflags:manual /reliable:yes /update
  9. 再檢查regedit可以看到NTPServer設定已變成國家時間與頻率標準實驗室的校時主機了。







參考來源:
https://support.microsoft.com/zh-tw/help/816042/how-to-configure-an-authoritative-time-server-in-windows-server
http://blog.miniasp.com/post/2009/06/16/Configure-the-Windows-Time-service-on-the-Domain-Controller.aspx


2017年5月5日 星期五

移除第2台有問題的Active directory server

參考:
https://community.spiceworks.com/how_to/9942-complete-force-removal-of-a-domain-controller-from-active-directory-guide


1.先在一台正常的AD Server上執行ntdsutil 確認以下資訊

參考:
https://community.spiceworks.com/how_to/9942-complete-force-removal-of-a-domain-controller-from-active-directory-guide

2017年5月2日 星期二

手動方式從microsoft Update Catalog下載更新檔進行windows update

有時候我們從各類資安通報收到通知微軟有安全性漏洞需要更新,通報有時會告知可下載微軟的KBxxxxxxx安全性更新進行安裝。

例如收到僅訊通報:微軟所有Office Word版本之物件連結與嵌入(OLE)存在零時差漏洞,允許攻擊者遠端執行任意程式碼。

可上微軟網站下載更新程式進行更新
https://portal.msrc.microsoft.com/en-US/security-guidance/advisory/CVE-2017-0199

上微軟網站,可以看到受影響的微軟產品以及相對應可以下載的KBxxxxxxx檔。


因為電腦上安裝Office 2007,所以下載Office 2007 SP3更新程式KB3141529

連上Microsoft Update Catalog網站並搜尋KB3141529

點選download按鈕,下載更新程式


出現下載連結畫面,點選連結開始下載

點選下載的檔案,進行安裝





2017年4月26日 星期三

如何用ssh連線進入mininet中的主機

mininet安裝完後,在mininet\examples中有一個python範例檔sshd.py,此範例展示所建之主機可以由本機用ssh方式登入mininet內之虛擬機

執行sshd.py後進入mininet 命令列,不要退出。


另外用putty登入本機後,用ssh登入其中一台主機,其中參數 -l 後面設定登入使用的帳號(root)

登入後執行ifconfig,可以看到只列出h1的介面

所以可以依自季的需求來修改sshd.py做其他應用及設計

Chrome如何檢查網站憑證

網站網址如果使用https表示有使用SSL憑證加密,查看憑證的方式如下:

在網址列可以看到 綠色安全標籤,表示此網站是安全的



在網頁上按滑鼠右鍵,出現選單,選擇 [檢查]

然後點選 Security 頁籤
找到並點選 View Certificate 按鈕
就可以看到瀏覽網站的憑證內容了

ubuntu 14.04.5 Server install mininet

參考文件
https://yeasy.gitbooks.io/mininet_book/index.html

1.在VirtualBox安裝ubuntu 14.04.5 server x64,Package select openssh

2.讓root可以用putty login
vi /etc/ssh/sshd_config
修改
PermitRootLogin Yes
重新開機,讓root可以用putty login

3.OS更新
#apt-get update
#apt-get upgrade

4.安裝git
root@mininet:/etc/init.d# apt-get install git

5.安裝mininet
root@mininet:~# git clone git://github.com/mininet/mininet
root@mininet:~# mininet/util/install.sh -a
(會跑很久)

6.登入mininet

root@mininet:~# mn
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2
*** Adding switches:
s1
*** Adding links:
(h1, s1) (h2, s1)
*** Configuring hosts
h1 h2
*** Starting controller
c0
*** Starting 1 switches
s1 ...
*** Starting CLI:
mininet>

預設會建立2台主機h1、h2
1台交換器 s1
1台控制器 c1

7.查看節點數
mininet> nodes
available nodes are:
c0 h1 h2 s1

8.查看連結訊息
mininet> net
h1 h1-eth0:s1-eth1
h2 h2-eth0:s1-eth2
s1 lo:  s1-eth1:h1-eth0 s1-eth2:h2-eth0
c0

8.查看各節點訊息
mininet> dump



9.h1 ping h2
mininet> h1 ping -c 1 h2
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=1.96 ms

--- 10.0.0.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.969/1.969/1.969/0.000 ms

10.開啟h1終端機
mininet> xterm h1
Error: Cannot connect to display

出現錯誤,必須在GUI模式才能開啟

11.在h1建一個web Server,再從h2 get h1 資料

mininet> h1 python -m SimpleHTTPServer 80 &
mininet> h2 wget -O - h1

刪除web服務
mininet> h1 kill %python



12.cmd line自訂拓樸
http://sdnhub.org/resources/useful-mininet-setups/


1個控制器、1個交換器、3個主機

root@mininet:~# sudo mn --arp --topo single,3 --mac --switch ovsk --controller remote

In the above command, there are some important keywords worth paying attention to:
  • mac: Auto set MAC addresses
  • arp: Populate static ARP entries of each host in each other
  • switch: ovsk refers to kernel mode OVS
  • controller: remote controller can take IP address and port number as options

1個控制器、2個交換器、2個主機

root@mininet:~# sudo mn --topo linear --switch ovsk --controller remote
mininet> nodes
available nodes are:
c0 h1 h2 s1 s2

1個控制器、1個交換器、3個主機、1個Client

root@mininet:~# sudo mn --arp --topo single,4 --mac --switch ovsk --controller remote
mininet> nodes
available nodes are:
c0 h1 h2 h3 h4 s1

  • Virtual IP/MAC: Pick a virtual IP (VIP) and MAC for the load-balancer. This is the IP address to which the clients will make a HTTP request. The controller will push rules to rewrite the VIP with the selected HTTP server. To make this work, you need to static set an ARP entry for the VIP in the client. If ‘h1′ is the client and 10.0.0.5 is the VIP, the following command will add the static ARP entry:
    mininet> h1 arp -s 10.0.0.5 00:00:00:00:00:05
    
  • Server setup: The –arp keyword is very important to populate MAC addresses in each host. Besides that we need to run the following commands within mininet:
    mininet> h2 python -m CGIHTTPServer &
    mininet> h3 python -m CGIHTTPServer &
    mininet> h4 python -m CGIHTTPServer &
    
  • Warm-up controller learning: After the hosts are up, it is important to make the controller learn the location of each host. You can do this through a pingall command in mininet:
    mininet> pingall
    
  • Client request: In our custom VM, we have CGI script configured to report back which server is handling a particular client request. Thus, when a client performs the following command, you will receive the IP address of the handling server.
    mininet> h1 curl http://10.0.0.5:8000/cgi-bin/serverip.cgi

13.Python API 腳本自訂拓樸

在 mininet\custom目錄下有一個範例 topo-2sw-2host.py
文件中定义了一个 mytopo,则可以通过 --topo 选项来指定使用这一拓扑,命令为 
sudo mn --custom ~/mininet/custom/topo-2sw-2host.py --topo mytopo --test pingall

root@mininet:~# sudo mn --custom ~/mininet/custom/topo-2sw-2host.py --topo mytopo --test pingall
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2
*** Adding switches:
s3 s4
*** Adding links:
(h1, s3) (s3, s4) (s4, h2)
*** Configuring hosts
h1 h2
*** Starting controller
c0
*** Starting 2 switches
s3 s4 ...
*** Waiting for switches to connect
s3 s4
*** Ping: testing ping reachability
h1 -> h2
h2 -> h1
*** Results: 0% dropped (2/2 received)
*** Stopping 1 controllers
c0
*** Stopping 3 links
...
*** Stopping 2 switches
s3 s4
*** Stopping 2 hosts
h1 h2
*** Done

completed in 5.341 seconds


14.Mininet 範例程式介紹
http://yhhuanglab.blogspot.tw/2015/09/mininet.html










ubuntu 安裝完kubernetes後做apt-get update會出現錯誤

root@k8s02:~# sudo apt-get update 已有:1 http://tw.archive.ubuntu.com/ubuntu xenial InRelease 已有:2 http://tw.archive.ubuntu.com/ubuntu xenia...