3 ก.ย. 2553

How to Setup CoovaChilli 1.2.4, FreeRadius, MySQL on Ubuntu 10.04

I decide to install Coovachilli on Ubuntu 10.04 because OS boots very fast.

Requirement applications for Captive portal solution
CoovaChilli 1.2.4
FreeRadius
MySQL

1. Install Ubuntu 10.04 and choose package LAMP ,DNS, Openssh .



1.1 Modify the network configuartion file.
nano /etc/network/interfaces



iface eth0 inet static
address 10.10.10.3
netmask 255.255.255.240
gateway 10.10.10.1
auto eth1



1.2 Uncomment in /etc/sysctl.conf:
nano /etc/sysctl.conf




net.ip4.ip_forward=1

2. Install Freeradius and edit



2.1 Setup freeradius
apt-get install freeradius freeradius-mysql





2.2 create DB "radius"

mysqladmin -p create radius

mysql -u root -p radius < /etc/freeradius/sql/mysql/schema.sql -p

mysql -u root -p radius < /etc/freeradius/sql/mysql/nas.sql

mysql -u root -p use radius; GRANT ALL PRIVILEGES ON radius.* TO 'radius'@'localhost' IDENTIFIED BY 'xxxxxxxx';

FLUSH PRIVILEGES; quit






2.3 แก้ไขไพล์ sql.conf เพื่อใช้เชื่อมต่อกับฐานข้อมูลที่เพิ่งสร้างขึ้นมา
nano -w /etc/freeradius/sql.conf




server = "localhost"
login = "radius"
password = "xxxxxxxx"
แล้วเอา # หน้า readclient =yes ออก



nano /etc/freeradius/radiusd.conf


ให้เอา comment ที่หน้า 2 บรรทัดนี้ออก

modules {
….
$INCLUDE sql.conf
$INCLUDE sql/mysql/counter.conf



2.4 แก้ไขไพล์ client.conf เพื่อให้ Coova-chilli และ Daloradius มาทำงานร่วมกับ freeradius ได้
nano -w /etc/freeradius/clients.conf


client 127.0.0.1 {
secret = Iloveradius
}



2.5 แก้ไขไพล์ default
nano -w /etc/freeradius/sites-available/default



ให้กด ctrl+w หาคำว่า authorize { เจอแล้วให้เลื่อนลงมาใส่ # ที่ file และเอา # ที่หน้า sql
authorize {
#file เติม # เข้าไป
sql เอา # ออก
daily เอา # ออก และเพิ่ม 3 บรรทัดข้างล่างต่อท้าย
noresetcounter
dailycounter
monthlycounter
}

ต่อมาก็หาคำว่า accounting { แล้วเอา # หน้า sql ออก
accounting {
sql # uncomment
}

ต่อมาก็หาคำว่า session { แล้วเอา # หน้า sql ออก
session {
sql #uncomment
}



2.6 เพิ่ม User เข้าไปในฐานข้อมูล Radius เสร็จ restart Freeradius แล้วทดสอบ User เลย
mysql -u root -p
INSERT INTO radcheck (UserName, Attribute, Value) VALUES ('guest', 'Password','guest'); เพิ่มusername เข้าไปในฐานข้อมูล
quit
/etc/init.d/freeradius restart
radtest guest guest 127.0.0.1 0 xxxxxxxx



ถ้าทำสำเร็จ จะมีข้อความประมาณนี้ Access-Accept packet from host 127.0.0.1:1812, id=144, length=20
--------------------จบ Freeradius----------------

3. Build Coova แล้ว install และ config


3.1 ได้ลอง build package เองแล้วมันใช้ได้ ดีกว่าแบบที่เค้า Build มาให้
aptitude --assume-yes install dpkg-dev debhelper libssl-dev
cd /tmp
wget -c http://ap.coova.org/chilli/coova-chilli-1.2.4.tar.gz
tar xzf coova-chilli*.tar.gz
cd coova-chilli*
dpkg-buildpackage -rfakeroot





3.2 Install CoovaChilli:
cd ..
dpkg -i coova-chilli_*_i386.deb





3.3 มาจัดการแก้ไข file ต่างๆ ใน coova
cp /etc/chilli/defaults /etc/chilli/config





3.4 สร้าง folder hotspot ขึ้น
mkdir /var/www/hotspot
cd /var/www/hotspot
cp /etc/chilli/www/* /var/www/hotspot
sed -i 's/1.0.0.1/192.168.0.1/g' /etc/chilli/www/ChilliLibrary.js ยาวเป็นบรรทัดเดียว
sed -i 's/1.0.0.1/192.168.0.1/g' /var/www/hotspot/ChilliLibrary.js





3.5 เข้าไปแก้ไข file chilli โดยเปลี่ยนค่าเป็น 1
nano -w /etc/default/chilli



START_CHILLI=1



3.6 แก้ไข file /etc/chilli/config
nano /etc/chilli/config



HS_LANIF=eth1 # Subscriber Interface for client devices
HS_NETWORK=192.168.0.0 # HotSpot Network (must include HS_UAMLISTEN)
HS_NETMASK=255.255.255.0 # HotSpot Network Netmask
HS_UAMLISTEN=192.168.0.1 # HotSpot IP Address (on subscriber network)
HS_UAMPORT=3990 # HotSpot Port (on subscriber network)

HS_NASID=nas01
HS_UAMSECRET=uamsecret
HS_RADIUS=127.0.0.1
HS_RADIUS2=127.0.0.1
HS_RADSECRET=xxxxxxxx
HS_UAMALLOW=www.google.com,192.168.0.0/24

HS_UAMSERVER=192.168.0.1
HS_UAMFORMAT=https://\$HS_UAMSERVER/uam/
HS_UAMHOMEPAGE=http://\$HS_UAMLISTEN:\$HS_UAMPORT/www/coova.html
HS_UAMSERVICE=https://192.168.0.1/cgi-bin/hotspotlogin.cgi

HS_ANYIP=on # Allow any IP address on subscriber LAN
#
HS_MACAUTH=on # To turn on MAC Authentication
HS_MACPASSWD=XXXXXX #รหัสผ่านต้องเหมือนกับทีแก้ไขในไพล์/etc/chilli/functions



3.7 ติดตั้ง Firewall (เพิ่มข้อความข้างล่างในบรรทัดท้ายสุด)
nano /etc/chilli/up.sh



#แทรก หลังจาก . /etc/chilli/functions
iptables -F
iptables -t nat -F

#แล้วต่อท้ายด้วย ข้างล่างนี้
# may not have been populated the first time; run again
[ -e "/var/run/chilli.iptables" ] && sh /var/run/chilli.iptables 2>/dev/null
# force-add the final rule necessary to fix routing tables
iptables -I POSTROUTING -t nat -o $HS_WANIF -j MASQUERADE

iptables -P INPUT DROP
iptables -I INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT


iptables -I INPUT -p icmp --icmp-type 8 -s 0/0 -d 192.168.0.1 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -I OUTPUT -p icmp --icmp-type 0 -s 192.168.0.1 -d 0/0 -m state --state ESTABLISHED,RELATED -j ACCEPT

#SSH Accept from tun0
iptables -I INPUT -i tun0 -p tcp -m tcp --dport 22222 --dst 192.168.0.1 -j ACCEPT

iptables -I INPUT -i eth0 -s 10.10.10.3 -p tcp -m tcp --dport 22222 --dst 10.10.10.4 -j ACCEPT

#SNMP
iptables -I INPUT -p udp -s 0/0 --sport 1024:65535 -d 192.168.0.1 --dport 53 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -I INPUT -p udp -i tun0 -d 192.168.0.1 --dport 161 -j ACCEPT

#iptables -t nat -I PREROUTING -i tun0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128
#iptables -I INPUT -i tun0 -p tcp -m tcp --dport 3128 --syn -j ACCEPT
#iptables -t nat -I PREROUTING -p tcp -m tcp --dport 3128 -j DROP
#iptables -t nat -I PREROUTING -p tcp -m tcp --dport 8080 -j DROP
#iptables -t nat -I PREROUTING -p tcp -m tcp --dport 2121 -j DROP

iptables -t nat -I POSROUTING -o eth0 -j LOG
#squid Log
iptables -t nat -N logging
iptables -t nat -A PREROUTING -j logging

#iptables -t nat -A POSTROUTING -j logging
iptables -A INPUT -j LOG --log-level info --log-prefix "INPUT "
iptables -A OUTPUT -j LOG --log-level info --log-prefix "OUTPUT "
iptables -A FORWARD -j LOG --log-level info --log-prefix "FORWARD "
# HTTP:
iptables -t nat -A logging -p tcp --dport 80 -j LOG --log-prefix "HTTP: " \
--log-level info
# HTTPS:
iptables -t nat -A logging -p tcp --dport 443 -j LOG --log-prefix "HTTPS: " \
--log-level info
# SMTP:
iptables -t nat -A logging -p tcp --dport 25 -j LOG --log-prefix "SMTP: " \
--log-level info
# FTP:
iptables -t nat -A logging -p tcp --dport 21 -j LOG --log-prefix "FTP: " \
--log-level info
# IMAP:
iptables -t nat -A logging -p tcp --dport 143 -j LOG --log-prefix "IMAP: " \
--log-level info
# POP3:
iptables -t nat -A logging -p tcp --dport 110 -j LOG --log-prefix "POP3: " \
--log-level info
# MSN:
iptables -t nat -A logging -p tcp --dport 1863 -j LOG --log-prefix "MSN: " \
--log-level info
# JABBER:
iptables -t nat -A logging -p tcp --dport 5222 -j LOG --log-prefix "JABBER: " \
--log-level info

JABBERS
iptables -t nat -A logging -p tcp --dport 5223 -j LOG --log-prefix "JABBERS: " \
--log-level info
# ICQ/AIM
iptables -t nat -A logging -p tcp --dport 5190 -j LOG --log-prefix "ICQ/AIM: " \
--log-level info
# Yahoo
iptables -t nat -A logging -p tcp --dport 5050 -j LOG --log-prefix "YAHOO: " \
--log-level info
# IRC
iptables -t nat -A logging -p tcp --dport 6667 -j LOG --log-prefix "IRC: " \
--log-level info
# Gadu-Gadu
iptables -t nat -A logging -p tcp --dport 8074 -j LOG --log-prefix "GADU-GADU: " \
--log-level info

iptables -I INPUT -i lo -j ACCEPT
iptables -I INPUT -p tcp -m tcp --dport 443 --syn -j ACCEPT
iptables -I INPUT -p tcp -m tcp --dport 3990 --syn -j ACCEPT
iptables -I INPUT -p tcp -m tcp --dport 4990 --syn -j ACCEPT

iptables -I INPUT -p tcp -m tcp --dport 80 --syn -j ACCEPT
iptables -I INPUT -p tcp -m tcp --dport 53 --syn -j ACCEPT
iptables -I INPUT -p tcp -m tcp --dport 67:68 --syn -j ACCEPT
iptables -I INPUT -p tcp -m tcp --dport 3306 --syn -j ACCEPT

iptables -A INPUT -i tun0 -j DROP


4. config Apapche2


4.1 ติดตั้ง SSL
apt-get install libapache2-mod-auth-mysql





4.2 สร้าง Certificate

apt-get install ssl-cert





4.3 สร้าง folder ssl
mkdir /etc/apache2/ssl





4.4 ดูชื่อเครื่อง
hostname -f





4.5 เสร็จแล้วก็เอาชื่อ hostnameมาใส่ในการตอบคำถามข้างล่างนี้
make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem





4.6 ติดตั้ง module ssl
a2enmod ssl
/etc/init.d/apache2 force-reload





4.7 แก้ไขไพล์ hosts
nano /etc/hosts



127.0.0.1 localhost.local localhost
127.0.1.1 Authen.local Authen
192.168.0.1 Authen.local Authen



4.8 สร้างsite hotspot ก๊อบข้างล่างไปวางใน hotspot (ลบ. ออกด้วยนะ)
nano -w /etc/apache2/sites-available/hotspot




NameVirtualHost 192.168.0.1:443
<.VirtualHost 192.168.0.1:443>
ServerAdmin webmaster@domain.org
DocumentRoot "/var/www/hotspot"
ServerName "192.168.0.1"
<.Directory "/var/www/hotspot/">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
<./Directory>

Alias "/dialupadmin/" "/usr/share/freeradius-dialupadmin/htdocs/"
<.Directory "/usr/share/freeradius-dialupadmin/htdocs/">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
<./Directory>

<.Directory "/var/www/hotspot/cgi-bin/">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
<./Directory>

ErrorLog /var/log/apache2/hotspot-error.log

LogLevel warn

CustomLog /var/log/apache2/hotspot-access.log combined

ServerSignature On
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.pem
<./VirtualHost>



4.9 สั่งให้ hotspot ใน apache ทำงาน
a2ensite hotspot





4.10 จัดการเรื่อง Listen Ports ใน apche
nano -w /etc/apache2/ports.conf



แก้ไขให้เหลือตามข้างล่างเป็นพอ

Listen 443
Listen 80



nano -w /etc/apache2/apache2.conf



ServerName 192.168.0.1 เพิ่มคำสั่งนี้ไว้บนสุดเลยครับ



4.11 เปิดไฟล์ default
nano -w /etc/apache2/sites-available/default



เพิ่มตรงบนสุด NameVirtualHost *:80



4.12 สร้างหน้า login ของ Hotspot
cd /var/www/hotspot/
wget http://www.truesoft.co.th/wifi/uam.tgz
tar xvf uam.tgz





to Start chilli service that server reboots
update-rc.d chilli defaults



จบด้วยการ restart มาถึงตรงนี้ สามารถทดสอบได้แล้ว



5. ติดตั้ง Haserl Download haserl from http://haserl.sourceforge.net/.

sudo apt-get install gcc
tar xvf haserl-0.8.0.tar.gz

cd haserl-0.8.0/

./configure
make
make install

Edit /etc/chilli/wwwsh file

haserl=$(which haserl 2>/dev/null)
with
haserl=/usr/local/bin/haserl


6. Install Syslog-ng

apt-get install syslog-ng
cp /etc/syslog-ng/syslog-ng.conf /etc/syslog-ng/syslog-ng.conf.bak
nano /etc/syslog-ng/syslog-ng.conf

destination remote {
udp("192.168.20.104" port(514));
};
log {source(s_all); filter(f_messages); destination(remote); };
log {source(s_all); filter(f_kern); destination(remote); };

/etc/init.d/syslog-ng start


nano /etc/init.d/rc.capture

#!/bin/bash
tail -F /var/log/squid/access.log logger -t squid -p local3.info &
tail -F /var/log/radius/radacct/127.0.0.1/details logger -t radiusd -p local3.info &

chmod a+x /etc/init.d/rc.capture
ln -s /etc/init.d/rc.capture /etc/rcS.d/S88rccapture


nano /etc/logrotate.d/freeradius

/var/log/radius/radacct/127.0.0.1/details {
rotate 13
weekly
delaycompress
missingok
notifempty
compress

}


nano /etc/freeradius/modules/detail

ให้เปลี่ยนค่า detailfile = ${radacctdir}/%{Client-IP-Address}/detail-%Y%m%d เป็น
detailfile = ${radacctdir}/%{Client-IP-Address}/details


ขั้นตอนการติดตั้ง NTP Server ที่เครื่อง Log Server เป็นดังนี้

1.ติดตั้ง ntp ด้วยสั่ง
apt-get install ntp
2.ทำการสำเนาไฟล์คอนฟิกของ ntp ไปไว้เป็นอีกชื่อดังนี้
cp /etc/ntp.conf /etc/ntp.conf.bak
3.แก้ไขไฟล์ /etc/ntp.conf ให้มีค่าเป็นดังนี้
restrict default kod nomodify notrap noquery nopeer
restrict 127.0.0.1
# อนุญาตให้ Internal network เข้าใช้งาน
restrict 192.168.0.0 mask 255.255.255.0 nomodify notrap
server 203.185.69.60 dynamic
server time.navy.mi.th dynamic
server time.nist.gov dynamic
server 127.127.1.0 # local clock
fudge 127.127.1.0 stratum 10
driftfile /var/lib/ntp/ntp.drift
broadcastdelay 0.008
keys /etc/ntp/keys

4.สั่ง restart service ด้วยคำสั่ง

chkconfig ntpd on
/etc/init.d/ntp restart

5. ตรวจสอบ Remote Server ที่ต้องการใช้อ้างอิงฐานเวลา ใช้คำสั่งดังนี้
ntptrace




อ้างอิง
http://linux.xvx.cz/2010/03/debian-wi-fi-hotspot-using-coovachilli-freeradius-mysql-and-daloradius/
http://www.itmanage.info/technology/linux/ubuntu/chillihospot/install_chillhotspot_ubutu_8_10.html

21 ส.ค. 2553

เรื่องสระลอยและวรรณยุกต์ลอย (ลอยไปไหน)

ผมใช้ Adobe Illustrator ตั้งแต่ version 10 จนตอนนี้ ถึง CS4 ก็ยังมีปัญหาเรื่องสระลอยและวรรณยุกต์ลอย วิธีแก้ไขมีให้เลือกดังนี้

1. เปลี่ยนไปใช้โปรแกรมอื่นอย่างPaint.NetหรือGimp ช่างเป็นเรื่องน่าตลกที่Adobeไม่สามารถทำได้จนถึงทุกวันนี้แต่2ตัวนี้ทำได้ ที่สำคัญฟรีด้วย

2. ใช้โปรแกรมSaru Revowelเป็นโปรแกรมที่ใช้แก้สระลอยของคนไทยใช้กับของAdobeได้ทุกตัว

3. ใช้ Font ของ f0nt.com เพราะส่วนใหญ่ Font ที่มากับเครื่องเป็นรุ่นเก่า

ที่มา http://sakary.exteen.com/20090415/entry
http://www.thaidphoto.com/forums/showthread.php?t=25128

Raster / Vector และ Pixel

ภาพบนคอมพิวเตอร์ หรือกราฟิคคอมพิวเตอร์สามารถแบ่งออกได้เป็นสองประเภทคือ ภาพแบบบิตแมป (bitmap) และภาพแบบเวกเตอร์(vector) ความเข้าใจความแตกต่างของกราฟิค ทั้งสองประเภทจะช่วยให้คุณสามารถเลือกใช้งานได้อย่างยืดหยุ่น มีประสิทธิภาพ และตรงตาม จุดประสงค์สูงสุดในการใช้งาน

Vector Graphic
ภาพแบบเวกเตอร์จะต่างจากภาพแบบบิตแมป ซึ่งคุณจะได้พบกับภาพแบบนี้บนโปรแกรม สำหรับวาดภาพเช่น Adobe Illustrator,Macromedia Freehand ภาพแบบเวกเตอร์จะประกอบด้วย เส้นสาย ลวดลายต่าง ๆ ที่สร้างขึ้นจากการคำนวณทางคณิตศาสตร์ของลักษณะทางเรขาคณิตเพื่อ สร้างรูปทรงต่าง ๆ ที่คุณเห็น ซึ่งเรียกว่าเวกเตอร์ (vectors)

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

Raster Graphic
โปรแกรมปรับแต่งภาพส่วนใหญ่ที่มีอยู่ในท้องตลาดทุกวันนี้ มักจะทำงานกับภาพแบบบิตแมป หรือที่เรียกกันว่าแบบราสเตอร์ (raster) ภาพแบบบิตแมปนี้จะใช้ กริดของตารางเล็ก ๆ ที่เรารู้จักกันดีในชื่อ “พิกเซล” (pixel) สำหรับแสดงภาพ แต่ละพิกเซลก็จะมีค่าของตำแหน่งและค่าสีของตัวเอง ด้วยเหตุที่พิกเซลมีขนาดเล็กเราจึงเห็นว่าภาพ มีความละเอียดสวยงามไม่มีลักษณะของกรอบสี่เหลี่ยมให้เห็น แต่ถ้าเราขยายขนาดของภาพ ก็จะเห็นกรอบเล็ก ๆ หรือพิกเซลที่ประกอบกันขึ้นมาเป็นภาพ ดังนั้นนเมื่องคุณทำงานกับภาพแบบมิตแมป จึงเป็นทำงานกับพิกเซลเล็ก ๆ ที่ประกอบกันขึ้นมาเป็นภาพ ไม่ใช่วัตถุหรือรูปทรงที่เห็น ภาพแบบบิตแมปเป็นภาพที่ขึ้นอยู่กับความละเอียด (resolution)
นั่นคือ มีจำนวนพิกเซลที่แน่นอนในการแสดงภาพ ดังนั้นจากตัวอย่างในภาพที่ 1 คุณจะเห็นว่าเมื่อภาพถูกขยาย หรือพิมพ์ด้วยความละเอียดไม่มากพอภาพจะสูญเสียรายละเอียด และปรากฏเป็นรอยหยักอย่างชัดเจนอย่างไรก็ตามภาพแบบบิตแมป ถือเป็นรูปแบบที่เหมาะกับภาพที่มีเฉดและสีสันจำนวนมาก เช่น ภาพถ่าย หรือภาพวาด


Pixel
พิกเซล (Pixel) เป็นการผสมผสานของคำว่า “Picture” และ “element” คือหน่วย พื้นฐานของภาพ ภาพบิตแมปทุก ๆ ภาพประกอบขึ้นด้วยพิกเซล แต่ละพิกเซลจะมีลักษณะ เป็นรูปสี่เหลี่ยมที่เก็บข้อมูลของสีโดยถูกกำหนตำแหน่งไว้บนเส้นกริดของแนวแกน x และ y ในลักษณะคล้ายแผนที่ (map) นั่นจึงเป็นที่มาของคำว่าบิตแมป (bitmap) เช่น พิกเซลของ ภาพ 8 บิต จะเก็บข้อมูลของสี 8 บิต ที่จอภาพจะใช้ในการแสดงผล ดังนั้นภาพภาพหนึ่งจึงประกอบด้วยพิกเซลเล็ก ๆ จำนวนมาก ซึ่งคุณสามารถมองเห็นได้เมื่อ ขยายภาพให้มีขนาดใหญ่ขึ้น จำนวนของพิกเซล

ที่แสดงต่อหน่วยของความยาวในภาพจะถูกเรียกว่าความละเอียด ของภาพ โดยปกติจะวัดเป็นพิกเซลต่อนิ้ว (ppi : pixel per inch) ภาพที่มีความละเอียดสูงจะประกอบไปด้วยพิกเซลจำนวนมากที่มีขนาดเล็กกว่าภาพเดียวกันที่มีความละเอียดน้อยกว่า ตัวอย่าง เช่น ภาพขนาด 1 x 1 นิ้ว ที่ความละเอียด 72 ppi จะประกอบด้วยพิกเซล 5,184 พิกเซล (ความกว้าง 72 พิกเซล x ความยาว 72 พิกเซล = 5,184) และภาพเดียวกันที่ความละเอียด 300 ppi จะประกอบด้วยพิกเซล 90,000 พิกเซลที่มีขนาดของพิกเซลเล็กกว่า (300 x 300 = 90,000) แน่นอน ว่าภาพที่มีความละเอียดมากกว่าก็จะใช้พื้นที่ในการจัดเก็บมากกว่า

ที่มา http://www.edu-mine.com/photoshop/lesson1_RasterVector.html

14 ส.ค. 2553

How to: Compile Linux kernel 2.6 (Ubuntu 10.04)

1. ไปเอา kernel ที่ stable อันล่าสุดมา จากเวบ http://kernel.org/
$ cd /tmp
$ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.35.2.tar.bz2

2. แตกไพล์
# tar -xjvf linux-2.6.35.2.tar.bz2 -C /usr/src
# cd /usr/src/linux-2.6.35.2

3. Configure kernel
ก่อนที่จะ Compile จะต้องมี development tools ก่อน เช่น gcc compilers ถ้าไม่มีก็พิมพ์ตามข้างล่างนี้เลย (ใช้คำสั่ง whereis gcc เพื่อดูว่าติดตั้งรึยัง)
# apt-get install gcc

$ make menuconfig ความจริงมี 3 วิธีแต่ผมเลือกแบบ Text based เพราะผมไม่ได้ลง X windows ไว้

4. Compile kernel
เร่ิมการ compile ด้วยการสร้าง kernel image
$ make
$ make modules
# make modules_install

5. Install kernel
หลังจากที่ได้ compile kernel และได้ติดตั้ง Module แล้ว คราวนี้ก็มาถึงการติดตั้งตัว kernel เองด้วยคำสั่ง
# make install
โดยคำสั่งนี้จะติดตั้ง 3 File คือ
System.map-2.6.35.2
config-2.6.35.2
vmlinuz-2.6.35.2
ซึ่งเราจะต้องตามไป configure ที่ /boot directory เพื่อให้ระบบ boot ด้วย kernel อันใหม่

6. สร้าง initrd image
# cd /boot
# mkinitramfs -o initrd.img-2.6.235.2 2.6.35.2
ใน initrd images ประกอบด้วย device driver อันที่จำเป็นต้องใช้ในการ Load operating system ใช่ว่าทุกเครื่องจำเป็นต้องมี initrd แต่สร้างไว้ก่อนเพื่อความชัวร์

7. แก้ไข Grub configuration file - /boot/grub/menu.lst แก้ไขไพล์โดยใช้ nano:
# nano /boot/grub/menu.lst
title Debian GNU/Linux, kernel 2.6.35.2 Default
root (hd0,0)
kernel /boot/vmlinuz root=/dev/hdb1 ro
initrd /boot/initrd.img-2.6.35.2
savedefault
boot

ต้องระบุ Hd ให้ถูกตัว เสร็จแล้วก็ Save ถ้าขี้เกียจก็พิมพ์ตามข้างบนก็ให้พิมพ์แค่นี้พอ
# update-grub

8. Reboot เครื่อง เพื่อจะได้ใช้ Kernel อันใหม่
# reboot

http://www.cyberciti.biz/tips/compiling-linux-kernel-26.html

13 ส.ค. 2553

Backing & Restoring Mysql Database via the command line

Backing up via the command line
To backup from the command line of your shell account, log in and type the following at the prompt replacing USERNAME and DATABASE as described previously:

mysqldump -a -u USERNAME -p DATABASE > FILENAME.mysql

You will be prompted for your database password and then the DATABASE will be dumped to a plain-text file called FILENAME.mysql.

The resulting file, FILENAME.mysql, is a full backup with which you can fully restore your database in case of problems.

Restoring via the command line
Restoring from FILENAME.mysql is a three step process:

1.Drop the database
mysqladmin -u USERNAME -p drop DATABASE

2.Recreate the database
mysqladmin -u USERNAME -p create DATABASE

3.Import the backup data
mysql -u USERNAME -p Databasename < FILENAME.mysql

Failed to find module "sql".

Freeradius version 2
Problem
หลังจาก run radiusd -X มีข้อความแบบนี้

/etc/freeradius/sites-enabled/default[152]: Failed to find module "sql".
/etc/freeradius/sites-enabled/default[62]: Errors parsing authorize section.

Solution
nano /etc/freeradius/radiusd.conf
แล้วเอา # หน้า $INCLUDE sql.conf ออก

12 ส.ค. 2553

Ubuntu 10.04 ไม่มี tun แล้ว "FATAL: Module tun not found."

ผมได้ลองคำสั่ง modprobe tun
บน Ubuntu 10.04แล้ว มี error แบบนี้ "FATAL: Module tun not found."

แล้วได้ไปอ่านเวบนี้
http://piotrnowicki.com/blog///calmate.php/2010/07/03/snx-in-ubuntu-10-04
ก็ได้ร้องอ๋อ เป็นอย่างนี้นิเอง

ปรากฎว่า ตัว kernal ของ Ubuntu V10.04 เค้าได้ compile Tun ไปไว้ใน Kernel เลย
วิธีแก้ไข
1. Compile Kernel ใหม่ โดยให้ Compile Tun แบบ Module
2. พิมพ์ตามนี้
echo -e "install tun /bin/true\n" > built-in.conf
sudo cp built-in.conf /etc/modprobe.d/
วิธีที่ 2 ผมทำแล้ว ไม่ work ไม่รู้ว่าทำไม