Thursday, February 17, 2011

Linux上好用的IP計算工具-sipcalc

sipcalc這個工具真是計算IP位置的好工具!尤其是在Linux console mode就可以使用囉!
當然啦!在OpenSUSE 11.3上只要透過zypper就可以安裝成功了。

Steps:
1. linux-8zbb:~ # zypper in sipcalc
Retrieving repository 'OpenSUSE 11.3 update' metadata [done]
Building repository 'OpenSUSE 11.3 update' cache [done]
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following NEW package is going to be installed:
sipcalc

1 new package to install.
Overall download size: 29.0 KiB. After the operation, additional 58.0 KiB will be used.
Continue? [y/n/?] (y): y
Retrieving package sipcalc-1.1.5-0.pm.2.1.x86_64 (1/1), 29.0 KiB (58.0 KiB unpacked)
Retrieving: sipcalc-1.1.5-0.pm.2.1.x86_64.rpm [done (15.7 KiB/s)]
Installing: sipcalc-1.1.5-0.pm.2.1 [done]
Additional rpm output:
warning: /var/cache/zypp/packages/Packman_opensuse_11.3/x86_64/sipcalc-1.1.5-0.pm.2.1.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 9a795806: NOKEY

2. linux-8zbb:~ # sipcalc 10.10.10.1/23 <- 指定某個IP subnet
-[ipv4 : 10.10.10.1/23] - 0

[CIDR]
Host address - 10.10.10.1
Host address (decimal) - 168430081
Host address (hex) - A0A0A01
Network address - 10.10.10.0
Network mask - 255.255.254.0
Network mask (bits) - 23
Network mask (hex) - FFFFFE00
Broadcast address - 10.10.11.255
Cisco wildcard - 0.0.1.255
Addresses in network - 512
Network range - 10.10.10.0 - 10.10.11.255
Usable range - 10.10.10.1 - 10.10.11.254

linux-8zbb:~ # sipcalc eth0 <- 針對目前的interface
-[int-ipv4 : eth0] - 0

[CIDR]
Host address - 10.10.10.253
Host address (decimal) - 168430333
Host address (hex) - A0A0AFD
Network address - 10.10.10.0
Network mask - 255.255.255.0
Network mask (bits) - 24
Network mask (hex) - FFFFFF00
Broadcast address - 10.10.10.255
Cisco wildcard - 0.0.0.255
Addresses in network - 256
Network range - 10.10.10.0 - 10.10.10.255
Usable range - 10.10.10.1 - 10.10.10.254

沒錯它就是這麼簡單好用,更多的功能請自行研究吧。

Tuesday, February 15, 2011

Linksys WUSB600N ver.2 driver for Linux and How to install it

Linksys WUSB600N ver.2 used Ralink RT3572 chipset, so please go to the Ralink website to download it first.
Steps:
1. Uncompress 2010_1215_RT3572_Linux_STA_v2.5.0.0.DPO.bz2
2. Plug in WUSB600N to your Linux box.
3. To execute "demsg" command to examine the vendor id and product id of WUSB600N. (it should be 1737/0079)
4. Added {USB_DEVICE(0×1737,0×0079)}, /* Linksys WUSB600N v2 */ to the /common/rtusb_dev_id.c file
5. Modified /os/linux/config.mk file to give you WPA encryption:
# Support Wpa_Supplicant
HAS_WPA_SUPPLICANT=y
# Support Native WpaSupplicant for Network Maganger
HAS_NATIVE_WPA_SUPPLICANT_SUPPORT=y
6. # make && make install && reboot
7. After system reboot successfully then plug in the WUSB600N to the Linux box again, and to execute "ifconfig -a" command then you will see the new device ra0

Saturday, February 12, 2011

What's pdsh and how it works?

What's pdsh?
Pdsh is a an efficient, multithreaded remote shell client which executes commands on multiple remote hosts in parallel. Pdsh implements dynamically loadable modules for extended functionality such as new remote shell services and remote host selection.
I.e., If you'd like to control multiple machines at once then you can use pdsh to reach it.
For example:
Server1: 10.10.2.2
node1: 10.10.2.181
node2: 10.10.2.159
And I'd like to control node1 and node2 on Server1 at once.

Steps:
1. Install pdsh on the Server.
2. Import ssh key of Server1 to the node1 and node2.
3. Add hostname-to-IPaddress of node1/node2 in /etc/hosts on Server1.
4. To execute: pdsh -w ssh:root@node[1,2] ls 2> /dev/null then node1 and node2 will to execute ls command and report to the Server1 as following:
lawrence@suse:~/.ssh> pdsh -w ssh:root@node[1,2] ls 2> /dev/null
node1: anaconda-ks.cfg
node1: Desktop
node1: id_rsa.pub
node1: install.log
node1: install.log.syslog
node2: anaconda-ks.cfg
node2: bin
node2: conf-examples
node2: cpulimit-1.1.tar.gz
node2: cpulimit.tar.gz
node2: Desktop
node2: id_rsa.pub
node2: install.log
node2: install.log.syslog
node2: mibs
node2: mibs_20100925.rar

5. Combine multiple commands:
lawrence@suse:~/.ssh> pdsh -w ssh:root@node[1,2] "cd /tmp;ls" 2> /dev/null
node1: pulse-Bk60xcI9xlDq
node1: virtual-root.pHV8bR
node2: etherXXXXWj7KYw
node2: gconfd-root
node2: keyring-RdVKdK
node2: mapping-root
node2: scim-panel-socket:0-root