หน้าเว็บ

แสดงบทความที่มีป้ายกำกับ Linux แสดงบทความทั้งหมด
แสดงบทความที่มีป้ายกำกับ Linux แสดงบทความทั้งหมด

วันจันทร์ที่ 21 มีนาคม พ.ศ. 2554

Linux / Unix Command: vmstat

vmstat - Report virtual memory statistics  

SYNOPSIS

vmstat [-n] [delay [ count]]
vmstat[-V]  

DESCRIPTION

vmstat reports information about processes, memory, paging, block IO, traps, and cpu activity. The first report produced gives averages since the last reboot. Additional reports give information on a sampling period of length delay. The process and memory reports are instantaneous in either case.
 

Options

The -n switch causes the header to be displayed only once rather than periodically. delay is the delay between updates in seconds. If no delay is specified, only one report is printed with the average values since boot.
count is the number of updates. If no count is specified and delay is defined, count defaults to infinity.
The -V switch results in displaying version information.
 

FIELD DESCRIPTIONS

 

Procs

r: The number of processes waiting for run time.  
b: The number of processes in uninterruptable sleep.
w: The number of processes swapped out but otherwise runnable.  This 
   field is calculated, but Linux never desperation swaps.
 

Memory

swpd: the amount of virtual memory used (kB).
free: the amount of idle memory (kB).
buff: the amount of memory used as buffers (kB).
 

Swap

si: Amount of memory swapped in from disk (kB/s).
so: Amount of memory swapped to disk (kB/s).
 

IO

bi: Blocks sent to a block device (blocks/s).
bo: Blocks received from a block device (blocks/s).
 

System

in: The number of interrupts per second, including the clock.
cs: The number of context switches per second.

These are percentages of total CPU time.
us: user time
sy: system time
id: idle time 
 
 
Example
$ vmstat 1 5
 
Example for add timestamp
 
Create perl script 
$ vi timestamp.pl
#!/usr/bin/perl
while (<>) { print localtime() . ": $_"; }
 
$ vmstat 1 5 | ./timestamp.pl 
 
Example for monitor Memory and CPU
 
$/usr/bin/watch -n 5 '/usr/bin/vmstat -s -S M | /bin/grep -E "memory|cpu"' 
 
Thanks : www.thegeekstuff.com

วันอังคารที่ 3 พฤศจิกายน พ.ศ. 2552

How to install rdesktop on Ubuntu

How to install rdesktop on Ubuntu



Code:
sudo apt-get install rdesktop
should take care of it. You way also want to install tsclient for a graphical frontend for rdesktop.
Code:
sudo apt-get install tsclient
You can also use Synaptic Package Manager to do this. Click on System --> Administration --> and choose Synaptic Package Manager.

Thanks : linuxquestions.org

Introduction To VMware VIX API

Introduction to VMware VIX API.


The VIX API allows you to automate virtual machine operations on VMware Server or VMware Workstation.


About the VIX API

The VIX API (or "Vix") is a library for writing scripts and programs to manipulate virtual machines. It is high-level, easy to use, and practical for both script developers and application programmers. The VIX API is designed for three kinds of users:

  • Technically Adventurous Users - For example, dedicated IT personnel in an organization building their own in-house tools.
  • Partners - Software vendors using Vix to integrate VMware products with their own products or to build management products specifically for virtual machines.
  • VMware Engineering - VMware uses Vix in its own products as a general abstraction layer between core virtual machine processes and associated service processes.

The VIX API runs on Microsoft Windows (Windows95 or later) and Linux platforms (kernel 2.4.x or later recommended). It supports programs written in C, Perl, and COM (Visual Basic, VBscript, C#).


Compatibility

This release of the VIX API is compatible with VMware Server 2.0 and VMware Workstation 6.5.

Product Compatibility

VIX API Version

Compatible Platform Products

Library Location

1.0.3

VMware Server 1.0

server-1

1.1

VMware Workstation 6.0

ws-3

1.1.1

VMware Workstation 6.0.1 or earlier

ws-3

1.1.2

VMware Workstation 6.0.2 or earlier

ws-3

1.1.4

VMware Workstation 6.0.4 or earlier

ws-5

1.1.5

VMware Workstation 6.0.5 or earlier

ws-5

1.6.0

VMware Server 2.0 or earlier

VIServer-2.0.0

1.6.1

Workstation 6.5 or earlier

Workstation-6.5.0

The library location is not important if you use the wrapper library as recommended.

Vix Version 1.x supports programs written to version 1.x of the VIX API. Exceptions are noted on function reference pages. For example, VMware Server does not support record and replay, while VMware Workstation does not support virtual machine registration.

Vix libraries are installed with VMware Server and VMware Workstation and provide API compatibility corresponding to the product release. Vix libraries are downward compatible in most cases. If you upgrade VMware Server or VMware Workstation, you should also upgrade any separately installed Vix libraries. For instructions, see Installing the VIX API. You should also upgrade VMware Tools to match the product release.

With VMware Server, you can run Vix programs remotely. With VMware Workstation, Vix programs usually run on the host.


64-Bit Library Support

The VIX API provides 64-bit libraries for Linux only. Windows 32-bit libraries may work in 64-bit emulation mode.


Redistributable Code and Sample Code

As noted in the End User License Agreement, the VIX API allows you to build and distribute your own applications. To facilitate this, the following files are designated as redistributable for the purpose of that agreement:

  • VixAllProducts.lib and VixAllProductsd.lib
  • vix.lib and vix.dll
  • vixCOM.dll
  • libvixAllProducts.so
  • libvix.so

Redistribution of the open source libraries included with the VIX API is governed by their respective open source license agreements.

The VIX API also includes sample code, which you can use as a starting point for your own programs. Code is delivered in the Samples directory installed with VMware VIX. A Makefile is provided for Linux, and an nMakefile for Windows.


Installing the VIX API

On the VMware Server or VMware Workstation host, you do not need to install any additional VIX API components. Vix libraries are installed by default under “VMware VIX” or vmware-vix. To compile programs on these systems


To control VMware Server remotely from another machine, you need header files vix.h and vm_basic_types.h, as well as one or more library files. You can get these files in one of two ways: Use the Vix standalone installer to get the files needed to compile a program


Using the Windows Standalone Installer

To install the VIX API files on Windows:

  1. Download the installer program to your Desktop.
  2. Double-click the installer icon to run the graphical installer.

To uninstall the VIX API, go to Start > Settings > Control Panel and use the Add/Remove Programs control panel.


Using the Linux Standalone Installer

To install the VIX API files on Linux:

  1. Download the tar-gzip package. For example:
    wget http://www.vmware.com/downloads/server/VMware-vix-110068.i386.tar.gz
  2. As superuser, extract the package:
    sudo tar zxpf VMware-vix-110068.i386.tar.gz
  3. Change directory and, as superuser, run the VMware installer:
    cd vmware-vix-distrib
    sudo ./vmware-install.pl
  4. Read the EULA and type "yes" if you agree to its terms. You can accept most defaults by typing Enter when prompted.

To uninstall the VIX API, run the vmware-uninstall-vix.pl script. The uninstaller is at /usr/bin/vmware-uninstall-vix.pl by default.


Upgrading an Earlier Installation

If you are using older Vix libraries, VMware recommends that you upgrade those libraries using the standalone installer. The standalone installer provides a current version of the wrapper library, which allows programs to communicate with any Vix library, regardless of version or target architecture. The wrapper library dynamically loads appropriate library files at connection time.

Otherwise you must link your program to a Vix library that matches the server version. This gets inconvenient if your program communicates with more than one version of the server.

VMware Tools in virtual machines should be kept up-to-date with the VMware version on the host. When upgrading, also update VMware Tools in all guest operating systems. The VIX API relies on a current matching version of VMware Tools to perform many operations.

Upgrading the Vix libraries replaces the older header files, vix.h and vm_basic_types.h with newer header files. The header files are installed at the following locations by default:

  • On a Windows system:
    • C:\Program Files\VMware\VMware VIX\vix.h
    • C:\Program Files\VMware\VMware VIX\vm_basic_types.h
  • On a Linux system:
    • /usr/include/vmware-vix/vix.h
    • /usr/include/vmware-vix/vm_basic_types.h

Whether or not you use the wrapper library, your programs may call only the functions supported by the host. If you communicate with an older host, you cannot use newer features.


Sample Vix Programs

On Windows, the sample programs are installed in C:\Program Files\VMware\VMware VIX\Samples by default. An nMakefile is provided to compile all sample programs using nmake and the Visual Studio C compiler.

On Linux, the sample programs are installed in /usr/share/doc/vmware-vix/VMwareVix/samples/ by default. A Makefile is provided to compile all sample programs using make and the GNU C compiler.

Compiling on Windows With Wrapper Library

To use the wrapper library with VIX 1.6, you need Visual Studio 2005 (Visual C release 8.0) or later. To compile code on Windows using the wrapper library, use the following procedure. Files are in the C:\Program Files\VMware\VMware VIX folder.

  1. Add the header file to an include statement in your source code:
  2. #include "vix.h"
    ... program code here ...
  3. Compile for, and link with, the multithreaded version of the C runtime library. For Workstation 6.0.1 and later, you may use either the debug or the non-debug version of this library. For Workstation 6.0.0 and earlier, you must use the non-debug version.
    • To compile and link with the debug version (libcmtd.lib) use compiler options /MTd /nodefaultlib:libcmtd.lib.
    • To compile and link with the non-debug version (libcmt.lib) use compiler options /MT /nodefaultlib:libcmt.lib.
  4. Compile code to link with these files:
    • VixAllProducts.lib for non-debug, or VixAllProductsd.lib for debug.
    • kernel32.lib
    • user32.lib
    • advapi32.lib
    • ole32.lib
    • oleaut32.lib
    • ws2_32.lib
    • shell32.lib

Compiling on Linux With Wrapper Library

This procedure assumes that you have installed Vix components in the default directories. If you made different choices during the installation, specify your directory choices instead.

  1. Add an include statement in your source code for the header file:
    #include "vix.h"
    ... program code here ...
  2. Compile your application, linking to the wrapper library and dynamic load library:
    $ gcc -I/usr/include/vmware-vix vixapp.c -o vixapp -lvixAllProducts -ldl

Compiling on Windows Without Wrapper Library

If you do not use the wrapper, you need to link the appropriate Vix libraries for the VMware product to which your Vix program connects. Workstation 6.5 is able to link a debug version of the C runtime library.

To compile your code for use with Workstation 6.5:

  1. Make the required DLL files available to your program, either by placing them in the same directory as your executable, or by placing them in the system directory (C:\WINDOWS\system32). The easiest option is to copy DLL files from the directory C:\Program Files\VMware\VMware VIX\Workstation-6.5.0\32bit or 64bit.
    • vix.dll (or vixd.dll if you are using debug C runtime library)
    • iconv.dll (or inconvd.dll if you are using debug C runtime library)
    • libxml2.dll (or libxml2d.dll if you are using debug C runtime library)
    • libeay32.dll
    • ssleay32.dll
    • vmcryptolib.dll
    • zlib1.dll
  2. Add the header file to an include statement in your source code:
    #include "vix.h"
    ... program code here ...
  3. Compile your code to link in vix.lib statically.
  4. Compile for, and link with, the multithreaded version of the C runtime library. You may use either the debug or the non-debug version of this library.
    • To compile and link with the debug version (libcmtd.lib) use compiler option /MTd with Microsoft Visual Studio.
    • To compile and link with the non-debug version (libcmt.lib) use compiler option /MT with Microsoft Visual Studio.

To compile your code for use with Workstation 6.0.x:

  1. Make the required DLL files available to your program, either by placing them in the same directory as your executable, or by placing them in the system directory (C:\WINDOWS\system32). The easiest option is to copy DLL files from the directory C:\Program Files\VMware\VMware VIX\ws-2\32bit or ws-3\32bit.
    • vix.dll
    • iconv.dll
    • libxml2.dll
    • libeay32.dll
    • ssleay32.dll
    • vmcryptolib.dll
    • zlib1.dll
  2. Add the header file to an include statement in your source code:
    #include "vix.h"
    ... program code here ...
  3. Compile your code to link in vix.lib statically.
  4. Compile for, and link with, the multithreaded version of the C runtime library. You must use the non-debug version of this library (libcmt.lib) by using compiler option /MT with Microsoft Visual Studio.

To compile your code for use with VMware Server 1.0:

  1. Make the following DLL files available to your program, either by placing them in the same directory as your executable, or by placing them in your system directory (C:\WINDOWS\system32). The easiest option is to copy DLL files from the directory C:\Program Files\VMware\VMware VIX\server-1\32bit.
    • vix.dll
    • ssleay32.dll
    • libeay32.dll
  2. Add the header file to an include statement in your source code:
    #include "vix.h"
    ... program code here ...
  3. Compile your code to link in vix.lib statically.

Compiling on Linux Without Wrapper Library

To compile your code with VMware Server or VMware Workstation installed:

  1. Add an include statement in your source code for the header file:
    #include "vix.h"
    ... program code here ...
  2. Compile your application, linking statically to libvix.so, as in the following examples.
    • To link the VMware Workstation library on a 32-bit machine:
      gcc -I/usr/include/vmware-vix -o vixapp vixapp.c /usr/lib/vmware-vix/Workstation-6.5.0/32bit/libvix.so
    • To link the VMware Server 2.0 library on a 32-bit machine:
      gcc -I/usr/include/vmware-vix -o vixapp vixapp.c /usr/lib/vmware-vix/lib/VIServer-2.0.0/32bit/libvix.so
    • To link the old VMware Server 1.x library:
      gcc -I/usr/include/vmware-vix -o vixapp vixapp.c /usr/lib/vmware-vix/lib/server-1/32bit/libvix.so
Thanks : VMware.com

วันจันทร์ที่ 2 พฤศจิกายน พ.ศ. 2552

Howto automount all my hdd

*First mount all the drives manually.*


then,open the "* Run Application Window *",for this press " *Alt+F2* " to open it.
then write there " *gksu nautilus* ", a window will be appeared and press
the "*up*" button once.

open the file "*mtab* " from " *etc* " folder
here you can see some text like this ,

/dev/sda8 /media/PHOTO vfat rw,nosuid,nodev,uhelper=hal,shortname=mixed,uid=1000,utf8,umask=077,flush 0 0
/dev/sda5 /media/SONGS vfat rw,nosuid,nodev,uhelper=hal,shortname=mixed,uid=1000,utf8,umask=077,flush 0 0

copy those texts and paste it *at the end *of a file named "*fstab*", you
can find the file into the " *etc* " folder.


How to automount all Harddisk on ubuntu

*First mount all the drives manually.*


then,open the "* Run Application Window *",for this press " *Alt+F2* " to open it.
then write there " *gksu nautilus* ", a window will be appeared and press
the "*up*" button once.

open the file "*mtab* " from " *etc* " folder
here you can see some text like this ,

/dev/sda8 /media/PHOTO vfat rw,nosuid,nodev,uhelper=hal,shortname=mixed,uid=1000,utf8,umask=077,flush 0 0
/dev/sda5 /media/SONGS vfat rw,nosuid,nodev,uhelper=hal,shortname=mixed,uid=1000,utf8,umask=077,flush 0 0

copy those texts and paste it *at the end *of a file named "*fstab*", you
can find the file into the " *etc* " folder.

Thanks : ubuntu.com

How to format a thumb drive on ubuntu

First make sure USB thumb drive is not mounted. Click on Places > Computer > Select USB thumb drive > Right click > Select Unmount Volume.

Let us assume that /dev/sda1 is your partition name for USB thumb drive. To format type the following command


$ sudo mkfs.ext3 /dev/sda1


Now use e2label command to change the filesystem label on the ext3 filesystem located on device /dev/sda1:


$ sudo e2label /dev/sda1 usb-thumbdrive


You can also create an MS-DOS/Windows XP file system under Linux, enter:


$ sudo mkfs.vfat /dev/sda1


Thanks : cyberciti.biz

How to format a new hard disk on ubuntu

How to format a new hard disk on ubuntu

Let's get going!

Removing and creating a partition
Having decided your drive's name (let's call it sda) we must now remove the default partition that the manafacturer put there:
Code:
sudo fdisk /dev/sda
This will start fdisk. We want to remove the partion(s), there should only be one.
Press d (for delete).
It might ask you for the partition number, press 1 and enter. If there are more then delete them too.

Now to make a new partition.
Press n (for new), then p (for primary), then 1 and then simply press enter for the next two questions.
This will make a new partition that uses the entire disk. If you want more complex partitioning then read the fdisk manual (man fdisk) or use parted or some other app.
Here's what we did with n, the values will differ from yours:
Code:
Command (m for help): n                                                    
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (197-621, default 197):
Using default value 197
Last cylinder or +size or +sizeM or +sizeK (197-621, default 621): +128M
Now to write the new partion and exit, press w and enter.
You should be ready to make a filesystem now.

Making a filesystem : "Formatting"
You need to put a system in-place, on the disk, such that it can handle files. This is called (unsurprisingly) a filesystem.
The one we are going to use is called "ext3". On Gnu/Linux we are spoiled for choice and there are loads of filesystems you can use, go do some research if you want to.
So, let's make the filesystem:
Code:
sudo mkfs.ext3 /dev/sda1
* Note the 1 at the end, because we are making the filesystem in that partition (thanks Mike)

Now it will go off and do strange stuff, simply wait for it to finish.

Using the new file system
Well, at this point you should be able to right-click on the icon (on your Desktop) and choose "mount" (I assume that's the verb it will present to you). After that you should be able to open a window and use the drive*
* all this assumes it's an external USB drive.
If you cannot then you will need to mount it yourself, try:
Code:
sudo mkdir /media/sda1
sudo mount /dev/sda1 /media/sda1
Note: We are actually mounting the first partition on the drive, hence the 1 at the end: sda1
And the mounted directory can be anywhere you like, but its common location is /media.


Or Use GUI

Install
Code:
sudo apt-get install gparted
sudo gparted
Note: Open from System => Administration => Partition Editor

And Mount your Partition with
Code:
sudo mkdir /media/sda1
sudo mount /dev/sda1 /media/sda1
Note: /dev/sda1 is your new partition

Thanks : ubuntuforums.org || answers.yahoo.com

วันอังคารที่ 20 ตุลาคม พ.ศ. 2552

Introduction to Ultra Monkey

Ultra Monkey: High Availability and Load Balancing Solution for Linux

[Monkey]


Overview

Cluster Network Services
Ultra Monkey is a project to create load balanced and highly available network services. For example a cluster of web servers that appear as a single web server to end-users. The service may be for end-users across the world connected via the internet, or for enterprise users connected via an intranet.


Diagram: Sample Ultra Network

1. An end-user sends a packet to the virtual service
2. Ultra Monkey selects a server and forwards the packet
3. The server replies
4. Ultra Monkey forwards this reply back to the end-user

Flexible
Ultra Monkey makes use of the Linux operating system to provide a flexible solution that can be tailored to a wide range of needs. From small clusters of only two nodes to large systems serving thousands of connections per second.


Open Source Working with Your Network

Use Any Operating System
While the Ultra Monkey software itself runs on Linux, it is able to provide clustering for virtually any network services running on an operating system that can communicate using TCP or UDP. This means almost any operating system, including Windows™, Solaris™ and of course Linux itself.

Supports a Wide Range of Protocols
Ultra Monkey supports a wide range of protocols, with native health checks for: Web, Mail, FTP, News, LDAP and DNS. Other protocols can be suported using a non-native health check or by adding a custom health check.

Open Source
Ultra Monkey is open source. It makes use of software from various open source projects including The Linux Virtual Server and Heartbeat. Members of the Ultra Monkey project actively contribute to the open source projects whose software is used. Horms, the Ultra Monkey project lead, is one of the core members of the development teams for both Heartbeat and The Linux Virtual Server.


Easy to Install and Maintain

Download, Install, Configure, Project Complete!

Supported Distribitions
Ultra Monkey provides binary packages for a selected list of distributions. Source packages are also available. At this time the following distributions are supported:

  • Debian Woody (Stable 3.0)
  • Debian Sid (Unstable/Testing)
  • Fedora Core 1
  • Red Hat Enterprise Linux 3.0
  • Red Hat 9
  • Red Hat 8.0
  • Red Hat 7.3

Updates
The Ultra Monkey team tracks software packages and releases updates for security or other critical bugs. This includes the kernel as Ultra Monkey provides a kernel patched with The Linux Virtual Server and other related patches. Announcements of these updates packages are available in the News Archive.

Documentation
Ultra Monkey also provides concise documentation in English and Japanese to allow system administrators to easily install and configure an Ultra Monkey cluster. The documentation is available online at www.ultramonkey.org and ultramonkey.jp. Ultra Monkey does not however place restrictions on the way that the underlying software and Linux itself is used, allowing users to customise the system to their needs.


Key Features

Download

The current release is Ultra Monkey 3 which has been built and tested on Debian Sarge and Red Hat Enterprise Linux 3.0. It includes comprehensive documentation on the software included, the technologies used and how to configure a highly available and/or load balanced network. more....

The previous release, 2.0.1, is also available, though new deployments are incouraged to use Ultra Monkey 3. more....

Miscellaneous

The history lists all releases of Ultra Monkey.

More Information

For more information please see the Ultra Monkey web site.


Thanks : ultramonkey.org/

วันศุกร์ที่ 16 ตุลาคม พ.ศ. 2552

Squid Analysis Report Generator ( SARG ) Tool For Enterprise

ความสำเร็จในการนำลีนุกซ์มาใช้ในองค์กร

คุณสมชาย โสภิตปิยกุล
Thai Yazaki Corporation Co.,Ltd

"เรื่องราวของการประยุกต์ใช้งานลีนุกซ์เป็น Proxy Server อีกหนึ่งบริการพื้นฐานที่ทุก ๆ องค์กรจำเป็นต้องใช้งาน "

ใน วันนี้การเชื่อมโยงองค์กรเข้าสู่อินเตอร์เน็ตดูเหมือนเป็นเรื่องธรรมดาเป็น เสียแล้ว ทุก ๆ หน่วยงานในองค์กรมีความต้องการที่จะใช้งานอินเตอร์เน็ตเพิ่มขึ้น จนกลายเป็นส่วนหนึ่งของการทำงานประจำวัน ที่ฝ่ายคอมพิวเตอร์จะต้องจัดสร้างระบบขึ้นเพื่อรองรับความต้องการดังกล่าว

เรื่อง ราวของลีนุกซ์โซลูชั่นในฉบับนี้ จะนำเรื่องราวความสำเร็จของลีนุกซ์ในองค์กรเอกชน บ.ไทยยาซากิ จก. ผู้ผลิตสายไฟฟ้า สวิทช์ไฟฟ้ารายใหญ่ของเมืองไทย ซึ่งมีบริษัทในเครืออีกประมาณ 6 บริษัท และมีจำนวนเครื่องลูกข่ายมากกว่า 100 เครื่อง จึงต้องมีใช้ซอฟต์แวร์ในส่วนงานต่าง ๆ เป็นจำนวนมาก รวมทั้งต้องอาศัยการสื่อสารที่มีประสิทธิภาพเพื่อการประสานงานอย่างเป็นระบบ ภาระหน้าที่ของเจ้าหน้าที่ผู้อยู่เบื้องหลังคงหนีไม่พ้นฝ่ายคอมพิวเตอร์และ ไอทีนั่นเอง

ไม่เพียงด้านประสิทธิภาพของงาน และความเชื่อถือได้ของระบบเท่านั้น การเลือกใช้ซอฟต์แวร์ที่เหมาะสมกับองค์กรเป็นอีกภาระกิจหนึ่งของฝ่าย คอมพิวเตอร์ทุกคนที่จะสามารถช่วยลดต้นทุนและสร้างผลกำไรให้เกิดขึ้นแก่ องค์กรได้ จึงเป็นเหตุผลสำคัญที่ทำให้ระบบปฏิบัติการลีนุกซ์ได้รับการคัดเลือกเพื่อนำ มาใช้งานเป็นเซิร์ฟเวอร์ในองค์กรแห่งนี้

อินเตอร์เน็ตเกตเวย์ และ Proxy Server

การ สื่อสารใช้งานอินเตอร์เน็ตถือเป็นงานบริการพื้นฐานที่พนักงานทุกคนจะต้อง สามารถเข้าถึงและใช้งานได้อย่างสะดวก ไม่ว่าจะเป็นการสืบค้นข้อมูลจากเว็บไซต์ต่าง ๆ การติดต่อด้วยอีเมล์ เพื่อทำให้งานในส่วนต่าง ๆ สามารถดำเนินไปได้ตามเป้าหมายของบริษัท สำหรับโซลูชั่นที่จะสนองความต้องการเช่นนี้ ลีนุกซ์สามารถทำหน้าที่เป็นอินเตอร์เน็ตเซิร์ฟเวอร์ได้เป็นอย่างดีอยู่แล้ว โดยอาศัยคุณสมบัติของ Packet Filter เช่น โปรแกรม ipchains หรือ NetFilter / iptables เครื่องพีซีธรรมดาก็จะทำงานเป็น NAT ( Network Address Translation ) ช่วยให้เครื่องลูกข่ายในเน็ตเวิร์กทั้งหมดออกสู่อินเตอร์เน็ตพร้อมกันด้วย โมเด็มหรือเราต์เตอร์เพียงชุดเดียวเท่านั้น

ถึงแม้ว่า เครื่องลูกข่ายทั้งหมดจะสามารถใช้งานอินเตอร์เน็ตได้อย่างที่ต้องการแล้วก็ ตาม แต่ก็ยังมีบางสิ่งที่ควรเสริมเข้าไปอีกคือ คุณสมบัติในด้านการจำกัดสิทธิที่จะเข้าถึงเว็บไซต์บางแห่งที่มีเนื้อหาไม่ สมควรเข้าชม การจำกัดยูสเซอร์ใช้งานในเวลาที่นอกเหนือจากเวลางาน หรือข้อจำกัดอื่น ๆ ที่ทำให้สิ้นเปลืองค่าใช้จ่ายไปโดยไม่ก่อให้เกิดประโยชน์ คุณสมบัติเช่นนี้ลำพังอินเตอร์เน็ตเกตเวย์คงยังไม่เพียงพอ จะต้องอาศัยพร๊อกซี่เซิร์ฟเวอร์ ( Proxy Server ) เข้ามาช่วยเสริมอีกแรงหนึ่ง ซึ่งภายในลีนุกซ์ทุกดิสทริบิวชั่นจะมีโปรแกรมพร๊อกซี่เซิร์ฟเวอร์ที่มี ประสิทธิภาพสูงให้มาพร้อมแล้ว คือ โปรแกรม Squid

โปรแกรม Squid เป็น Proxy Server ที่มีคุณสมบัติในการจำกัด ควบคุมการแอกเซสเข้าสู่เว็บไซต์ภายนอกองค์กรได้เป็นอย่างดีและมีประสิทธิภาพ ที่เรียกว่า Access Control List ( ACL ) ซึ่งเป็นการนิยามชื่อลิสต์ขึ้นแทนคุณสมบัติของสิ่งที่ต้องการอ้างอิง จากนั้นจึงตั้งข้อกำหนดลงไปว่าต้องการให้ลิสต์นั้นสามารถแอกเซสผ่านพร๊อกซี่ ได้หรือไม่ ตัวอย่างเช่น

acl floor1 src 192.168.1.0/255.255.255.0
acl blacklist urlpath_regex sex hack casino chat download
http_access deny blacklist
http_access allow floor1

  • จะมีความหมายดังนี้ - floor1 เป็นชื่อลิสต์ที่ตั้งขึ้นมา หมายถึง ทุกโฮสต์ที่อยู่ในเน็ตเวิร์ก 192.168.1.0
  • blacklist เป็นชื่อลิสต์ที่เป็นตัวแทนของ URL ที่มีคำว่า sex hack casino chat download เป็นส่วนประกอบ
  • ในบรรทัดที่ 3 เป็นการกำหนดว่า หากผู้ใช้งานอินเตอร์เน็ตต้องการเข้าสู่เว็บที่ตรงกับลิสต์ชื่อ blacklist ให้ปฏิเสธทันที
  • ส่วนบรรทัดที่ 4 เป็นการกำหนดว่า หากผู้ใช้งานอินเตอร์เน็ตเป็นโฮสต์ที่ตรงตามลิสต์ floor1 จะยินยอมให้แอกเซสพร๊อกซี่ ( ยินยอมให้เข้าไปสู่อินเตอร์เน็ต ) ได้
ดังนั้นการที่เสริมการทำงานของอินเตอร์เน็ตเซิร์ฟเวอร์ด้วย Squid Proxy Server จึงเป็นการควบคุมการเข้าสู่อินเตอร์เน็ตของผู้ใช้งานในองค์กรได้ตามต้องการ และยังช่วยเพิ่มประสิทธิภาพให้แก่ระบบอีกด้วยเพราะ Squid จะมีคุณสมบัติเป็น HTTP Object cache ที่ช่วยเก็บข้อมูลจากเว็บไซต์ภายนอกไว้ในหน่วยความจำ ( RAM และฮาร์ดดิสก์ ) ของตัวเซิร์ฟเวอร์เองอีกด้วย ช่วยให้การเรียกเว็บไซต์ที่เคยเข้าถึงมาก่อนทำได้รวดเร็วยิ่งขึ้นเนื่องจาก มีข้อมูลบางส่วนของเว็บเพจที่ยังคงอยู่ในแคชนั่นเอง

ข้อมูลการแอกเซสสู่เว็บไซต์
เนื่อง จาก Squid Proxy Server ทำหน้าที่เป็นประตูที่กั้นกลางระหว่างผู้ใช้งานภายในองค์กร กับเครือข่ายอินเตอร์เน็ตภายนอก ดังนั้นข้อมูลจากล๊อกไฟล์ของ Squid ที่จะมีการบันทึกไว้ทุก ๆ ครั้งที่เครื่องลูกข่ายมีการร้องขอเพื่อเข้าสู่เว็บไซต์ต่าง ๆ จึงเป็นข้อมูลที่เป็นประโยชน์ต่อผู้ดูแลระบบในการวิเคราะห์ดูพฤติกรรมการใช้ งานอินเตอร์เน็ตได้เป็นอย่างดี โดยจะสามารถเฝ้าดูความเคลื่อนไหวของล๊อกไฟล์ดังกล่าวได้ด้วยคำสั่ง

# tail -f /var/log/squid/access.log

คำ สั่งดังกล่าวจะทำการรายงานข้อมูลล่าสุดจากล๊อกไฟล์ของ Squid คือ /var/log/squid/access.log อย่างต่อเนื่อง ( เป็นผลมาจากพารามิเตอร์ -f ของคำสั่ง tail หมายถึง Follow ) ผลลัพธ์จะปรากฏดังตัวอย่างดังรูป



จาก รูปจะเห็นว่าเราสามารถทราบได้ว่าโฮสต์หมายเลข 192.168.0.9 ในเครือข่ายของเรา ออกไปชมเว็บไซต์ใดบ้าง โหลดไฟล์ใดมีขนาดเท่าไหร่บ้าง ไฟล์ access.log ของ Squid นี้จะอยู่ในรูปของไฟล์ข้อความธรรมดา ดังนั้นเราจึงสามารถอ่านได้โดยตรง และโดยปรกติแล้วไฟล์นี้จะมีการเปลี่ยนชื่อไฟล์ที่บันทึกข้อมูลเองโดย อัตโนมัติ โดยอาศัยบริการชื่อ logrotate ทุก ๆ สัปดาห์

สร้างรายงานที่ดีกว่าด้วย SARG

ถึง แม้ว่าการอ่านล๊อกไฟล์ของ Squid จะทำให้เราทราบการเรียกใช้งานเว็บไซต์ต่าง ๆ ของผู้ใช้ในระบบได้ก็ตาม แต่ก็ได้ข้อมูลที่ใช้ประโยชนได้ไม่มากนัก ทั้งนี้เนื่องจากเป็นข้อมูลดิบเกินไป รูปแบบก็อ่านได้ยาก ดังนั้นจึงมีโปรแกรมโอเพ่นซอร์สที่ถูกพัฒนาขึ้นเพื่อการวิเคราะห์ และสร้างรายงานในรูปแบบที่สะดวกต่อการนำข้อมูลมาใช้งานมากยิ่งขึ้น โปรแกรมประเภทนี้มีอยู่หลายตัว แต่ที่น่าสนใจและนำมาใช้งานได้อย่างดี คือ โปรแกรม SARG ( Squid Analysis Report Generator )

SARG เป็นโปรแกรมที่ออกแบบมาเพื่อทำงานร่วมกับ Squid โดยจะทำการวิเคราะห์ข้อมูลจากล๊อกไฟล์ของ Squid แล้วนำมาสร้างรายงานข้อมูลเชิงสถิติในหลาย ๆ ด้านเพื่อให้ผู้ดูแลระบบสามารถอ่านข้อมูลได้อย่างง่ายดายในรูปของเอกสารเว็บ เพจ ( HTML ) ดังนั้นจึงง่ายต่อการนำเสนอผ่านเว็บเซิร์ฟเวอร์ ( Apache Web Server ) ซึ่งลีนุกซ์เองมักจะติดตั้งให้มาพร้อมอยู่แล้วเช่นเดียวกับซอฟต์แวร์สำคัญ อื่น ๆ



รูปแผนผังการทำงานของ SARG ร่วมกับบริการ Squid และ Apache
ผู้ ดูแลระบบจึงสามารถมอนิเตอร์ดูข้อมูลสถิติการใช้งานเว็บไซต์ต่าง ๆ ผ่านทางโปรแกรมเว็บบราวเซอร์ได้จากเครื่องคอมพิวเตอร์เครื่องใดก็ได้ในเครือ ข่าย แน่นอนว่าจะสั่งพิมพ์รายงานนั้น ๆ ออกมาได้ไม่ยากเช่นกัน แต่ถ้าหากข้อมูลเหล่านี้ต้องการปิดเป็นความลับ ( ไม่ต้องการให้ผู้ใช้งานทั่วไปเปิดดูรายงานนี้ได้ ) ก็ควรป้องกันด้วยการควบคุมการเข้าถึงเว็บเซิร์ฟเวอร์ ( Host Access Control ) หรือกำหนด Restriction เฉพาะบุคคลที่ได้รับอนุญาติเท่านั้นก็ได้ ( HTTP User Authentication ) ซึ่งเป็นคอนฟิกในส่วนความปลอดภัยของเว็บเซิร์ฟเวอร์นั่นเอง

การติดตั้งและคอนฟิก SARG
โปรแกรม SARG นี้เป็นซอฟต์แวร์โอเพ่นซอร์ส สามารถหาดาวน์โหลดได้จากเว็บไซต์ของผู้พัฒนาโปรแกรมโดยตรงที่ http://web.onda.com.br/orso/ ซึ่งมีซอฟต์แวร์ที่น่าสนใจให้ดาวน์โหลดมาใช้งานได้ฟรีอีกหลายตัวทีเดียว สำหรับ SARG จะมีไฟล์ที่ให้เลือกดาวน์โหลดทั้งแบบที่เป็น Tarball และเป็นแพคเกจ RPM ในที่นี้ผู้เขียนเลือกที่จะติดตั้งจากไฟล์ชนิด Tarball ซึ่งโปรแกรมนี้สามารถทำงานได้ดีบน Red Hat Linux ทุกรุ่นรวมทั้ง รุ่น 9.0 ซึ่งเป็นรุ่นปัจจุบันที่ผู้เขียนใช้ในการทดสอบครั้งล่าสุดนี้ด้วย

หลัง จากดาวน์โหลดไฟล์โปรแกรม sarg-1.4.1.tar.gz ขนาด 123KB มาแล้ว การติดตั้งสามารถทำได้ง่ายมาก โดยใช้คำสั่ง Tar แตกไฟล์ออกมาจะปรากฏเป็นไดเร็คทอรี่ sarg-1.4.1 ให้เข้าไปในไดเร็คทอรี่นี้ แล้วพิมพ์คำสั่งตามลำดับนี้

# ./configure
# pico Makefile แก้ไขข้อความบรรทัด MANDIR ตามรูป
หลัง จากที่ใช้คำสั่ง ./configure แล้ว จำเป็นต้องปรับแก้ไขตำแหน่งของ Man page ของโปรแกรม SARG เล็กน้อย โดยแก้ไขข้อความบรรทัด MANDIR = /usr/local/man/man1 เป็น MANDIR = /usr/share/man/man1 แล้วบันทึกไว้ก่อนจะทำการคอมไพล์โปรแกรมต่อไป



ลำดับต่อมาให้พิมพ์คำสั่ง make และ make install ตามลำดับ โปรแกรมจะได้รับการคอมไพล์และติดตั้งในที่ ๆ กำหนดไว้ดังนี้

ตัวโปรแกรม SARG อยู่ที่ /usr/bin/sarg
คอนฟิกไฟล์อยู่ที่ /usr/local/sarg/sarg.conf

การ คอนฟิกเบื้องต้นเพื่อให้ SARG ทำงานได้ใน Red Hat 9.0 จะต้องแก้ไขไฟล์คอนฟิกเล็กน้อย โดยใช้ Text Editor ที่คุณถนัดแก้ไขไฟล์ /usr/local/sarg/sarg.conf ที่บรรทัดข้อความต่อไปนี้ โดยค้นหาแล้วลบเครื่องหมาย # ที่คอมเมนต์ไว้ออก และแก้ไขตำแหน่งอ้างอิงใหม่ให้ตรงกับความเป็นจริงในระบบของเรา

access_log /var/log/squid/access.log
output_dir /var/www/html/squid_reports

มี ข้อควรระวังคือ อย่าให้มีเครื่องหมายวรรค ( space ) หรือ Tab อยู่ท้ายบรรทัดข้อความทั้งสองเด็ดขาด มิฉะนั้นโปรแกรมจะทำงานผิดพลาด จุดนี้ทำให้ผู้เขียนเสียเวลาไปพอสมควรที่เดียว

ต่อจากนั้นให้ ทดสอบการทำงานของ SARG โดยพิมพ์คำสั่ง sarg แล้วกด Enter เพื่อให้ทำการสร้างรายงานเป็นครั้งแรก โดยก่อนจะทดสอบเช่นนี้ได้จะต้องมีการรัน Squid ให้บริการไปแล้วซักระยะหนึ่งเพื่อให้มีข้อมูลปรากฏอยู่ใน access.log ของ Squid เสียก่อน หาก SARG สามารถทำงานได้อย่างถูกต้องจะปรากฏไฟล์ที่เป็นเว็บเพจขึ้นที่ output_dir ดังรูป



ตั้งเวลากระตุ้น SARG ด้วย cron
โดย ปรกติ แล้ว เราควรให้ SARG สรุปรายงานให้ทุก ๆ ช่วงเวลา เช่น สรุปทุก ๆ วันเป็นต้น ดังนั้นจึงต้องใช้โปรแกรม crond ซึ่งเป็น Schedule Jab Daemon ช่วยในการกระตุ้นให้ SARG วิเคราะห์สรุปรายงานของ Squid ในเวลาเที่ยงคืนของทุกวัน โดยเพิ่มข้อความต่อไปนี้ลงในไฟล์ /etc/crontab

0 0 * * * root /usr/bin/sarg

หาก โปรแกรม Apache Web Server ในเครื่องเซิร์ฟเวอร์ลีนุกซ์ของเราทำงานอยู่ตามปรกติ ผู้ใช้งานจะสามารถเปิดหน้าเว็บเพจของ SARG ที่รายงานสถิติของ Squid ได้ผ่านโปรแกรมเว็บบราวเซอร์ทั่วไป มีหน้าจอที่รายงานข้อมูลให้หลากหลายรูปแบบ ดังรูปต่อไปนี้





สถิติเครื่องลูกข่าย( หรือยูสเซอร์ ) ที่ใช้งานเว็บมากที่สุด





รายชื่อเว็บไซต์ที่มีการเรียกใช้งานมากที่สุด







100 อันดับเว็บไซต์ที่ผู้ใช้นิยมเข้าชม




หน้าแรกของ SARG จะแสดงเรียงตามวันที่สรุปรายงาน


เปิดใจ..เปิดเผยซอร์สโค๊ดสู่เสรีภาพ
โปรแกรม SARG หรือ Squid Analysis Report Generator เป็นเครื่องมือสำหรับผู้ดูแลระบบเครือข่ายอีกชิ้นหนึ่งที่จะช่วยให้ทราบการ ใช้งานอินเตอร์เน็ตของยูสเซอร์ในองค์กรได้อย่างเป็นรูปธรรม ต้องขอขอบคุณประสบการณ์ที่เป็นประโยชน์อย่างยิ่งจากคุณสมชายที่ได้เอื้อ เฟื้อข้อมูลเกี่ยวกับการประยุกต์ใช้งานลีนุกซ์และซอฟต์แวร์โอเพ่นซอร์สใน บริษัท ถึงแม้ว่าจะมีเสรีภาพของการเผยแพร่มากแค่ไหนก็ตาม คุณค่าของซอฟต์แวร์โอเพ่นซอร์สไม่มีทางที่จะถูกนำมาใช้ประโยชน์ในวงกว้างได้ เลย หากปราศจากความรู้ความเข้าใจในวัฒนธรรมของสังคมโอเพ่นซอร์ส และความเสียสละจากพวกเราทุกคน
รูปแบบการประยุกต์ใช้งานลีนุกซ์ ในโซลูชั่นระดับองค์กรมีอีกมากมาย ท่านผู้อ่านสามารถติดตามได้จากเว็บไซต์ของผู้เขียน http://www.itdestination.com ในฉบับหน้าจะเป็นโซลูชั่นในด้านไหนโปรดติดตามในตอนต่อไป ฉบับนี้สวัสดีครับ


Thanks : คุณสมชาย โสภิตปิยกุล

วันอังคารที่ 13 ตุลาคม พ.ศ. 2552

How To Use iptables for Linux Firewalls

How To Use iptables

You can start, stop, and restart iptables after booting by using the commands:
# service iptables start
# service iptables stop
# service iptables restart


To get iptables configured to start at boot, use the chkconfig command:.
# chkconfig iptables on

You can determine whether iptables is running or not via the service iptables status command. Fedora Core will give a simple status message. For example
# service iptables status

iptables Won't Start
# touch /etc/sysconfig/iptables
# chmod 600 /etc/sysconfig/iptables
# service iptables start

Example : Allowing WWW And SSH Access To Your Firewall
#---------------------------------------------------------------
# Allow previously established connections
# - Interface eth0 is the internet interface
#---------------------------------------------------------------

iptables -A OUTPUT -o eth0 -m state --state ESTABLISHED,RELATED \
-j ACCEPT

#---------------------------------------------------------------
# Allow port 80 (www) and 22 (SSH) connections to the firewall
#---------------------------------------------------------------

iptables -A INPUT -p tcp -i eth0 --dport 22 --sport 1024:65535 \
-m state --state NEW -j ACCEPT
iptables -A INPUT -p tcp -i eth0 --dport 80 --sport 1024:65535 \
-m state --state NEW -j ACCEPT

And More at linuxhomenetworking.com

How to Disable SELinux ?

How to Disable SELinux

SELinux หรือ Security Enhanced Linux ซึ่งเป็นระบบรักษาความปลอดภัยแบบเข้มข้น
ออกแบบและพัฒนาโดยสำนักงานความมั่นคงแห่งชาติสหรัฐ (NSA)

SELinux ทำให้เรื่องที่คอนฟิกง่าย ๆ กลายเป็นยุ่งยากขึ้นถนัดตา เนื่องจากมีการเช็คความถูกแบบละเอียดมาก

จะแก้ไขผ่าน Cmd หรือ Gui ก็แล้วแต่ถนัดครับ
nano /etc/sysconfig/selinux หรือ vi /etc/sysconfig/selinux แล้วแต่ถนัด

เสร็จแล้วแก้ค่าจาก
SELINUX=enforcing
เป็น
SELINUX=disabled

แล้วก็ reboot server 1 ครั้ง

Thanks : thaiadmin.org

Basic Cmd of Linux's firewall with Iptables

คำสั่งที่มีการใช้งานบ่อย ๆ ใน iptables

1. การเรียกดู List ของ chains

# iptables -L

หากว่าเราสั่งคำสั่งแบบนี้จะเป็นการดู chains ใน tables filter หากต้องการดู List ใน tables อื่นให้สั่งตามนี้
# iptables -L -t nat
จะเป็นการดู chains ใน tables nat

2. การยกเลิก chains ทั้งหมด
# iptables -F
เป็นการสั่งลบ chains ทั้งหมดใน tables filter

# iptables -F -t nat
เป็นการสั่งลบ chains ทั้งหมดใน tables nat

3. การเพิ่ม chains ต่าง ๆ
# iptables -A INPUT -p tcp --dport ftp -j DROP
ตามตัวอย่าง จะเป็นการสั่งให้ เพิ่ม chains INPUT เข้าไปใน tables filter โดย
-p หมายถึง protocol tcp
--dport หมายถึง destination port หรือ port ที่เข้ามา
-j หมายถึง targets ที่จะระบุว่าจะให้ ทำอย่างไรหากตรวจสอบพบ
และในตัวอย่างนี้เป็นการตรวจสอบ chains INPUT ที่เข้ามาใน tables INPUT
โดยการเข้ามานั้นตรวจสอบที่ protocal tcp/ip ที่ ports ftp (21) หากตรวจสอบพบให้ ปิด (DROP)

4. การแทรก chain ต่าง ๆ
# iptables -I INPUT --dport ftp -j ACCEPT

5. การลบ chain ที่ไม่ต้องการ
# iptables -D INPUT --dport ftp -j ACCEPT

และ iptables จะทำการตรวจสอบคำสั่งจาก chains ก่อนหน้าที่สั่งไปหา chains สุดท้าย หรือเรียกง่าย ๆ ว่าทำงานแบบ top - down

การ config firewall แบบง่าย ๆ
ต่อไปนี้จะแนะนำการทำ Server Firewall ของระบบอย่างง่าย ๆ ครับ พิมพ์คำสั่งตามนี้เลยครับ

# echo 1 > /proc/sys/net/ipv4/ip_forward
#iptables -F
#iptalbes -F -t nat
#iptables -t nat -A POSTROUTING -j MASQUERADE
#iptables -A INPUT -p tcp --dport http -j ACCEPT
#iptables -A INPUT -p udp --dprot domain -j ACCEPT
#iptables -A INPUT -j DROP
*จากคำสั่งด้านบนจะเป็นการเปิดให้บริการ http และ dns เท่านั้น หากต้องการเพิ่มอะไรอีกก็ใส่แทรกเข้าไปได้เลย

แต่ถ้าเราทำการ Reboot เครื่องใหม่ config ต่าง ๆ ก็จะหายไปครับ วิธีการไม่ให้มันหายไปให้เราไปเพิ่ม config ต่อท้ายไฟล์ rc.local อยู่ที่ห้อง /etc/rc.d เพี่ยงเท่านี้เราก็มี Firewall ใช้แล้ว

Thanks :
งานสารสนเทศทางวิศวกรรมศาสตร์

Detail of Service of Fedora for security

รายละเอียดของแต่ละ service ที่มาจากการติดตั้ง Fedora 9 แบบไม่เลือก Package Group ใดๆ เลย พร้อมคำแนะนำว่าจะปิดหรือเปิด service สำหรับการใช้งาน

NetworkManager
เป็น service ที่สามารถปรับเปลี่ยนคอนฟิกของ network เพื่อให้ต่อเชื่อมกับ network เช่น WiFi ได้อย่างอัตโนมัติ
คำแนะนำ

* ปิด – สำหรับ server
* เปิด – สำหรับ notebook ที่มีการเปลี่ยนที่ใช้งานเป็นประจำ

acpid
เป็น service สำหรับตรวจสอบสถานะของเครื่อง โดยจะใช้ได้สำหรับ BIOS บางรุ่น วิธีทดสอบง่ายๆ คือเข้าไปดูใน /proc/acpi/ แล้วใช้คำสั่ง cat ดูไฟล์ต่างๆ ว่าสามารถตรวจสอบสถานะของอุปกรณ์ได้หรือไม่
คำแนะนำ

* เปิด – สำหรับเครื่องที่ตรวจสอบสถานะได้
* ปิด – ถ้าเราไม่สนใจตรวจสอบ

anacron
การปิด/เปิด บ่อยๆ อาจทำให้ crontab ที่ตั้งไว้ไม่สามารถทำงานได้เลย เช่นโดยดีฟอลต์แล้วจะมี crontab รันอยู่ทุกวันเวลา 4:02 AM แต่ถ้าเราไม่ได้เปิดเครื่องเวลานี้ crontab นี้ ก็จะไม่ถูกรันเลย
คำแนะนำ

* เปิด – สำหรับ notebook, desktop ที่มีการปิด/เปิด อยู่เรื่อยๆ
* ปิด – สำหรับ server ที่เปิดเครื่องตลอดเวลา

atd
เป็น service สำหรับการตั้งเวลาในการรันโปรแกรมได้ ซึ่งตามประสบการณ์ส่วนตัวของผมแล้ว แทบไม่เคยใช้เลย
คำแนะนำ

* ปิด – ยกเว้นมีคนต้องการใช้จริงๆ

avahi-daemon
ใช้สำหรับหาอุปกรณ์เช่น printer, scanner ที่เชื่อมอยู่โดยอัตโนมัติ
คำแนะนำ

* ปิด – เวลาจะใช้อุปกรณ์ แล้วค่อยคอนฟิกเองดีกว่า

bluetooth
สำหรับเชื่อมต่อกับ bluetooth
คำแนะนำ

* ปิด – ยกเว้นต้องการใช้งาน

capi
สำหรับต่อเชื่อมอุปกรณ์ประเภท ISDN
คำแนะนำ

* ปิด

cpuspeed
เป็นการปรับความเร็วของ CPU ตามการใช้งาน
คำแนะนำ

* ปิด – สำหรับ server
* เปิด – สำหรับ notebook เพื่อการประหยัดไฟ

crond
เป็น service สำหรับการตั้งเวลาในการรันโปรแกรมต่างๆ จำเป็นต้องรันทุกเครื่อง
คำแนะนำ

* เปิดเท่านั้น

cups
สำหรับต่อเชื่อมกับ printer ไม่ว่าจะเป็นแบบต่อโดยตรง หรือสั่งผ่าน network
คำแนะนำ

* ปิด – ยกเว้นต้องการใช้งาน printer เช่น สั่งพิมพ์งานจากโปรแกรมที่รันอยู่ใน Linux

dund
เป็นโปรแกรมที่ทำให้สามารถสั่ง dial-up ได้ผ่านอุปกรณ์ Bluetooth
คำแนะนำ

* ปิด

gpm
ทำให้เราสามารถใช้ mouse ผ่านหน้าจอ console โดยตรงของเครื่องได้ เช่น copy, paste ไม่เกี่ยวกับใช้งาน mouse ผ่าน X Window หรือใช้งานผ่านโปรแกรมที่เรา Secure Shell เข้าไป
คำแนะนำ

* ปิด

haldaemon
ตรวจสอบสถานะของอุปกรณ์
คำแนะนำ

* เปิด

ip6tables
เป็น iptables firewall ที่รองรับ IPv6
คำแนะนำ

* ปิด – ไว้ IPv6 ใช้งานอย่างแพร่หลายแล้ว ค่อยมาว่ากันใหม่

iptables
ทำหน้าที่เป็น firewall
คำแนะนำ

* เปิด – โดยดีฟอลต์แล้ว จะอนุญาต เฉพาะ ping หรือ Secure Shell เข้ามายังเครื่องเราเท่านั้น แต่จากเครื่องเราสามารถออกไปข้างนอกได้หมด

irda
รองรับพอร์ต Infrared
คำแนะนำ

* ปิด

irqbalance
เพิ่มประสิทธิภาพในการทำงานสำหรับเครื่องที่มี multiprocessor ซึ่งรวมทั้ง multi-core ด้วย
คำแนะนำ

* เปิด – ยกเว้นเครื่องจะเก่ามากเป็นแบบ CPU เดียว

isdn
รองรับอุปกรณ์ ISDN
คำแนะนำ

* ปิด

mdmonitor
ตรวจสอบสถานะของ Software RAID ซึ่งไม่รวมถึง Hardware RAID
คำแนะนำ

* ปิด – ยกเว้นในเครื่องมีคอนฟิกฮาร์ดดิสก์เป็นแบบ Software RAID

messagebus
สำหรับส่งข้อมูลระหว่างโปรแกรม
คำแนะนำ

* เปิด

microcode_ctl
สำหรับปรับปรุงค่าใน CPU Intel เท่านั้น
คำแนะนำ

* เปิด – สำหรับ CPU Intel

multipathd
รองรับการเชื่อมต่อกับ Multi-path Storage Device พร้อมๆ กันหลายเครื่องได้
คำแนะนำ

* ปิด – ยกเว้นมีการเชื่อมต่อกับอุปกรณ์ประเภทนี้

netconsole
สำหรับส่ง console logging ผ่าน network
คำแนะนำ

* ปิด

netfs
เป็น service สำหรับใช้งานดิสก์ (mount) ผ่านทาง network ไม่ว่าจะเป็น NFS, Samba
คำแนะนำ

* ปิด

netplugd
ตรวจสอบและเปลี่ยนค่าคอนฟิกของ network interface เมื่อมีการเปลี่ยนแปลงสถานะ
คำแนะนำ

* ปิด

network
คอนฟิกค่า IP Address, Subnet mask และอื่นๆ สำหรับการเชื่อมต่อกับ network
คำแนะนำ

* เปิดเท่านั้น – ยกเว้นคุณต้องการให้เครื่องอยู่อย่างโดดเดี่ยว (standalone) ไม่คุยกับใคร

nfs
nfslock
เป็น service เพื่อให้สามารถใช้งานดิสก์ผ่านทาง network แบบ NFS ได้
คำแนะนำ

* ปิด – ยกเว้นเมื่อต้องการใช้งาน

nscd
เก็บค่าสำรอง (cache) สำหรับข้อมูลเช่น password ในการใช้งาน NIS, LDAP
คำแนะนำ

* ปิด

pand
รองรับอุปกรณ์ bluetooth
คำแนะนำ

* ปิด

pcscd
มีไว้สำหรับรองรับอุปกรณ์ประเภท Smart Card ที่ต่อเชื่อมกับเครื่องโดยตรง
คำแนะนำ

* ปิด

psacct
เก็บข้อมูลการใช้งาน process ว่าผู้ใช้งาน ใช้คำสั่ง อะไรบ้าง เมื่อเวลาเท่าไร โดยถ้ารัน service นี้แล้ว เราสามารถใช้คำสั่ง lastcomm เพื่อดูข้อมูลย้อนหลังได้
คำแนะนำ

* ปิด – ยกเว้นมีนโยบายในการตรวจสอบจริงๆ

rdisc
ไว้สำหรับค้นหา router ที่ต่อเชื่อมกับ network โดยอัตโนมัติ
คำแนะนำ

* ปิด – แล้วคอนฟิกเองดีกว่า

restorecond
เป็น service สำหรับตรวจสอบสถานะและปรับปรุงคอนฟิกของ SELinux
คำแนะนำ

* เปิด – ถ้าคุณตัดสินใจใช้ SELinux

rpcbind
ทำหน้าที่จัดการโปรแกรม NFS, NIS เหมือนกับ portmap
คำแนะนำ

* ปิด

rpcgssd
rpcidmapd
rpcsvcgssd
เป็น service สำหรับ NFSv4
คำแนะนำ

* ปิด

rsyslog
เป็นโปรแกรมที่ใช้แทนที่ syslog สำหรับเก็บ log ของเครื่อง
คำแนะนำ

* เปิดเท่านั้น

saslauthd
รองรับโปรแกรมที่ใช้แบบ SASL เช่นโปรแกรมประเภท Mail Server
คำแนะนำ

* ปิด – แนะนำให้ปิดไว้ก่อน ถ้าจะคอนฟิก Mail Server แล้วค่อยมาเปิดกันอีกที

sendmail
โดยคอนฟิกที่มาตอนติดตั้ง จะทำหน้าที่เป็น Mail Server แต่ใช้งานเฉพาะในเครื่องเท่านั้น (localhost, 127.0.0.1) ไม่รองรับการเชื่อมต่อจากเครื่องอื่นๆ บางคนก็แนะนำให้เปิดไว้ เพราะจะมี log บางอย่างเช่น จาก crontab ส่งไปยัง root แต่ถ้าคุณไม่สนใจ log พวกนี้ ก็ปิดไปได้เลย
คำแนะนำ

* ปิด

smartd
มีไว้สำหรับตรวจสอบสถานะเช่นอุณหภูมิของฮาร์ดดิสก์ได้ แต่ดิสก์บางรุ่นก็ไม่รองรับ หรืออาจมีปัญหาในการรัน service นี้ได้
คำแนะนำ

* เปิด – สำหรับเครื่องที่ตรวจสอบสถานะได้ แล้วไม่มีปัญหาในการรัน

sshd
เป็น service ที่ทำให้เราสามารถที่จะ remote login แบบ Secure Shell เข้าไปในเครื่องได้ โดยใช้โปรแกรมเช่น PuTTY
คำแนะนำ

* เปิด – สำหรับ server
* ปิด – สำหรับ notebook, desktop ที่ใช้งานส่วนตัว และไม่ต้องการให้เครื่องอื่น remote เข้ามาได้

udev-post
ใช้ตรวจสอบ แก้ไข คอนฟิกของอุปกรณ์ที่มีการเปลี่ยนแปลงได้
คำแนะนำ

* เปิด

winbind
ทำงานร่วมกับ Samba File Sharing
คำแนะนำ

* ปิด

wpa_supplicant
เป็น service เพื่อรองรับการเชื่อมต่อกับ Wireless แล้วมีการใช้งานแบบ WPA
คำแนะนำ

* ปิด – สำหรับเครื่องที่ไม่ได้ใช้ Wireless ในการเชื่อมต่อ network

ypbind
ทำให้เครื่องเป็น NIS Client
คำแนะนำ

* ปิด


Thanks : spalinux.com

วันศุกร์ที่ 9 ตุลาคม พ.ศ. 2552

ฺBasic Firewall on iptables

เมื่อเรากำลัง ตรวจดู port ที่เปิดอยู่ของเครื่องของเราด้วย nmap localhost

ผลที่ได้ก็ประมาณนี้

*************************************************************
Starting Nmap 5.00 ( http://nmap.org ) at 2009-10-09 16:22 ICT
Warning: Hostname localhost resolves to 2 IPs. Using 127.0.0.1.
Interesting ports on localhost.localdomain (127.0.0.1):
Not shown: 981 closed ports
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
80/tcp open http
110/tcp open pop3
111/tcp open rpcbind
143/tcp open imap
443/tcp open https
465/tcp open smtps
587/tcp open submission
631/tcp open ipp
993/tcp open imaps
995/tcp open pop3s
5222/tcp open unknown
5269/tcp open unknown
5900/tcp open vnc
7025/tcp open unknown
7777/tcp open unknown
10024/tcp open unknown
10025/tcp open unknown

Nmap done: 1 IP address (1 host up) scanned in 0.33 seconds

*************************************************************


แล้วเราจะป้องกันเครื่องของเราได้อย่างไรหล่ะที่นี้ ลองมาดูกันนะ

1. ไปที่ iptables ซึ่งเป็น firewall ของเครื่องกันเลย

# vim /etc/sysconfig/iptables


-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 25 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 143 -j ACCEPT

-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited



หรือ ไม่ก็ลองดูว่า port นี้ process ตัวไหน เป็นคนทำงานอยู่ ก็ปิดมันซะ

# netstat -tanp

หรือ จะดูข้อมูลอย่างละเีอียด

# nmap -A -T4 localhost


ผลที่ได้ก็ประมาณนี้

****************************************************************
Starting Nmap 5.00 ( http://nmap.org ) at 2009-10-09 16:17 ICT
Warning: Hostname localhost resolves to 2 IPs. Using 127.0.0.1.
Stats: 0:01:59 elapsed; 0 hosts completed (1 up), 1 undergoing Script Scan
NSE Timing: About 92.31% done; ETC: 16:19 (0:00:02 remaining)
Interesting ports on localhost.localdomain (127.0.0.1):
Not shown: 981 closed ports
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 5.2 (protocol 2.0)
| ssh-hostkey: 1024 a6:1c:7d:c7:44:bf:fc:9e:29:a0:6b:a5:ae:ea:b5:d4 (DSA)
|_ 2048 4f:ee:5e:2e:e3:40:45:ef:ed:57:90:a5:b4:52:da:29 (RSA)
25/tcp open smtp Postfix smtpd
|_ smtp-commands: EHLO zimbra.agss.com, PIPELINING, SIZE 10240000, VRFY, ETRN, STARTTLS, ENHANCEDSTATUSCODES, 8BITMIME, DSN
80/tcp open http?
|_ html-title: Did not follow redirect to https://localhost/zimbra/?zinitmode=http and no page was returned.
110/tcp open pop3 Zimbra pop3d
|_ pop3-capabilities: USER STLS EXPIRE(31 USER) UIDL IMPLEMENTATION(ZimbraInc) XOIP TOP SASL
111/tcp open rpcbind
| rpcinfo:
| 100000 2,3,4 111/udp rpcbind
| 100024 1 42604/udp status
| 100000 2,3,4 111/tcp rpcbind
|_ 100024 1 58036/tcp status
143/tcp open imap Zimbra imapd
|_ imap-capabilities: CONDSTORE THREAD=ORDEREDSUBJECT ESEARCH STARTTLS BINARY UNSELECT LOGINDISABLED UIDPLUS SORT SEARCHRES ID SASL-IR WITHIN AUTH=X-ZIMBRA LIST-EXTENDED QUOTA QRESYNC CHILDREN ENABLE LOGIN-REFERRALS I18NLEVEL=1 RIGHTS=ektx ACL IDLE CATENATE IMAP4rev1 LITERAL+ ESORT NAMESPACE MULTIAPPEND
443/tcp open ssl/http Zimbra http config
|_ html-title: Zimbra Collaboration Suite Log In
465/tcp open ssl/smtp Postfix smtpd
|_ smtp-commands: EHLO zimbra.agss.com, PIPELINING, SIZE 10240000, VRFY, ETRN, AUTH PLAIN LOGIN, AUTH=PLAIN LOGIN, ENHANCEDSTATUSCODES, 8BITMIME, DSN
587/tcp open smtp Postfix smtpd
|_ smtp-commands: EHLO zimbra.agss.com, PIPELINING, SIZE 10240000, VRFY, ETRN, STARTTLS, ENHANCEDSTATUSCODES, 8BITMIME, DSN
631/tcp open ipp CUPS 1.4
993/tcp open ssl/imap Zimbra imapd
|_ imap-capabilities: CONDSTORE THREAD=ORDEREDSUBJECT ESEARCH AUTH=PLAIN SASL-IR IMAP4rev1 UNSELECT UIDPLUS SORT ID SEARCHRES WITHIN AUTH=X-ZIMBRA LIST-EXTENDED BINARY QUOTA QRESYNC CATENATE CHILDREN LOGIN-REFERRALS RIGHTS=ektx ACL I18NLEVEL=1 ENABLE IDLE LITERAL+ ESORT NAMESPACE MULTIAPPEND
995/tcp open ssl/pop3 Zimbra pop3d
|_ pop3-capabilities: USER EXPIRE(31 USER) UIDL IMPLEMENTATION(ZimbraInc) XOIP TOP SASL(PLAIN X-ZIMBRA)
5222/tcp open unknown
5269/tcp open unknown
5900/tcp open vnc VNC (protocol 3.7)
7025/tcp open lmtp Zimbra lmtpd
7777/tcp open socks5 (No authentication; connection not allowed by ruleset)
10024/tcp open smtp amavisd smtpd
| smtp-commands: EHLO [127.0.0.1], VRFY, PIPELINING, SIZE, ENHANCEDSTATUSCODES, 8BITMIME, DSN, XFORWARD NAME ADDR PORT PROTO HELO SOURCE
|_ HELP 2.0.0 See amavisd-new home page at: 2.0.0 http://www.ijs.si/software/amavisd/
10025/tcp open smtp Postfix smtpd
|_ smtp-commands: EHLO zimbra.agss.com, PIPELINING, SIZE 10240000, VRFY, ETRN, STARTTLS, ENHANCEDSTATUSCODES, 8BITMIME, DSN
3 services unrecognized despite returning data. If you know the service/version, please submit the following fingerprints at http://www.insecure.org/cgi-bin/servicefp-submit.cgi :
==============NEXT SERVICE FINGERPRINT (SUBMIT INDIVIDUALLY)==============
SF-Port80-TCP:V=5.00%I=7%D=10/9%Time=4ACEFFAF%P=i386-redhat-linux-gnu%r(Ge
SF:tRequest,117,"HTTP/1\.1\x20302\x20Found\r\nExpires:\x20Tue,\x2024\x20Ja
SF:n\x202000\x2020:46:50\x20GMT\r\nCache-Control:\x20no-store,\x20no-cache
SF:,\x20must-revalidate,\x20max-age=0\r\nPragma:\x20no-cache\r\nContent-Ty
SF:pe:\x20text/html;\x20charset=utf-8\r\nContent-Language:\x20en-US\r\nLoc
SF:ation:\x20https://127\.0\.0\.1/zimbra/\?zinitmode=http\r\nContent-Lengt
SF:h:\x200\r\n\r\n")%r(HTTPOptions,C7,"HTTP/1\.1\x20200\x20OK\r\nExpires:\
SF:x20Tue,\x2024\x20Jan\x202000\x2020:46:50\x20GMT\r\nCache-Control:\x20no
SF:-store,\x20no-cache,\x20must-revalidate,\x20max-age=0\r\nPragma:\x20no-
SF:cache\r\nAllow:\x20GET,\x20HEAD,\x20POST,\x20TRACE,\x20OPTIONS\r\nConte
SF:nt-Length:\x200\r\n\r\n")%r(RTSPRequest,2F,"HTTP/1\.1\x20400\x20Bad\x20
SF:Request\r\nConnection:\x20close\r\n\r\n")%r(X11Probe,2F,"HTTP/1\.1\x204
SF:00\x20Bad\x20Request\r\nConnection:\x20close\r\n\r\n")%r(FourOhFourRequ
SF:est,5BD,"HTTP/1\.1\x20404\x20Not\x20Found\r\nContent-Type:\x20text/html
SF:;\x20charset=utf-8\r\nContent-Language:\x20en-US\r\nContent-Length:\x20
SF:1356\r\n\r\n\n\n\n\n\n\n\n\n\nSF:ML\x20PUBLIC\x20\"-//W3C//DTD\x20HTML\x204\.01\x20Transitional//EN\">\n
SF:\n\n\n\n\n\n\n\n\n\n\n\x20\x20\x20\x20SF:"Content-Type\"\x20content=\"text/html;charset=utf-8\">\n\x20\x20\x20\x
SF:20404\x20-\x20Not\x20Found\n\x20\x20\x20\x20SF:e=\"viewport\"\x20content=\"width=320;\x20initial-scale=1\.0;\x20maximu
SF:m-scale=8\.0;\x20user-scalable=1;\">\n\x20\x20\x20\x20SF:escription\"\x20content=\"Zimbra\x20provides\x20open\x20source\x20serve
SF:r\x20and\x20client\x20software\x20for\x20messaging\x20and\x20collaborat
SF:ion\.\x20To\x20find\x20out\x20more\x20visit\x20http://www\.zimbra\.com\
SF:.\">\n\x20\x20\x20\x20SF:s\"\x20href=\"/zimbra/css/common,login,zhtml,skin\.css\?skin=&v=0909111
SF:85028\">\n\t\n\t\n\t\x20\x20\x20\x20\n\t\n\x20\x20\x20\x20SF:\"SHORTCUT\x20ICON\"\x20href=\"/zimbra/img/logo/favicon\.ico\">\nSF:>\n\n\n





\n<
SF:tr>\n==============NEXT SERVICE FINGERPRINT (SUBMIT INDIVIDUALLY)==============
SF-Port5222-TCP:V=5.00%I=7%D=10/9%Time=4ACEFFD2%P=i386-redhat-linux-gnu%r(
SF:Help,10,"")%r(X11Probe,10,"")%r(LPDStri
SF:ng,10,"")%r(TerminalServer,10,"");
==============NEXT SERVICE FINGERPRINT (SUBMIT INDIVIDUALLY)==============
SF-Port5269-TCP:V=5.00%I=7%D=10/9%Time=4ACEFFD2%P=i386-redhat-linux-gnu%r(
SF:Help,10,"")%r(X11Probe,10,"")%r(LPDStri
SF:ng,10,"")%r(TerminalServer,10,"");
Device type: general purpose
Running: Linux 2.6.X
OS details: Linux 2.6.15 - 2.6.27
Network Distance: 0 hops
Service Info: Hosts: zimbra.agss.com, 127.0.0.1

OS and Service detection performed. Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 127.55 seconds

*******************************************************************

Thanks : thaiadmin.org

DNS Server On Fedora Core 5

การติดตั้ง DNS Server ด้วย Fedora Core 5

การติดตั้ง DNS Server เพื่อใช้งานในเครือข่ายองค์กร และเครือข่ายอินเตอร์เน็ต ....

การติดตั้ง DNS Server ด้วย Fedora Core 5

1. ตรวจสอบ BIND packet ด้วยคำสั่ง ดังตัวอย่างนี้

[ root@kk ~ ]# rpm -qa bind
bind-9.3.2-4.1

ในการทดลองนี้ ได้ติดตั้งโปรแกรม BIND ไว้แล้วคือ bind-9.3.2-4.1 ซึ่งเป็นเวอร์ชั่น 9.3.2-4.1

2. หากยังไม่ได้ติดตั้งโปรแกรม BIND สามารถดาวน์โหลดได้ที่ http://fedora.redhat.com/download/ ซึ่งต้องดาวน์โหลดเป็นไฟล์ rpm และเป็น Fedora Core 5 หรือสูงกว่า เมื่อดาวน์โหลดเสร็จแล้ว ทำการติดตั้งด้วยคำสั่ง ดังตัวอย่างนี้

[ root@kk ~ ]# rpm -ivh bind-9.3.2-4.1.rpm

3. เพิ่มชื่อโดเมน และกลุ่ม IP address ที่ต้องการ ลงไปในไฟล์ named.conf ดังตัวอย่างนี้

3.1 ใช้คำสั่ง vi เพื่อแก้ไขไฟล์ named.conf ดังตัวอย่างนี้

[ root@kk ~ ]# vi /etc/named.conf

3.2 กดปุ่ม insert หรือ กด i เพื่อแทรกและแก้ไขข้อความ

3.3 จากนั้นเพิ่มกลุ่มโดเมนและ กลุ่มไอพีแอดเดรส ดังตัวอย่างนี้

zone "kk.koogle.com" IN {
type master;
file "koogle.com.zone";
allow-update { none; };
};

zone "0.168.192.in-addr.arpa" IN {
type master;
file "192.168.0.zone";
allow-update { none; };
};

3.4 บันทึกไฟล์ named.conf ด้วยคำสั่ง ดังนี้

3.4.1 กดปุ่ม Esc

3.4.2 ตามด้วยเครื่องหมาย : และ wq!

3.5 สร้างไฟล์ ossthailand.com.zone และไฟล์ 192.168.0.zone ดังตัวอย่างนี้

3.5.1 เข้าไปยังไดเรคเทอรี่ /var/named/chroot/var/named ดังตัวอย่างนี้

[ root@kk ~ ]# cd /var/named/chroot/var/named/

3.5.2 สร้างไฟล์ koogle.com.zone โดยการก๊อบบี้จากไฟล์ localhost.zone ดังตัวอย่างนี้

[ root@kk named ]# cp localhost.zone koogle.com.zone

3.5.3 สร้างไฟล์ 192.168.0.zone โดยการก๊อบบี้จากไฟล์ localhost.zone ดังตัวอย่างนี้

[ root@kk named ]# cp localhost.zone 192.168.0.zone

3.6 แก้ไขไฟล์ koogle.com.zone ดังตัวอย่างนี้

$TTL 86400
@ IN SOA kk.koogle.com. root.kk.koogle.com (
2007022201 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum

IN NS kk.koogle.com
koogle.com. IN NS kk.koogle.com
koogle.com. IN MX 5 mail.koogle.com

kk IN A 192.168.0.7
data IN A 192.168.0.1

www IN CNAME kk
ftp IN CNAME kk

3.7 แก้ไขไฟล์ 192.168.0.zone ดังตัวอย่างนี้

$TTL 86400
@ IN SOA kk.koogle.com. root.kk.koogle.com. (
2007022201 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum

IN NS kk.koogle.com

1 IN PTR data.koogle.com
7 IN PTR kk.koogle.com

3.8 เปิดการใช้งานโปรแกรม BIND ด้วยคำสั่ง ดังตัวอย่างนี้

[ root@kk named ]# /etc/init.d/named restart
Stopping named: [ OK ]
Starting named: [ OK ]

3.9 ทดสอบ Forward mapping ด้วยโปรแกรม BIND โดยคำสั่ง dig ดังตัวอย่างนี้

[ root@kk ~ ]# dig kk.koogle.com

3.9.1 โดยแสดงรายการดังนี้

; <<>> DiG 9.3.2 <<>> kk.koogle.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55458
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;kk.koogle.com. IN A

;; ANSWER SECTION:
kk.koogle.com. 86400 IN A 192.168.0.7

;; AUTHORITY SECTION:
koogle.com. 86400 IN NS kk.koogle.com.koogle.com.

;; Query time: 4 msec
;; SERVER: 192.168.0.7#53(192.168.0.7)
;; WHEN: Tue Mar 6 00:55:10 2007
;; MSG SIZE rcvd: 85

3.10 ทดสอบการทำงานโปรแกรม BIND ด้วยคำสั่ง nslookup ดังตัวอย่างนี้

[ root@kk ~ ]# nslookup
> kk.koogle.com <------- ใส่ชื่อโดเมนที่ต้องการตรวจสอบ
Server: 192.168.0.7
Address: 192.168.0.7#53
Name: cs.ossthailand.com
Address: 192.168.0.7


Thanks : kom.homelinux.org

Basic user command

How to linux (Case study จาก Redhat 6.2 ไปถึง Fedora Core 4)

คำสั่งสำหรับผู้ใช้พื้นฐาน (Basic user command)

  • คำสั่ง ls : : : แสดงรายชื่อแฟ้มในห้องปัจจุบัน หรือห้องอื่น ๆ ที่ต้องการ
  • คำสั่ง chmod : : : เปลี่ยนสถานะของแฟ้มเช่น Read Write eXecute
  • คำสั่ง man : : : แสดงรายละเอียดของคำสั่ง (Manual)
  • คำสั่ง mkdir, rmdir, cd : : : คำสั่งเกี่ยวกับ Directory หรือ Folder เพื่อสร้าง หรือลบ
  • คำสั่ง pico : : : editor ยอดฮิตใน Linux ที่ต้องมากับ Pine เป็น Text mode ที่ใช้ง่ายที่สุด
  • คำสั่ง emacs : : : editor ยอดฮิตใน Linux ใช้ยากกว่า pico นิดหน่อย
  • คำสั่ง vi : : : editor ยอดฮิตใน Linux ที่ใช้ยากที่สุด
  • คำสั่ง id, finger, who, w : : : โปรแกรมตรวจสอบ username ของตนเอง
  • คำสั่ง cat : : : แสดงข้อมูลในแฟ้มเหมือนคำสั่ง type ในระบบ DOS
  • คำสั่ง ifconfig : : : ดู IP หรือเพิ่ม IP เข้าไปใน linux server
  • คำสั่ง netstat : : : แสดงสถานะของเครือข่าย
  • คำสั่ง service : : : แสดงสถานะโปรแกรมที่เปิดให้บริการ
  • คำสั่ง xinetd : : : แสดงบริการที่เปิดใต้โปรแกรม xinetd
  • คำสั่ง whereis : : : ค้นหาแฟ้มที่ต้องการว่าอยู่ที่ห้องใด
  • คำสั่ง cp, rm, mv : : : จัดการแฟ้มเช่น คัดลอก ลบ และย้าย
  • คำสั่ง ping : : : ตรวจสอบ ip และการเชื่อมต่อ internet
  • คำสั่ง env : : : แสดงค่า environment ปัจจุบัน
  • คำสั่ง lynx : : : Text browser ที่ใช้งานง่าย ใช้ดู source หรือ download ได้
  • คำสั่ง nslookup : : : แสดงข้อมูลเกี่ยวกับ name server จาก ip หรือ domain name
  • คำสั่ง tail : : : แสดงส่วนท้ายของแฟ้มที่มีขนาดใหญ่ ต้องข้ามกับ cat ที่ดูตั้งแต่เริ่มแฟ้ม
  • คำสั่ง telnet : : : ใช้ติดต่อเข้า server ต่าง ๆ ตาม port ที่ต้องการ .
คำสั่งสำหรับผู้ใช้ระดับกลาง (Intermediate user command) เพื่อต้องการตรวจสอบระบบ
  • คำสั่ง df : : : แสดง partition ของ linux พร้อมขนาดที่ใช้ไป
  • คำสั่ง du : : : แสดงพื้นที่ใช้งานในแต่ละ Directory
  • คำสั่ง ps : : : แสดง process ที่กำลังทำงานอยู่ทั้งของเครื่อง และตนเอง
  • คำสั่ง kill : : : ยกเลิก process ที่ทำงานอยู่
  • คำสั่ง find : : : ค้นหาแฟ้มที่ต้องการภายในทุก ๆ directory ได้
  • คำสั่ง gzip : : : คลายการบีบอัด หรือแตกแฟ้มประเภท .gz
  • คำสั่ง tar : : : คลายการบีบอัด หรือแตกแฟ้มประเภท .tar
  • คำสั่ง last : : : แสดงรายชื่อผู้ใช้งานระบบปัจจุบันไปถึงอดีต
  • คำสั่ง grep : : : เลือกข้อความที่ต้องการภายในแต่ละบรรทัด
  • คำสั่ง date, hwclock : : : ใช้กำหนด หรือแสดงเวลาปัจจุบัน
  • คำสั่ง top : : : แสดง process ที่ทำงานในปัจจุบัน พร้อม refresh ตลอดเวลา
  • คำสั่ง ntsysv และ setup : : : กำหนดบริการที่ต้องการเปิด หรือปิด เช่น httpd หรือ vsftp เป็นต้น
  • คำสั่ง route : : : ใช้กำหนด แสดง ตารางเส้นทาง
  • คำสั่ง shutdown, reboot : : : ใช้ปิดเครื่อง หรือ ปิดและเปิดเครื่องใหม่อย่างถูกวิธี
  • คำสั่ง runlevel : : : คู่กับแฟ้ม /etc/inittab
  • คำสั่ง fsck : : : ซ่อมแซมระบบแฟ้มใน linux
  • คำสั่ง chown, chgrp : : : เปลี่ยนเจ้าของ หรือเปลี่ยนกลุ่ม
  • คำสั่ง chkconfig : : : กำหนด หรือแสดง บริการที่สั่งประมวลผลใน level ต่าง ๆ ขณะเปิดเครื่อง
  • คำสั่ง mount, umount : : : สั่งเชื่อมต่ออุปกรณ์ หรือ partition เช่น Diskette หรือ Handy drive เป็นต้น
  • คำสั่ง mkbootdisk : : : สร้างแผ่น boot disk เพื่อใช้ boot ระบบ linux ขึ้นมาภายหลัง
  • คำสั่ง traceroute : : : แสดงเลข ip ของเครื่องที่ถูกเชื่อมต่อ ไปยังปลายทางที่ต้องการ
  • คำสั่ง rpm : : : ใช้ตรวจสอบ เพิ่ม หรือลบ package ของระบบ linux เกือบทั้งหมด
  • คำสั่ง su : : : ขอเปลี่ยนตนเองเป็น Super user เพื่อใช้สิทธิสูงสุดในการบริหารระบบ ที่ผู้ใช้ปกติทำไม่ได้
  • คำสั่ง useradd : : : เพิ่มผู้ใช้รายใหม่เข้าไปในระบบ
  • คำสั่ง userdel : : : ลบผู้ใช้รายเดิม ออกจากระบบ
  • คำสั่ง usermod : : : แก้ไขข้อมูลของผู้ใช้ได้
  • คำสั่ง crontab : : : ตั้งเวลาสั่งงานคอมพิวเตอร์
  • คำสั่ง lspci : : : ตรวจสอบอุปกรณ์ที่เชื่อมต่อภายในเครื่อง
  • คำสั่ง nmap : : : ตรวจสอบเครือข่ายแบบกวาดทั้งในเครื่อง และ class C
Thanks : thaiabc.com

วันอังคารที่ 29 กันยายน พ.ศ. 2552

Linux networking tools

In this Daily Drill Down, I’ll introduce you to five network tools: ping, netstat, whois, nslookup, andfinger. Each of these tools has its own place in a LAN environment, though admittedly ping, netstat, whois, and nslookup are the most useful. These tools can be used to debug network connections in various ways.

ping
You can think of ping as network sonar. It sends out packets of information toward a server. If the remote server is online, ping reports back the number of bytes and time it took to get there. If the server is not online, it will give you an error message that the pinged server does not exist. Use this tool when you need a quick response to see that your network or your ISP's network is online; otherwise you’ll need to use other diagnostic tools.

The command-line structure of ping is
ping[-dfnqrvR] [-c count][-i wait interval ][-l preload] [-p pattern]
[-s packetsize] [-w waitsecs]


A typical readout of ping is shown here:
>ping localhost
> PING localhost.localdomain (127.0.0.1) from 127.0.0.1 :
56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=0 ttl=255 time=0.3 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=255 time=0.3 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=255 time=0.1 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=255 time=0.2 ms


Here we see that localhost.localdomain is connected. While ping will go on forever unless you hit [Ctrl]c, there’s another way to break out of an endless loop. You use the -c option, like so:
>ping -c 10 localhost
PING localhost.localdomain (127.0.0.1) from 127.0.0.1 :
56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=0 ttl=255 time=0.2 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=255 time=0.1 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=255 time=0.1 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=255 time=0.1 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=255 time=0.2 ms
64 bytes from 127.0.0.1: icmp_seq=5 ttl=255 time=0.1 ms
64 bytes from 127.0.0.1: icmp_seq=6 ttl=255 time=0.1 ms
64 bytes from 127.0.0.1: icmp_seq=7 ttl=255 time=0.2 ms
64 bytes from 127.0.0.1: icmp_seq=8 ttl=255 time=0.2 ms
64 bytes from 127.0.0.1: icmp_seq=9 ttl=255 time=0.1 ms
--- localhost.localdomain ping statistics ---
10 packets transmitted, 10 packets received, 0% packet loss
round-trip min/avg/max = 0.1/0.1/0.2 ms


If the time seems to remain constant while you’re connected to your ISP, this might mean that the network is jammed.

Why use ping?
If you were an administrator, why would you want to use ping? The answer is that it’s the first line of defense. If you’re not using NT, then ping will tell you quickly if you’re online by sending you packets. It gets your boss off your back when he’s having network problems and barking the question, “Is the network up?” By using ping, you can at least tell him “Yes” or “No.”

Many companies have a mail server with many individual computers connected to it via a proxy server on the network. The direct way to this mail server is to ping it, as shown here:
ping -d -c 25

This command will ping for 25 packets. I think this is a fair amount of packets to test to see whether or not you’re online.
The -d option is for debugging.
If you’re on a workstation and have a proxy IP, then you might try this:
ping -d -r -c 25

This command is nearly the same as the previous example except it will bypass the routing tables. If your e-mail server is online, ping will return packets; otherwise you’ll get an error. This method should work if you’re not an administrator.

Scenario
Your boss yells that he can't send e-mail. What do you do? Using ping can help you with the first steps. If the packets are constant, then there might be a lot of traffic. Tell him to wait and try to send again. If the packets aren't constant, further diagnosis is needed.

netstat
Another major network tool is netstat. The netstat tool can provide you with plenty of information about your network, including information about TCP and UNIX connections. It can also tell you about the status of all the interfaces on your server. Interfaces for Ethernet are identified as eth0, eth1, etc; PPP as ppp0, ppp1, etc; and slip as sl0, sl1, etc. So, if you have one Ethernet connection up and running in the Iface column, it will be shown as UP.

You use the netstat tool to check which of your connections are up. This tool is very useful in a large network setting where you have perhaps 30 or more machines connected to a server and don't have the time to check all of them. You could use netstat to find the bad connections and then use some other network software to reconnect the machine if it finds a software problem, or you could go to the machine yourself and fix the hardware and the software. One place where this would come in handy is on an archive server. If everyone complains that they can't back up their work, you could invoke netstat to see if the server is up and then fix the problem by whatever means possible.

Displaying interface statistics
Invoke netstat at the prompt as follows:
>netstat –I
Kernel Interface table
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg LRU
lo 3924 0 220 0 0 0 220 0 0 0
ppp0 1500 0 6 0 0 0 6 0 0 0


Let’s look at this command in detail:
  • The MTU and Met fields show the current metric values for the interface (Iface).
  • RX-OK/ERR represents received packets that are okay and those that have errors.
  • TX-OK/EER represents transferred packets that are okay and those that have errors.
  • RX-DRP represents received packets that have been dropped.
  • TX-DRP represents transferred packets that have been dropped.
  • The Flg column shows the flags that have been set for each interface. These values come ifconfig. The ones shown are one-character versions of long flag names:
    L means that this interface is a loopback device.
    R means that this interface is running.
    U means that this interface is up.
    P means that this is a point-to-point interface.
    O means that ARP is turned off for this interface.

Displaying connections
The netstat tool has options to display active and passive sockets. These options show TCP, UDP, RAW, and UNIX socket connections. The flags to show these options are -t, -u, -w, and -x. For example, invoking netstat -ta produces this output:
>netstat –ta
tcp 0 0 *:1052 *:* LISTEN
tcp 0 0 *:1051 *:* LISTEN
tcp 0 0 *:1050 *:* LISTEN
tcp 0 0 *:1049 *:* LISTEN
tcp 0 0 *:1048 *:* LISTEN
tcp 0 0 *:1047 *:* LISTEN
tcp 0 0 *:1040 *:* LISTEN
tcp 0 0 *:1025 *:* LISTEN
tcp 0 0 *:6000 *:* LISTEN
tcp 0 0 *:smtp *:* LISTEN
tcp 0 0 *:printer *:* LISTEN
tcp 0 0 *:linuxconf *:* LISTEN
tcp 0 0 *:auth *:* LISTEN
tcp 0 0 *:finger *:* LISTEN
tcp 0 0 *:login *:* LISTEN
tcp 0 0 *:shell *:* LISTEN
tcp 0 0 *:telnet *:* LISTEN
tcp 0 0 *:ftp *:* LISTEN
tcp 0 0 *:sunrpc *:* LISTEN


This output shows that all servers are simply waiting for an incoming connection. Here’s some more interesting data from these options:
>netstat –tw
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 1 g69-17.citenet.net:1063 cti13.citenet.net:finger SYN_SENT

  • Recv-Q represents the count of bytes not copied to this citenet.net socket.
  • Send-Q represents the count of bytes not acknowledged by citenet.net.

Displaying program connections
In order to display program connections with netstat, you use the -p option. A sample readout is shown here:
>netstat –p
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 1 [ ] STREAM CONNECTED 6974 554/gnome-smproxy @00000082
unix 1 [ ] STREAM CONNECTED 1622 615/asclock_applet @0000007b
unix 1 [ ] STREAM CONNECTED 1309 601/gmc @0000006a
unix 1 [ ] STREAM CONNECTED 593 512/X @0000003f
unix 0 [ ] STREAM CONNECTED 201 1/init [5] @0000002e
unix 1 [ ] STREAM CONNECTED 6712 663/xemacs @00000081
unix 1 [ ] STREAM CONNECTED 1324 601/gmc @0000006b
unix 1 [ ] STREAM CONNECTED 589 513/ @0000003e
unix 1 [ ] STREAM CONNECTED 1667 592/panel @00000080
unix 1 [ ] STREAM CONNECTED 677 558/ @0000004b
unix 1 [ ] STREAM CONNECTED 46050 554/gnome-smproxy @000000b7
unix 1 [ ] STREAM CONNECTED 1647 592/panel @0000007f
unix 1 [ ] STREAM CONNECTED 1595 615/asclock_applet @00000077
unix 1 [ ] STREAM CONNECTED 1465 612/gen_util_applet @0000006e
unix 1 [ ] STREAM CONNECTED 1294 601/gmc @00000068
unix 1 [ ] STREAM CONNECTED 1112 592/panel @0000005d


This readout shows that all the programs are connected with their PIDs and their names (Program name). All of the programs are connected to UNIX sockets.

Why use netstat?
Why would anyone want to use netstat? The answer is to debug networks. You might use this tool if you suspected that your network was sluggish. This tool becomes the next logical step in debugging a network. After using ping, I’d use netstat to check all network connections.

Scenario
You’re on a network and supposedly connected to the Internet. Your boss comes in and yells at you because the e-mail server isn't working.

Here’s one strategy you can use to find out why it isn’t working. First, check the routing table. Do you still have a network? You can find out by issuing the command netstat -nr. If, in the Flag column, a U appears for all the interfaces in the Iface column, then you’re in luck—your network works. If not, you have a problem. You must check each interface and reinstall it using ifconfig and route or some similar tool.

Next, do a general packet check. This check will display general information in a list format as shown here:
Use netstat –s
Ip:
8285 total packets received
0 forwarded
0 incoming packets discarded
120 incoming packets delivered
8252 requests sent out
Icmp:

Tcp:
515 active connection openings
0 passive connection openings
0 failed connection attempts
0 connection resets received
0 connections established
8158 segments received
8120 segments sent out
117 segments retransmitted
39 bad segments received
150 resets sent
Udp:


Check the tcp section, and look at the segments’ received rates. If the rates are low, the problem could exist within your network, or maybe it’s just that you’re on a slow line. If there’s simply a lot of traffic, then you can tell your boss to send the e-mail later.

If the number of failed connection attempts is high, then your ISP is most likely causing the problem. You can reboot the computer if you're on a Microsoft network.
Rebooting on a Linux network is not necessary.
After this, you might try issuing netstat -i. I discussed this option in a previous section. You’d want to use this option to inspect the RX-OK, RX-ERR, RX-DRP, TX-OK, TX-ERR, and TX-DRP packet metric values. If RX/TX-ERR is near zero, then you’re in good shape. If the RX-ERR value is high, the problem is line speed, the ISP, or traffic. If the TX-ERR value is high, then the problem could be your network. You’ll need to clean the cables and check all the routes.

Where would you apply netstat? You’d use netstat on the main e-mail server or any server that uses the Internet heavily. It could be used on a LAN not connected to the Internet, but the traffic should be fairly constant. In that case, you’d then use netstat -n to check your UNIX connections. This will show which streams are connected.

whois
The whois tool will give you addresses and information related to an Internet address, which is useful for security purposes. You can use it as a first line of defense against crackers if you can get their ISP number. Then, you can call up the ISP and complain!

Use the following command at the prompt to invoke whois:
whois .|com|net|org|edu

For example, whois xoom.com yields the following information:
#whois xoom.com
[rs.internic.net]
Whois Server Version 1.1
Domain names in the .com, .net, and .org domains can now be
registered with many different competing registrars.
Go to http://www.internic.net for detailed information.
Domain Name: XOOM.COM
Registrar: NETWORK SOLUTIONS, INC.
Whois Server: whois.networksolutions.com
Referral URL: www.networksolutions.com
Name Server: NAME.PHX.FRONTIERNET.NET
Name Server: NAME.ROC.FRONTIERNET.NET
Name Server: NS1.XOOM.COM
Name Server: NS2.XOOM.COM
Name Server: NS3.XOOM.COM


This information isn’t too interesting in itself, but it’s also useful for the next network tool.

Why use whois?
If you suspect that your network is being hacked, whois can give you the name of the ISP or their main branch. This is the ethical reason for using this tool. Another use is to get information on computers that access your server.

Let’s suppose that weird_do.org hacked your system. If you type:
whois weird_do.org

you'll see something like this:
[rs.internic.net]
Whois Server Version 1.1
Domain names in .com, .net, and .org can now be
registered with many different competing registrars.
Go to http://www.internic.net for detailed information.
WEIRD_DO.ORG.TOM_GUN.ORG
WEIRD_DO.ORG
OR
Domain Name :WEIRD_DO.ORG
Registrar: TOM_GUN.ORG
Whois Server:whois.TOM_GUN.org
Referral Server:whois.TOM_GUN.org
Referral URL: www.TOM_GUN.org
Name Server:NS1.WEIRD_DO.ORG
Name Server: NS2:WEIRD_DO.ORG
Update Date: 23-july-1999


You can also use whois for purposes other than security. This is very similar to the previous example. For instance, the site oceania.org has a link that will tell you what server you’re using as the browser and your screen resolution. It’s obvious that they’re using whois in a creative fashion.

nslookup
Another major network tool is nslookup. You can use this tool to verify the operation of your name server; nslookup allows you to search for all kinds of data relating to a name server. You can look up mail records (MX), NS records (records associated with the root domain), and Start Of Authority (SOA) records, just to name a few. And, nslookup works in two modes: interactive and non-interactive. So, to get these records to appear, at the interactive prompt, you’d type set type=MX for mail records, followed by the name of the name server (yours or another company for which you’d like to see MX records). A good use of nslookup is on an e-mail server. If people can't send their e-mail, perhaps the server is offline. Invoke nslookup to check on the status of a remote e-mail server in general and to check the MX records in particular. Possibly the company is going through changes, which could cause e-mail problems on the client's end.

Let’s look at the interactive mode. There are many options for this command—too many to look at them all. The nslookup command-line form is:
nslookup [-option,,,] [host-to-find | [-server] ]

For example, invoking nslookup at the prompt yields the following:
> nslookup xoom.com
Server: g29-151.citenet.net
Address: 205.151.205.151
Non-authoritative answer:
Name: xoom.com
Address: 206.132.179.136


The non-authoritative answer means that xoom.com isn't the official domain name used for this server. If you type nslookup at the prompt, the following occurs:
> nslookup
Server: g29-151.citenet.net
Address: 205.151.205.151


At this prompt, you type in the domain name, and it will respond with the name and address.

Suppose you now want to look up MX records. At the nslookup prompt, you type >set type=MX:
>set type=MX
> xoom.com
Server: g29-151.citenet.net
Address: 205.151.205.151
xoom.com preference=10 mail exchanger=mail4.xoom.com
xoom.com preference=0 mail exchanger=mail1-mx2.xoom.com
xoom.com preference=0 mail exchanger=mail1-mx3.xoom.com
xoom.com nameserver=ns1.xoom.com
xoom.com nameserver=ns2.xoom.com
xoom.com nameserver=name.roc.globalcenter.net
xoom.com nameserver=name.pbx.globalcenter.net
mail4.xoom.com internet address=206.57.66.73
mail1-mx2.xoom.com internet address=206.57.66.72


One other interesting use of nslookup is to look up SOA records. Look at this example:
>set type=SOA
xoom.com
Server: g29-151.citenet.net
Address: 205.151.205.151
Non-authoritative answer:
origin=lugh.xoom.com
mail address=dns.xoom.com
serial=20000011300
refresh=10800
retry= 1800
expire= 604800
minimum ttl=3600
Authoritative answers can be found from:
xoom.com nameserver=ns1.xoom.com
xoom.com nameserver=ns2.xoom.com
xoom.com nameserver=name.roc.globalcenter.net
xoom.com nameserver=name.pbx.globalcenter.net
xoom.com nameserver=ns1.nuq1.gctr.net
ns1.xoom.com internet address=206.132.185.58
ns2.xoom.com internet address=206.132.185.59
name.roc.globalcenter.net internet address=206.130.187.10
name.pbx.globalcenter.net internet address=206.165.6.10
ns1.nuq1.gctr.net internet address=206.216.163.20.


Another interesting thing you can do is use the d2 option to print extensive debugging information about your network if it gets gummed up.

Why use nslookup
Why would you want to use nslookup? This tool checks to see if your domain name server is in working order. It’s also good for finding information on other domain name servers. In all, it’s an extremely versatile tool.

There is an interesting use of finger in nslookup. Once the host is defined, you can use finger to check to see whether certain users exist on that machine if a finger server exists on the remote machine to which you’re connecting.

For debugging your own server, you can use the d2 and debug options. In interactive mode, enter the following:
>set debug
>set d2
> xoom.com
Session looks like
;;res_nmkquery(QUERY,xoom.com,IN,A)
---------
SendRequest, len 26
HEADER:
opcode=QUERY,id=51423 rcode=NO ERROR
header:FLAGS, query:want recursion
questions= 1, answers=0, authority, records=0, additional=0

QUESTION:
xoom.com, type=A class=IN
----------
----------
Got answer (248 bytes)
opcode=QUERY,id=51423 rcode=NO ERROR
header:FLAGS, query:want recursion
questions= 1, answers=1, authority, records=5, additional=5

QUESTION:
xoom.com type=A class =IN
ANSWERS:
-> xoom.com
type=A class=IN, dlen=4
internet address=206.132.179.136
ttl:2488(41m28s)
AUTHORITY RECORDS:
-> xoom.com
type=NS,class=IN, dlen=6
nameserver=ns1.xoom.com
ttl=545(9m5s)

ADDITIONAL RECORDS
->ns1.xoom.com
type=A class=IN, dlen=4
internet address=206.132.185.59
ttl:145483

->name.roc.globalcenter.net
type=A class=IN, dlen=4
internet address=209.130.187.10
ttl:2488(41m28s)
-------------
Server:xoom.com
Address:206.132.179.136
---------------


If your name server is messed up, your report will look similar to the report shown above. This example is meant to be instructive (in case you’ve never seen what the debug information looks like).

Scenario
Back to the scenario where your boss is yelling at you because the e-mail server isn't working. You can enter the following at the prompt (let’s say that the name of your ISP is boring_biz.net):
>nslookup
>>set q=mx

mail1-mx1.boring_biz.net internet address=201.00.34.23
mail2-mx2.boring_biz.net internet address 201.01.35.24

>>set q=any
>>mail2

Server: boring_biz.net
Address: 200.00.22.21


If you get this response
mail2:can’t find 201.00.34.23: non-existent host/domain

then your network has problems!

Your next step is to check to see if your network is up. Go into nslookup again (I’m assuming you exited it), and type
>nslookup
>>set q=any
>> .com, = your company's name


You should see
Server :.com
Address:xxx.yyy.zzz.aaa


If not, you have a problem. If you do see it, then at the prompt run:
>>set q=mx
>>.com


You should see a listing something like this:
mail-mx1..com internet address=bbbb.cccc.dddd.eeee
...


If not, there’s still a problem. Check the cables of your mail server or network card.

finger
The next tool is minor; finger has little use as far I can see. If you want to get the address or phone number of someone, then finger will be able to do it, assuming that you’re allowed access to the remote finger server.

The command-line structure of finger is
finger [-lmsp] [user...] [user@host...]

To best see how finger works, let's invoke it. At the prompt, type:
>finger –s

and you should see something like this:
Login Name Tty Idle Login Time Office Office Phone
kabir Larry Mintz 4 * Dec 24 20:46 (xxx)yyy-zzzz


Why use finger?
As far administration goes, finger doesn't really give much useful information. If you forgot the number of a user whose login name is hog, type:
>finger -s hog

which should report something like this:
Login Name tty idle login time Office Office #
hog Hoggish Greedly 3 * 9:15 WB34-1 666-6666


Conclusion
So many network tools exist to aid you in your network administration load. In this Daily Drill Down, I’ve shown how Linux (like UNIX) bears this weight with the help of a very powerful, yet simple-to-use set of network tools. These tools, ping, netstat, whois, nslookup, and finger, report a great deal of information to the administrator.

Larry Mintz is a Canadian citizen who does contract work on many levels. Larry holds a B.A. in mathematics from Concordia University, studies theoretical math, and has written solution manuals for many texts.

The authors and editors have taken care in preparation of the content contained herein but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability is assumed for any damages. Always have a verified backup before making any changes.

Thanks : articles.techrepublic.com