2011年4月1日 星期五

shellinabox - 在瀏覽器操作 Linux Shell


環境: Fedora 13, Shell In A Box v2.10 (revision 225)

安裝 shellinabox
#安裝必要套件
sudo yum install subversion gcc make automake pam-devel openssl-devel openssh-clients
#安裝 Shell In A Box
svn checkout http://shellinabox.googlecode.com/svn/trunk/ shellinabox
cd shellinabox
./configure
make
sudo make install

#若 SELinux 為 Enforcing, 需進行以下處理
sudo cp -Z system_u:object_r:etc_t:s0 etc-pam.d-shellinabox-example /etc/pam.d/
#查看 openssl 版本
rpm -q openssl
#若 openssl 版本高於 0.9.8
#則必須在 openssl 0.9.8 以下的電腦製作 ssl 憑證: certificate.pem
#再把 certificate.pem 檔案複製到 shellinabox 電腦的 /tmp 目錄下

openssl req -x509 -nodes -days 3650 -subj '/CN=localhost/' \
  -newkey rsa:1024 -keyout certificate.pem -out certificate.pem

註: openssl 1.0.0 所產生的 certificate.pem 會造成 ssl handshake failure
執行 shellinabox
#不使用 SSL, 預設聆聽 tcp 4200 port
$ shellinaboxd --disable-ssl
#使用 SSL, 聆聽 tcp 1234 port
$ shellinaboxd --cert /tmp --port 1234
#使用 SSL, 聆聽 tcp 1234 port, 黑底白字
$ shellinaboxd --cert /tmp --port 1234 --css /usr/local/share/doc/shellinabox/white-on-black.css
#使用 SSL, 聆聽 tcp 1234 port, 背景執行
$ shellinaboxd --background --cert /tmp --port 1234
#在 SELinux=Enforcing 環境下以 root 執行
# shellinaboxd --background --cert /tmp --service /:SSH
以 service 方式管理 shellinabox
su -
chmod 700 /usr/local/bin/shellinaboxd
vi /etc/init.d/shellinabox

#!/bin/sh
### BEGIN INIT INFO
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
 
case "$1" in
'start')
    /usr/local/bin/shellinaboxd --background --cert /tmp --service /:SSH
    ;;
'stop')
    pkill shellinaboxd
    ;;
esac
exit 0
chmod +x /etc/init.d/shellinabox
chkconfig --add shellinabox
service shellinabox start
參考資料:

LINK from:http://cha.homeip.net/blog/2010/09/2699.html

2011年3月26日 星期六

STP (Spanning – Tree Protocol)

STP (Spanning – Tree Protocol) 主要的目的是為了避免Switch Loop 為Cisco設備專有的技術



* 初學者容易把 STP 和 VTP(vlan) 搞混,這兩個是不同的技術。



主要依靠:

1.BPDU(Bridge Protocol Data Unit)

2.Spanning Tree advertisement (STA)

來讓switch接受到neighbor switch的BPDU來進行資料的比對。



BPDU:(Priorty、MAC address、Port Cost、Port Priority、Port ID……等等的資訊)



運作流程:

1.首先會在Switch之中,依Priorty最小 或 MAC address最小 的Switch當做Root Bridge。

2.在Root Bridge上每一個Port都是Designed Port (被定義的Port)。

3.其它沒有被選為Root Bridge的Switch就稱為Non-Root Bridge。

4.在這些Non-Root Bridge上的Port,會選出一個到達Root Bridge的成本(Cost)最低的當作Root Port。

5.其它連接 Switch 之間的Non-Designed Port(未被定義的Port),就會被Block起來。


*被Block起來的Port,仍會聆聽BPDU,一但網路出了問題,就會馬上啟用(Forwarding),修復網路。



*Port Fast:使用在End-User的Port:(參考Cisco網站原文的技術書)

- 因為 Cisco 設備,都會對於插上Port的端點進行迴圈的偵測,大約 15秒 + 15秒,因為如果你的網路線

端點,是 Server 或是 PC host 的話,就可以設定該Port為PortFast,加快網路間的收斂(Converse)

- Port Fast Configuration:Switch(config-if)# spanning-tree portfast (2900系列)



本文的引用網址  http://blog.xuite.net/wizardyuy/pcblog/12731221/track

2011年3月25日 星期五

IPad,IPhone,IPod 使用一般電腦USB充電方法

一般電腦USB 因輸出電流過小(USB介面標準最大輸出電流量只有500mA),而無法對IPad,IPhone...等device進行充電。Apple為了加快充電 速度,進而設計出「快速」和「慢速」兩種充電模式。iPad電池容量大,被設定在需要約1A(1000mA)以上的電流量,才能進入慢速充電模式,因此有 許多電腦無法為它充電。至於iPhone、iPod Touch,單純連接電腦是屬於慢速充電模式,想進入快速充電模式,電流量則是必需達到0.7A(700mA)左右。

透過安裝下列軟體,可以使USB送出模擬偏壓訊號的方式,讓裝置以為是連接到變壓器,進而啟動充電模式。

ASUS Ai charger:  http://dlcdnet.asus.com/pub/ASUS/misc/utils/AiCharger_V10006_XpVistaWin7.zip

2011年3月8日 星期二

SNAT V.S MASQUERADE

SNAT改變包的源位址,這在極大程度上可以隱藏你的本地網路或者DMZ等。一個很好的例子是我們知道防火牆的外部位址,但必須用這個位址替換本地網路位 址。有了這個操作,防火牆就 能自動地對包做SNAT和De-SNAT(就是反向的SNAT),以使LAN能連接到Internet。
 
MASQUERADE的作用和SNAT完全一樣,只是電腦 的負荷稍微多一點。因為對每個匹配的包,MASQUERADE都要查找可用的IP地址,而不象SNAT用的IP位址是配置好的。當然,這也有好處,就是我 們可以使用通過PPP、 PPPOE、SLIP等撥號得到的地址,這些位址可是由ISP的DHCP隨機分配的。

How to overclock RB450G/RB750G from 600Mhz to 800Mhz

Login RouterOS terminal

then type :
                    /system routerboard settings set cpu-frequency=800

2011年2月25日 星期五

ubuntu 10.0 4 重設root密碼方法

1. 開機時先進入到GRUB,選擇Recovery Mode後,按 "e" 進入編輯模式
2. 把最後面 "ro single" 改成 "rw single init=/bin/bash"

按 ctrl+x 去boot 便可以用root單人模式 login,再用passwd 修改root密碼即可!

2011年2月21日 星期一

Mapping IP Multicast to MAC-Layer Multicast

To support IP multicasting, the Internet authorities have reserved the multicast address range of 01-00-5E-00-00-00 to 01-00-5E-7F-FF-FF for Ethernet and Fiber Distributed Data Interface (FDDI) media access control (MAC) addresses. As shown in Figure 4.1, the high order 25 bits of the 48-bit MAC address are fixed and the low order 23 bits are variable.
Cc957928.INAF01(en-us,TechNet.10).gif Figure 4.1 Mapping IP Multicast Addresses to Ethernet and FDDI MAC Addresses
To map an IP multicast address to a MAC-layer multicast address, the low order 23 bits of the IP multicast address are mapped directly to the low order 23 bits in the MAC-layer multicast address. Because the first 4 bits of an IP multicast address are fixed according to the class D convention, there are 5 bits in the IP multicast address that do not map to the MAC-layer multicast address. Therefore, it is possible for a host to receive MAC-layer multicast packets for groups to which it does not belong. However, these packets are dropped by IP once the destination IP address is determined.
For example, the multicast address 224.192.16.1 becomes 01-00-5E-40-10-01. To use the 23 low order bits, the first octet is not used, and only the last 7 bits of the second octet is used. The third and fourth octets are converted directly to hexadecimal numbers. The second octet, 192 in binary is 11000000. If you drop the high order bit, it becomes 1000000 or 64 (in decimal), or 0x40 (in hexadecimal). For the next octet, 16 in hexadecimal is 0x10. For the last octet, 1 in hexadecimal is 0x01. Therefore, the MAC address corresponding to 224.192.16.1 becomes 01-00-5E-40-10-01.
Token Ring uses this same method for MAC-layer multicast addressing. However, many Token Ring network adapters do not support it. Therefore, by default, the functional address 0xC0-00-00-04-00-00 is used for all IP multicast traffic sent over Token Ring networks. For more information about Token Ring support for IP multicasting, see RFC 1469.

How to repair and clone disk with ddrescue

  ddrescue  is a tool that can be used to repair and clone disks on a  Linux system . This includes hard drives, partitions, DVD discs, flas...