Suchart.Blog –> ITupstart.com

ธันวาคม 10, 2007

Kernel 2.6.23.9 + iptables 1.3.8 + L7-filter + ipp2p on Ubuntu 7.10 Server

Filed under: Linux,Ubuntu — suchart @ 12:53 am

โน้ตคำสั่งต่างๆ ที่ใช้ไว้ก่อนกันลืม

===============================================================

Update 20071223

พอดีว่า iptables 1.4.0 ออกมาแล้ว ผมได้ลองติดตั้งโดยวิธีนี้ สามารถติดตั้งได้โดยใช้

kernel 2.6.23.12

iptables 1.4.0 + netfilter-layer7-v2.17

patch-o-matic-ng-20071222 + IPP2P v0.8.1_rc1

Update 20071228

iptables 1.4.0 จะมีปัญหา ไม่สามารถใช้งานได้กับ ipp2p 

==============================================================

ในที่นี้ผมลองใช้ทั้ง L7-filter และ ipp2p ใครจะใช้อย่างใดอย่างหนึ่งก็ได้นะครับ

apt-get update
apt-get install build-essential
apt-get install kernel-package

ถ้าต้องการใช้คำสั่ง make menuconfig ติดตั้งตามคสั่งบรรทัดด้านล่าง

####################### apt-get install libncurses5-dev
ใช้คำสั่งบรรทัดด้านล่าง ถ้าต้อง kernel source ของ ubuntu (linux-source-2.6.22.tar.bz2)

###################### apt-get install kernel-source

cd /usr/src
wget http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.23.9.tar.bz2
tar xvjf linux-2.6.23.9.tar.bz2
ln -s linux-2.6.23.9 linux

wget http://jaist.dl.sourceforge.net/sourceforge/l7-filter/netfilter-layer7-v2.16.1.tar.gz
wget http://jaist.dl.sourceforge.net/sourceforge/l7-filter/l7-protocols-2007-11-22.tar.gz

wget http://iptables.org/projects/iptables/files/iptables-1.3.8.tar.bz2
wget ftp://ftp.netfilter.org/pub/patch-o-matic-ng/snapshot/patch-o-matic-ng-20071208.tar.bz2

tar xvzf l7-protocols-2007-11-22.tar.gz
tar xvzf netfilter-layer7-v2.16.1.tar.gz
tar xvjf patch-o-matic-ng-20071208.tar.bz2
tar xvzjf iptables-1.3.8.tar.bz2
ln -s iptables-1.3.8 iptables

cd /usr/src/linux
patch -p1 < ../netfilter-layer7-v2.16.1/kernel-2.6.22-2.6.23-layer7-2.16.1.patch

cd ../iptables
patch -p1 < ../netfilter-layer7-v2.16.1/iptables-1.3-for-kernel-2.6.20forward-layer7-2.16.1.patch
chmod +x extensions/.layer7-test

cd ../patch-o-matic-ng-20071208/
./runme –download
./runme ipp2p

cd /usr/src/linux
cp /boot/config-2.6.22-14-server ./.config
make oldconfig

เลือก m หรือ y ในหัวข้อที่เกี่ยวกับ layer 7 และ ipp2p ส่วนอันอื่นก็สามารถจะ enter ผ่านไปได้

คอมไพล์และสร้าง kernel image รอนานหน่อยนะครับ

make-kpkg clean
make-kpkg –initrd –append-to-version=-p2p kernel_image kernel_headers

cd /usr/src/iptables
make KERNEL_DIR=/usr/src/linux
make install

ต่อไปก็ติดตั้ง kernel ใหม่

cd ..
dpkg -i linux-image-2.6.23.9-p2p_2.6.23.9-p2p-10.00.Custom_i386.deb
dpkg -i linux-headers-2.6.23.9-p2p_2.6.23.9-p2p-10.00.Custom_i386.deb

cd /usr/src
tar xvzf l7-protocols-2007-11-22.tar.gz
mv /usr/src/l7-protocols-2007-11-22 /etc/l7-protocols

reboot

ลองทดสอบดู

iptables -m ipp2p –help
iptables -m layer7 –help

iptables -A FORWARD -m layer7 –l7proto bittorrent -j DROP
iptables -A FORWARD -m ipp2p –ipp2p -j DROP

root@myubuntu:/usr/src# iptables -L -n -v
Chain INPUT (policy ACCEPT 2385 packets, 153K bytes)
pkts bytes target prot opt in out source destination

Chain FORWARD (policy ACCEPT 17040 packets, 4942K bytes)
pkts bytes target prot opt in out source destination
484 36972 DROP all — * * 0.0.0.0/0 0.0.0.0/0 LAYER7 l7proto bittorrent
6 2106 DROP all — * * 0.0.0.0/0 0.0.0.0/0 ipp2p v0.8.1_rc1 –ipp2p

Chain OUTPUT (policy ACCEPT 2527 packets, 308K bytes)
pkts bytes target prot opt in out source destination

root@myubuntu:/usr/src# lsmod
Module Size Used by
ipt_MASQUERADE 4864 1
iptable_nat 8708 1
nf_nat 21036 2 ipt_MASQUERADE,iptable_nat
nf_conntrack_ipv4 19848 3 iptable_nat
xt_layer7 13700 1
nf_conntrack 67144 5 ipt_MASQUERADE,iptable_nat,nf_nat,nf_conntrack_ipv4,xt_layer7
nfnetlink 7192 3 nf_nat,nf_conntrack_ipv4,nf_conntrack
ipt_ipp2p 9600 1
iptable_filter 4224 1
ip_tables 15204 2 iptable_nat,iptable_filter
x_tables 16516 5 ipt_MASQUERADE,iptable_nat,xt_layer7,ipt_ipp2p,ip_tables

Update

ถ้า patch connlimit ด้วยจะคอมไพล์ kernel ไม่ผ่าน ใน kernel 2.6.23.9 ได้รวมไว้ใน kernel แล้ว สามารถเลือกเป็น module (m) ได้เลย แต่ว่าเท่าที่ผมได้ลอง iptables 1.3.8 จะยังไม่ support connlimit แต่ใน 1.4.0 rc1 จะสามารถใช้งานได้ แต่ไม่แน่ใจว่ามันจะมี bug ยังไงบ้างหรือเปล่า เพราะมันยังไม่ stable

root@myubuntu:/usr/src/iptables-1.3.8-ipp2p-L7# iptables -V
iptables v1.3.8
root@myubuntu:/usr/src/iptables-1.3.8-ipp2p-L7# iptables -m connlimit -h
iptables v1.3.8: Couldn’t load match `connlimit’:/usr/local/lib/iptables/libipt_connlimit.so: cannot open shared object file: No such file or directory

Try `iptables -h’ or ‘iptables –help’ for more information.
root@myubuntu:/usr/src/iptables-1.3.8-ipp2p-L7#

root@myubuntu:/usr/src/iptables# iptables -V
iptables v1.4.0rc1

root@myubuntu:/usr/src/iptables# iptables -m connlimit -h

……………………….

connlimit v1.4.0rc1 options:
[!] –connlimit-above n match if the number of existing connections is (not) above n
–connlimit-mask n group hosts using mask

Links

http://www.ipp2p.org/

http://l7-filter.sourceforge.net/

http://ubuntuforums.org/showthread.php?t=56835

http://www.kernel.org/

http://www.netfilter.org/

ธันวาคม 8, 2007

apt-get ผ่าน proxy

Filed under: Debian,Linux,Ubuntu — suchart @ 4:26 pm

export http_proxy=http://myusername:mypassword@myproxy:myproxy_port

sudo apt-get update

sudo apt-get install xxx

ธันวาคม 7, 2007

HP Pavilion dv2109tx + Ubuntu 7.10

Filed under: Linux,Ubuntu — suchart @ 3:06 pm

ได้ฤกษ์ยำ Notebook HP Pavilion dv2109tx เจ้าปัญหาของผมซักที ก่อนอื่นก็ใช้ Partition magic ย่อ Windows XP partition แล้ว ลง CentOS 5.1 ตามด้วย Ubuntu 7.10 ไว้ตัวละ partition ลงได้ไม่มีปัญหาอะไร นี่กะว่าถ้า FreeBSD 7 ออกเมื่อไร จะลงมันด้วยนะนี่

Ubuntu จะสร้างเมนูของ grub มีเมนูบูตทั้งของ XP และ CentOS ให้เรียบร้อยเลย

ลองเล่น Ubuntu ยังไม่ค่อยได้ทำอะไรมากนัก แค่ลองเล่นเน็ต ดูหนัง ฟังเพลง ได้ แต่กว่าจะทำให้เสียงออกลำโพงของ Notebook ได้ก็เล่นเอาเหนื่อยเลย โดยจากการลองผิดลองผิด อยู่นาน ก็พบว่า มันอยู่ที่ตัว PCM-2 โดยไปที่เมนู system -> preferences -> sound ต้องเลือก PCM และ PCM-2 ด้วย แล้วคลิกขวาที่รูปลำโพงที่มุมขวาแล้วเลือก open volume control แล้วไที่เมนู edit -> preferences แล้วเลือกทั้ง PCM และ PCM-2 ด้วย

Ubuntu 7.10 Firefox Flash Plugin

Filed under: Linux,Ubuntu — suchart @ 1:45 pm

ผมติดตั้ง flash plugin จาก firefox มีปัญหา มันติดตั้งได้ แต่ไม่ทำงาน เลยต้องหาวิธีติดตั้งแบบ manual

1. ไปที่ http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash

2. download .tar.gz

3. tar xvzf install_flash_player_9_linux.tar.gz

4. cd install_flash_player_9_linux

5. ./flashplayer-installer

6. ตัวติดตั้งจะบอกให้เราปิดเบราเซอร์

7. กำหนดไดเรกตอรีของ firefox เป็น /usr/lib/firfox

ตุลาคม 27, 2007

Ubuntu ไม่มีไฟล์ inittab !

Filed under: Linux,Ubuntu — suchart @ 1:53 pm

ใครที่เคยใช้ Redhat หรือ Debian พอมาใช้ Ubuntu จะหาไฟล์ /etc/inittab ไม่เจอแล้ว เนื่องจาก Ubuntu เปลี่ยนมาใช้ upstart รายละเอียดดูได้จาก http://upstart.ubuntu.com/

สำหรับการจัดการเซอร์วิสต่างๆ ของ Ubuntu ตอนสตาร์ทก็ยังสามารถใช้ sysv-rc-conf เช่นเดียวกับ Debian ผมเคยเขียนไปแล้วครับ ที่

โปรแกรม init, Runlevel และ Services

dos2unix บน Ubuntu มันอยู่ไหนหว่า?

Filed under: Linux,Ubuntu — suchart @ 1:36 pm

ช่วงหลังผมชักจะติดใจ Ubuntu ซะแล้ว มีบางครั้งที่ต้อง copy ไฟล์คอนฟิกที่แก้ไขบน Windows ไปใช้บน Ubuntu แต่หาคำสั่ง dos2unix เพื่อแปลงไฟล์ไม่เจอ จากการค้นหาโดยใช้ google ก็พบว่ามันอยู่ในแพคเกจ tofrodos สามารถติดตั้งโดยใช้คำสั่ง

sudo apt-get install tofrodos

ถ้าสงสัยว่ามันคืออะไร ดูรายละเอียดโดยใช้คำสั่ง ด้านล่าง

root@myubuntu:~# aptitude show tofrodos
Package: tofrodos
State: installed
Automatically installed: yes
Version: 1.7.6-2
Priority: optional
Section: utils
Maintainer: Florian Ernst <florian@debian.org>
Uncompressed Size: 69.6k
Depends: libc6 (>= 2.4-1)
Conflicts: sysutils (<= 2.0.0-1)
Description: Converts DOS <-> Unix text files, alias tofromdos
DOS text files traditionally have CR/LF (carriage return/line feed) pairs as their new line delimiters while Unix text files traditionally have LFs (linefeeds) to terminate each line.

Tofrodos comprises one program, “fromdos” alias “todos”, which converts text files to and from these formats. Use “fromdos” to convert DOS text files to the
Unix format, and “todos” to convert Unix text files to the DOS format.

This functionality is also available via the dos2unix/unix2dos symlinks.

Homepage: http://www.thefreecountry.com/tofrodos/index.shtml

พฤษภาคม 4, 2007

การจัดการแพคเกจใน Debian (Ubuntu)

Filed under: Debian,Linux,Ubuntu — suchart @ 4:24 am

การจัดการแพคเกจใน Debian (Ubuntu)

แพคเกจ ประกอบไปด้วยกลุ่มของไฟล์ที่จำเป็นในการดำเนินการอะไรบางอย่าง เช่น การติดตั้งโปรแกรม

ในลีนุกซ์ตระกูล Debian นั้น แพคเกจจะเป็นไฟล์ที่มีนามสกุล .deb ในขณะที่ Redhat จะมีนามสกุล .rpm

Debian(Ubuntu) Package Management Tools

มีเครื่องมือหลายตัวที่ใช้ในการจัดการแพคเกจทั้งในแบบคอมมานด์ไลน์และกราฟิก เครื่องมือระดับบนๆ ซึ่งมีความยืดหยุ่นมากกว่าจะอาศัยเครื่องมือระดับล่างในการทำงาน

เครื่องมือระดับบนๆ เช่น aptitude และ dselect จะอาศัย apt ในการทำงาน ในขณะที่ apt เองนั้นก็อาศัย dpkg ในการจัดการแพคเกจ

อ่านต่อ … https://suchart.wordpress.com/debianubuntu-package-management/

เมษายน 20, 2007

Ubuntu ใช้ root ไม่ได้ (sudo)

Filed under: Debian,Linux,Ubuntu — suchart @ 10:27 am

ใน Ubuntu นั้น เพื่อความปลอดภัยของระบบ โดยปกติจะไม่มีการใช้งานผู้ใช้งานที่ชื่อ root เนื่องจากในขั้นตอนการติดตั้งไม่มีการกำหนดรหัสผ่านให้ root (แต่ถ้าหลังจากติดตั้งเสร็จแล้ว มีการกำหนดรหัสผ่านให้ root ก็จะสามารถล็อกอินเป็น root ได้)

ถ้าจะต้องใช้คำสั่งที่ต้องใช้สิทธิ์ของ root จะต้องใช้ผ่านคำสั่ง sudo โดยหลังจากติดตั้งเสร็จผู้ใช้งานที่ถูกสร้างขึ้นในตอนติดตั้งเพียงคนเดียวเท่านั้นที่มีสิทธิ์รันคำสั่งในฐานะ root ถ้าต้องการให้ผู้ใช้งานคนอื่นสามารถทำได้ด้วย จะต้องกำหนดให้ผู้ใช้งานคนนั้นเป็นสมาชิกของกลุ่ม admin

อ่านต่อ … https://suchart.wordpress.com/sudo/

เมษายน 18, 2007

การขยายขนาด logical volumn ของ LVM แบบเร็วๆ

Filed under: Debian,Linux — suchart @ 9:01 am

การขยายขนาด logical volumn ของ LVM

มีลูกศิษย์ผม e-mail มาขอให้ผมช่วยแสดงวิธีขยายขนาด logical volume ให้ดูหน่อย ผมก็เลยบอกว่าจะเขียนอธิบายไว้ใน blog เผื่อคนอื่นจะได้ดูด้วย

ในที่นี้ผมจะทำแบบเร็วๆ ผมเพิ่มดิสค์ตัวที่ 2 (/dev/sdb) มีขนาด 80 GB

 

 

1. สร้าง partition ในดิสค์ตัวใหม่

mydebian2:~# fdisk /dev/sdb

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel. Changes will remain in memory only,

until you decide to write them. After that, of course, the previous

content won’t be recoverable.

The number of cylinders for this disk is set to 10443.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

(e.g., DOS FDISK, OS/2 FDISK)

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): p

Disk /dev/sdb: 85.8 GB, 85899345920 bytes

255 heads, 63 sectors/track, 10443 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

Command (m for help): m

Command action

a toggle a bootable flag

b edit bsd disklabel

c toggle the dos compatibility flag

d delete a partition

l list known partition types

m print this menu

n add a new partition

o create a new empty DOS partition table

p print the partition table

q quit without saving changes

s create a new empty Sun disklabel

t change a partition’s system id

u change display/entry units

v verify the partition table

w write table to disk and exit

x extra functionality (experts only)

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-10443, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-10443, default 10443):

Using default value 10443

Command (m for help):

Command (m for help): p

Disk /dev/sdb: 85.8 GB, 85899345920 bytes

255 heads, 63 sectors/track, 10443 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sdb1 1 10443 83883366 83 Linux

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

 

2. สร้าง physical volume ให้กับ partition ที่เพิ่งสร้างใหม่

mydebian2:~# pvcreate /dev/sdb1

Physical volume “/dev/sdb1” successfully created

 

3. ขยายขนาด volume group

mydebian2:~# vgscan

Reading all physical volumes. This may take a while…

Found volume group “mydebian2” using metadata type lvm2

mydebian2:~# vgextend

Please enter volume group name and physical volume(s)

vgextend: Add physical volumes to a volume group

vgextend

[-A|–autobackup y|n]

[-d|–debug]

[-h|–help]

[-t|–test]

[-v|–verbose]

[–version]

VolumeGroupName PhysicalDevicePath [PhysicalDevicePath…]

mydebian2:~# vgextend mydebian2 /dev/sdb1

Volume group “mydebian2” successfully extended

 

4. ขยายขนาด logical volume

mydebian2:~# lvscan

ACTIVE ‘/dev/mydebian2/root’ [119.03 GB] inherit

ACTIVE ‘/dev/mydebian2/swap_1’ [752.00 MB] inherit

mydebian2:~# lvextend -L+80G /dev/mydebian2/root

Extending logical volume root to 199.03 GB

Insufficient suitable allocatable extents for logical volume root: 1 more required

ขยายเพิ่ม 80 G ไม่ได้ เพราะไม่พอ ระบบใช้ไปแล้วส่วนหนึ่ง งั้นใช้ 79.99 G

mydebian2:~# lvextend -L+79.99G /dev/mydebian2/root

Rounding up size to full physical extent 79.99 GB

Extending logical volume root to 199.02 GB

Logical volume root successfully resized

mydebian2:~# lvscan

ACTIVE ‘/dev/mydebian2/root’ [199.02 GB] inherit

ACTIVE ‘/dev/mydebian2/swap_1’ [752.00 MB] inherit

mydebian2:~# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/mydebian2-root

118G 792M 111G 1% /

tmpfs 63M 0 63M 0% /lib/init/rw

udev 10M 60K 10M 1% /dev

tmpfs 63M 0 63M 0% /dev/shm

/dev/sda1 236M 13M 211M 6% /boot

 

5. ปรับขนาดระบบไฟล์

mydebian2:~# resize2fs /dev/mapper/mydebian2-root

resize2fs 1.40-WIP (14-Nov-2006)

Filesystem at /dev/mapper/mydebian2-root is mounted on /; on-line resizing required

old desc_blocks = 8, new_desc_blocks = 13

Performing an on-line resize of /dev/mapper/mydebian2-root to 52171776 (4k) blocks.

The filesystem on /dev/mapper/mydebian2-root is now 52171776 blocks long.

mydebian2:~# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/mydebian2-root

196G 792M 186G 1% /

tmpfs 63M 0 63M 0% /lib/init/rw

udev 10M 60K 10M 1% /dev

tmpfs 63M 0 63M 0% /dev/shm

/dev/sda1 236M 13M 211M 6% /boot

จะเห็นได้ว่า

/dev/mapper/mydebian2-root ซึ่ง mount เป็น / มีขาดเพิ่มจาก 111 G -> 186G

เมษายน 16, 2007

aptitude vs apt-get

Filed under: Debian,Linux — suchart @ 9:40 pm

aptitude vs apt-get


เนื่องจากผมเพิ่งเริ่มเล่น
Debian พอดีเห็นว่าเขาแนะนำให้ใช้ aptitude แทน apt-get ผมก็เลยลองใช้ แต่ใช้ๆ ไปชักจะเริ่มรู้สึกแปลกๆ เวลาติดตั้งแพคเกจมันก็จะติดตั้งมากกว่า apt-get เพราะมันติดตั้งแพคเกจที่ Recommended ด้วย แต่พอจะไม่ติดตั้งส่วนที่มัน Recommended (-R) มันก็กลับจะไปเอาแพคเกจที่เคยลงไปแล้วบางส่วนออก ซึ่งบางตัวเราก็รู้ทั้งรู้ว่ายังต้องใช้ จริงๆ มันก็สามารถเซตได้ แต่ขี้เกียจหา

เฮ้อ… สงสัยว่ามือใหม่อย่างผม คงต้องกลับไปใช้อะไรที่มันง่ายๆแบบ apt-get เหมือนเดิมไปก่อนซะละมั้ง

Debian 4.0 + MySQL Server 5.0 + phpMyAdmin แบบเร็วๆ

Filed under: Debian,Linux — suchart @ 8:29 pm

ติดตั้ง MySQL Server 5.0 และ phpMyAdmin บน Debian 4.0 แบบเร็วๆ

# aptitude install mysql-server

# mysqladmin -u root password รหัสผ่านของ_MySQL_root

# aptitude install phpmyadmin

ใช้งาน phpMyAdmin ผ่าน browser เรียก

http://หมายเลขไอพีของเครื่อง/phpmyadmin

Linux Text Mode Browsers

Filed under: Debian,Linux — suchart @ 6:55 pm

การใช้งานลีนุกซ์ของผมส่วนใหญ่แล้วจะอยู่ใน text mode และบ่อยครั้งก็ต้องใช้ browser เพื่ออ่าน html docs หรือเข้าเว็บเพื่อดูข้อมูล browser ตัวแรกที่ผมรู้จักคือ lynx ตัวที่สอง links

ตัวที่สาม ผมก็เพิ่งมารู้จักตอนที่ใช้ Debian นี่แหละครับ คือ w3m ผมว่ามันก็เข้าท่าทีเดียว

ถ้าจะติดตั้ง ก็

# apt-get install w3m

หรือ

# aptitude install w3m

การใช้งาน

# w3m http://www.tldp.org

หน้าตาก็ประมาณนี้

ใครมีโปรแกรมลักษณะนี้ ดีๆ มาแนะนำอีกไหมครับ

« หน้าก่อนหน้าหน้าถัดไป »

บลอกที่ WordPress.com .