9/25/2013

What is ESP?

ESP(封装安全有效负载),全称Encapsulating Security Payload, IPsec 封装安全负载(IPsec ESP)是IPsec 体系结构中的一种主要协议, IPsec ESP 通过加密需要保护的数据以及在IPsec ESP 的数据部分放置这些加密的数据来提供机密性和完整性。 根据用户安全要求,这个机制既可以用于加密一个传输层的段(如:TCP、UDP、ICMP、IGMP), 也可以用于加密一整个的IP 数据报。封装受保护数据是非常必要的,这样就可以为整个原始数据报提供机密性。

9/22/2013

IP subenet zero 的意思

IP subnet zero 是用來限制router不可使用與class相同的subnet.
 例如: 把一個class b 的network 172.16.0.0/16 subnet細分. 其中一個細分方式係 172.16.0.0/19, 172.16.32.0/19, 172.16.64.0/19.....

而如果第一個subnet 172.16.0.0/19在沒有subnet mask的情形下 (即172.16.0.0) 與它的class network (即172.16.0.0) 相同.

這樣會引起routing上的混亂 --- 如果一個router 上有一個network 172.16.0.0/19, 而它用rip把這個network告訴它的neighbor router. neighbor router就會將所有要送去172.16.0.0 class 的packet送到這個router...... 

以前, RIP是很流行的routing 協議. 但它就沒有把subnet mask放入routing table. 當時亦沒有太多network admin考慮這個問題. (RFC950提到這個問題) Cisco注意到這個問題, 所以在很早以前的IOS已經限制使用subnet zero. 以前cisco router 預設是不可使用 subnet zero (即no ip subnet zero是預設的). network admin要輸入ip subnet zero 才可使用.

從12.0開始, ip subnet zero 是預設(因為已沒有太多人使用不含subnbet mask 的routing 協議). 不過network admin還是可以用no ip subnet zero 來限制使用subnet zero.

 版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明 http://www.blogbus.com/coolliang-logs/1864324.html

9/09/2013

快速理解 FECN/BECN (forward explicit congestion notification/backward explicit congestion notification)

在frame relay世界中, 有送端與收端, 想像工廠中生產線上的兩個員工, A and B.

A 會一直作東西給 B, 當 A 發現 要把做好的東西放到機台上時結果擠不進去,

這時候A 就會跟 B 說 FECN : 現在機台很上太多東西了, 會滿出來喔.

相反地, B 會一直拿到 A 做好的東西 再加工, 如果 B 發現機台上太多東西,

就會跟 A 說 BECN, 現在機台上太多東西了, 很塞耶.

當然實際在網路上發生此現象的原因是因為頻寬不足, 或是 link noise太大 之類.

8/31/2013

vim 如何使用巨集功能

1. 紀錄

先在最外層 按下 "q" , 再按下你想要的巨集名稱, 例如: a

2. 輸入想要編輯的步驟

此時左下方會顯示 "recording" , 代表已經在紀錄中, 此時你所有
輸入的編輯指令都會被紀錄在巨集 a 當中. 例如: 我 i + teststring + Esc

3. 離開紀錄模式

編輯完後按 Esc 跳到最外層, 再按下 "q", 就會停止紀錄

4. 播放巨集

按下 @a, 播放剛才紀錄的巨集, 這樣就會播放一次

5. 連續播放巨集

按下 10@a, 就會播放剛才紀錄的巨集 10 次


8/26/2013

STP switch port states

STP switch port states:


  • Blocking - A port that would cause a switching loop if it were active. No user data is sent or received over a blocking port, but it may go into forwarding mode if the other links in use fail and the spanning tree algorithm determines the port may transition to the forwarding state. BPDU data is still received in blocking state. Prevents the use of looped paths.
  • Listening - The switch processes BPDUs and awaits possible new information that would cause it to return to the blocking state. It does not populate the MAC address table and it does not forward frames.
  • Learning - While the port does not yet forward frames it does learn source addresses from frames received and adds them to the filtering database (switching database). It populates the MAC Address table, but does not forward frames.
  • Forwarding - A port receiving and sending data, normal operation. STP still monitors incoming BPDUs that would indicate it should return to the blocking state to prevent a loop.
  • Disabled - Not strictly part of STP, a network administrator can manually disable a port
  • Reference: wikipedia

    8/19/2013

    set the IPs and static route on ERX

    show the config on certain interface
    (config)# run show configuration interface gigabitEthernet X/X/X.YYY

    set the ip address subnet on certain interface
    (config)# interface gigabitEthernet X/X/X.YYY
    (config)# ip address 1.1.1.1 255.255.255.0 secondary

    set static route on router
    (config)#ip route 1.1.1.1/24 2.2.2.2
    or
    (config)#ip route 1.1.1.1/24 gigabitEthernet X/X/X.YYY


    setting targets:

    o. let certain subnet can access to internet

    8/02/2013

    python dictionary 入門

    >>> tel = {'jack': 4098, 'sape': 4139}
    >>> tel['guido'] = 4127
    >>> tel
    {'sape': 4139, 'guido': 4127, 'jack': 4098}
    >>> tel['jack']
    4098
    >>> del tel['sape']
    >>> tel['irv'] = 4127
    >>> tel
    {'guido': 4127, 'irv': 4127, 'jack': 4098}
    >>> tel.keys()
    ['guido', 'irv', 'jack']
    >>> 'guido' in tel
    True

    7/31/2013

    python write the json and php read it periodically

    python part:

    #save your data into python dictionary - Ex. testResultsJson
    testResultsJson = {}
    fjs = open('/var/www/xxx/state.json','w')
    fjs.write(json.dumps(testResultsJson))
    fjs.close()


    php part:

    $file = "/var/www/xxx/state.json";
    $obj = json_decode(file_get_contents($file));
    #Ex. i want to get the timestamp info from this object.
    $timestring =  'Last Updated:'.$obj.'timestamp.';

    7/26/2013

    GTM 常用指令紀錄

    create gtm datacenter dc1 dc2

    create gtm server ltm1 addresses add { 10.10.100.1 } monitor bigip datacenter dc1 virtual-servers add { 10.10.100.10:80 10.10.100.11:80 10.10.100.12:80 }

    create gtm server ltm2 addresses add { 10.10.200.1 } monitor bigip datacenter dc3 virtual-servers add { 10.10.200.10:80 10.10.200.11:80 10.10.200.12:80 }

    create gtm pool gpool1 members add { 10.10.100.10:80 {ratio 1} 10.10.100.11:80 {ratio 2} 10.10.100.12:80 {ratio 3} } load-balancing-mode ratio verify-member-availability disabled

    create gtm pool gpool2 members add { 10.10.200.10:80 {ratio 1} 10.10.200.11:80 {ratio 2} 10.10.200.12:80 {ratio 3} } load-balancing-mode ratio verify-member-availability disabled

    create gtm wideip test.wip.com pool-lb-mode ratio pools add { gpool1 { ratio 1 } gpool2 { ratio 2 } } persistence enabled ttl-persistence 300 rules add { testwip-rule }

    如何在 GTM 使用 tmsh 新增多members 到 pool當中

    tmsh# gtm pool modify POOLNAME members add { ip1:port ip2.port }

    7/25/2013

    set static mac address on juniper router

    (config)# arp 1.1.1.1 gigabitEthernet x/x/x/x AAAA.BBBB.CCCC

    7/23/2013

    常忘記但會用到的 shell script while loop

    Example:

    while true; do ls; sleep 2; done

    while true; do [command]; sleep [duration];  done


    7/15/2013

    紀錄常用protocol header

    mac header size: 14 B
    ip header size: 20 B
    tcp header size: 20 B
    udp header size: 8 B

    6/27/2013

    一次觀看多個youtube影片的方法

    1. 連結到此網站:

    http://geoipro.mooo.com/youtube/testy.html

    2. 輸入您所要看的youtube video ID 以及其他相關參數

    3. 點擊 Gen crazy user

    4. 享受一次觀看多個youtube的效果

    6/12/2013

    SNAT 與 DNAT 的差別

    假設 IP 封包 示意如下:

    | src ip | dst ip | xxxx(payload) |

    NAT大致有下列三種 :

    1. SNAT

       [change]
    |     src ip     | dst ip | xxxx |

    #修改 src ip

    2. DNAT

                   [change]
    | src ip |     dst ip      | xxxx |

    #修改 dst ip

    3. MASQUERADE (SNAT的一種)

    假設 網卡 eth0 上的 IP 為 A-ip, 則由eth0 出去的封包:

       [change to A-ip]
    |          src ip           | dst ip | xxxx |


    SNAT run on POSTROUTING chain, DNAT run on PREROUTING chain

    如何寫簡單的 web page auto refresh

    如何在用apt-get 安裝 vim 7.3

    1. 在 /etc/apt/sources.list 中加入下列這行:

    deb http://ftp.de.debian.org/debian sid main

    2. 關閉vim並且運行下列指令:

    sudo apt-get update

    sudo apt-get remove vim-common vim-runtime vim-gtk vim-gui-common

    sudo apt-get install vim-common vim-runtime

    3. 在/etc/apt/sources.list 中移除 deb http://ftp.de.debian.org/debian sid main

    4. 再跑一次 sudo apt-get update

    5. 完成

    5/17/2013

    GTM 修改多個 WideIP 之設定方法

    tmsh

    Ex.
    modify gtm wideip all last-resort-pool test-pool

    The last-resort-pool part can be the any parameter within wideip

    5/09/2013

    4/24/2013

    CTCP - Compound TCP

    簡介:

    CTCP 是 Microsoft 所研發的一種TCP algorithm, 原始是被用在Windows Vista (非預設) and Windows Server 2008 上的TCP Stack. 他主要是被設計成可以積極的調整送端的壅塞窗戶,  並且其主要針對頻寬大而延遲高的網路通道作最佳化, 而又不失TCP 之公平性. CTCP可以用hotfix 套用於Linux 與 Windows XP.

    原則:

    CTCP 使用queueing 延遲來作為壅塞的衡量參數. 如果queueing延遲很小, 那他就會假設目前網路通道上沒有link發生壅塞, 進而快速增加傳送速率.

    CTCP 維護兩種壅塞窗戶, 一種是一般的AIMD窗戶, 另一種是以延遲為基準的窗戶, 而實際上的Sliding window size 就是以上兩種的總和. AIMD窗戶大小增加的行為與TCP Reno相同.

    如果網路環境的延遲很小, 那麼延遲窗戶就會快速加大, 一旦發現queueing發生, 延遲窗戶就會快速減小, 來補償AIMD窗戶增加的量. 主要目的是要讓 AIMD 窗戶 size + 延遲窗戶 size ~= 定值 (趨近定值) 而當queue 發生時, 延遲窗戶所減少的量會接近於queue size, 以防止持續性的壅塞. 所以CTCP的特點在於, 他可以根據delay的程度來調整其窗戶 size.


    設定:

    在Windows 7 如果想要啟用的話, 可使用以下指令:

    netsh interface tcp set global congestionprovider=ctcp

    在Windows 8 的話, 可使用以下指令:

    set-nettcpsetting -Settingname Custom -CongestionProvider CTCP

    顯示目前您電腦的TCP設定:

    netsh interface tcp show global




    1/19/2013

    測試DNS是否成功設定 - python script


    #!/usr/bin/python
    import time
    import sys
    import os
    i = 1

    if len(sys.argv) < 3:
        sys.stderr.write('Usage: sys.argv[0] target-domain times-of-test  DNS-IP\n')
        sys.exit(1)
    else:
        counter = int(sys.argv[2])
        domain = sys.argv[1]
        dnsip = sys.argv[3]
        while i <= counter:
            i += 1
            os.system("dig " +  domain "@" + dnsip + " | grep NXDOMAIN")



    #只要看ouput出來有幾行 NXDOMAIN 就知道大約的錯誤機率了

    1/15/2013

    保護眼睛 螢幕設定模式

    作為一個資訊相關的工程師, 或是一般上網的重度使用者,  一定會覺得常常眼壓很高很累吧. 個人最近甚至因為常常工作看螢幕, 飛蚊症漸漸出現, 為了讓各位的眼睛能夠用久一點, 在此推薦在 win 7 裡面可以設定螢幕色調相反模式, 也就是如果網頁是白底黑字, 就會變成黑底白字, 眼睛長期看螢幕比較不會一直都在看白色部份.

    設定方法如下:

    控制台 -> 輕鬆存取中心 -> 啟動放大鏡 -> 在放大鏡控制介面有個齒輪設定圖案
    -> 進入設定後 勾選 開啟色彩反轉

    大功告成

    以後覺得眼睛很酸很累又需要看螢幕時, 可以嘗試開啟此模式喔


    看網頁會像是下面這樣:



    1/01/2013

    在linux刪除所有特定的程序

    linux上面有些daemon一次可能會開多個process, 例如: nginx, 如果我們想要一次kill所有跟nginx相關的process, 可以使用 killall nginx 來刪除所有與nginx有關的 running process.