Tuesday, November 11, 2008

ส่งเมล์ผ่าน endian firewall มี error ดังนี้

สถานการณ์

ส่งเมล์ด้วยโปรแกรม mail ใน vista ส่งถึงผู้รับชื่อ xxx@gmail.com ตรวจสอบใน endian ด้วยคำสั่ง
mailq พบ error เช่นนี้แล


885F718F3C8 3470 Wed Nov 12 13:25:05 MAILER-DAEMON
(host mx5.isp.com[ipaddr] said: 452 Too many recipients received this hour (in reply to RCPT TO command))it_xx@xxx.co.th

ปัญหานี้ยังไม่ได้แก้
บันทึกไว้เป็นความจำ

วันที่และเวลาใน log ของ squid

ความเห็น 1

Open your squid.conf and search for the line that starts with access_log or cache_access_log and looks like:

Code:
access_log /var/log/squid/access.log squidOf course the path to the logfile may vary in your case.
Note the last keyword (in this case squid, but it could be common, combined, squidmime). Then look for the line that starts with logformat and change "%ts.%03tu" with "%tl" fro local time or "%tg" fro GMT time. If the line does not exist you should add it. For the above example it should changed from:

Code:
logformat squid %ts.%03tu %6tr %>a %Ss/%03Hs %
Code:
logformat squid %tl %6tr %>a %Ss/%03Hs %============
ความเห็น 2
emulate_httpd_log on

This is explained in the squid.conf.default:

# TAG: emulate_httpd_log on|off
# The Cache can emulate the log file format which many 'httpd'
# programs use. To disable/enable this emulation, set
# emulate_httpd_log to 'off' or 'on'. The default
# is to use the native log format since it includes useful
# information Squid-specific log analyzers use.
#
#Default:
# emulate_httpd_log off

ขอบคุณ
http://www.linuxquestions.org/questions/linux-general-1/adding-date-and-time-to-squid-access.log-589410/

Thursday, November 6, 2008

ผู้ใช้เปลี่ยนพาสเวิร์ดมี error

ในกรณีที่่ทำเป็น Authenticated ด้วย proxy แล้วให้ผู้ใช้งานสามารถเปลี่ยนพาสเวิร์ดด้วยตนเองโดยเข้าไปที่
https://endian:10443/cgi-bin/chpasswd.cgi เมื่อคลิกเปลี่ยนพาสเวิร์ดแล้วกลับมี error

E R R O R E R R O R: Username does not exist

What problem and how to solved this ?

Endian community กับปัญหาที่รอคำตอบ?????

1. ต่ออินเทอร์เน็ต 2 line คือ 1. True 2 MB 2. True 1 MB ต้องการให้เส้นทางเดินเป็นดังนี้
1.1 port 8080/80/445 เป็นต้น วิ่งออกที่ 2 MB
1.2 port 25/110 เป็นต้นวิ่งออกทาง 1 MB
-------------------------------------
2. hotspot function ใน Endian community
3. IPcop update http blacklist จะถูก enable ตั้งแต่แรกติดตั้ง ส่วนใน endian จะ update โดยอัตนโนมัติได้อย่างไร ??
คำตอบ

BTW, this was posted to the nabble mail list archives:
#!/bin/sh
# update_blacklists.sh, 20070615
# Mike Tremaine
###################################

###################################
#Set up variables
###################################

dansguardian_start="/etc/init.d/dansguardian start"
dansguardian_stop="/etc/init.d/dansguardian stop"
dansguardian_conf="/etc/dansguardian/"
httpget="/usr/bin/curl"
tarpath="/bin/tar"
workdir="/tmp"
blacklist="http://squidguard.mesd.k12.or.us/blacklists.tgz"

##########################################
#Move to tmp and download
##########################################

cd $workdir
$httpget -O $blacklist || exit 1
$tarpath xzf $workdir/blacklists.tgz -C $workdir || exit 1
#Sanity check file we downloaded
if [ $(stat -c%s "$workdir/blacklist.tgz") -lt 4000001 ]; then
exit 1
fi

###########################################
#Updates lists
############################################

cp -pRf $workdir/blacklists $dansguardian_conf

#Restart
$dansguardian_stop
sleep 3
$dansguardian_start

#Cleanup
rm -f $workdir/blacklists.tgz
rm -r -f $workdir/blacklists

exit 0

http://efwsupport.com/index.php?topic=347.0

วิธีป้องกัน SSH Brute Force บน Endian Firewall

การป้องกันการจู่โจมด้วย ssh brute force สำหรับ endian ให้เพิ่ม iptables สำหรับกฏ INPUT
เพิ่มเติม มีวิธีการดังนี้

1. เปิดไฟล์ /etc/rc.d/rc.firewall.local
เพิ่ม iptables อีก 2 บรรทัด

iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --set
iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --update --seconds 600 --hitcount 2 -j DROP

รูปแบบไฟล์หลังจากเพิ่มสองบรรทัดข้างบนแล้วจะเป็นดังนี้


#!/bin/sh
# Used for private firewall rules

# See how we were called.
case "$1" in
start)
iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --set
iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --update --seconds 600 --hitcount 2 -j DROP
## add your 'start' rules here
;;
stop)
## add your 'stop' rules here
;;
reload)
## add your 'reload' rules here
;;
*)
echo "Usage: $0 {start|reload|stop}"
esac

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

reboot endian firewall ใหม่

mrt2514
บ.ไอทีทริปเปิลพลัส จก.

Wednesday, November 5, 2008

Set Endian Firewall ส่ง Log ไปเก็บไว้ที่ Log Server

Endian Firewall เวอร์ชั่น 2.2 RC3 ใช้ syslog-ng เป็นตัวจัดการ log ทำให้สามารถส่ง log จากเครื่อง endian ไปยัง Log Server เพื่อจัดเก็บตาม พรบ. ได้อย่างมีประสิทธิภาพเยี่ยม ในบทความนี้จะแสดงวิธีการ config แบบย่อ ๆ โดยมีรูปแบบการจัดวาง server ดังนี้

1. Endian Firewall เป็นตัวกั้นกลางระหว่าง network ภายในกับ internet
2. Router ที่ต่อเข้า internet เป็น ZyXEL 660H ต่อผ่าน RED ของ Endian โดย set เป้น Bridge
3. Log Server ตั้งอยู่ที่ network ภายใน มีหมายเลข IP=192.168.2.249 ใช้ FC9 เป็น OS ใช้ syslog-ng
เป็นตัวจัดการ Log

ในที่นี้้จะกำหนดให้ endian เป็น gateway ของระบบ และเป็นตัวผลิต log กำหนดให้ FC9 เป็น Log Server

..... หลังจากที่ท่านได้ติดตั้ง endian และ FC เสร็จแล้วทุกอยางผ่านหมด server ทั้งสองสามารถคุยกันได้แล้วต่อไปเรามาเริ่ม config โดยเริ่มจากเครื่อง Log Server ก่อน โดยแก้ไขไฟล์ /etc/syslog-ng/syslog-ng.conf ดังนี้

ส่วนที่เพิ่มเติม ตอนท้ายไฟล

# Log from Endian Server
source s_endialserver {
udp(ip("0.0.0.0") port(514));
};

destination d_logserver {
file("/var/log/$R_YEAR$R_MONTH$DAY.log"
owner(root) group(adm) perm(665)
create_dirs(yes) dir_perm(0775));
};

log {
source(s_endianserver);
destination(d_logserver);
};


รูปแบบไฟล์เก็บ log จะมีรูปแบบ 20081103.log คือ ปีเดือนวัน

เสร็จจากเครื่อง log server แล้ว คราวนี้ก็ไป set ที่ endian firewall ต่อกันนะครับ

endian มีการเซ็ต log ผ่าน gui ที่หัวข้อ Logs->Settings แต่ว่าการใช้ gui นี้ยังไม่ประสบความสำเร็จตามที่ประสงค์ได้ จึงได้หันมาใช้การเซ็ตผ่านไฟล์ตรง ๆ ดีกว่าดูเข้าท่าและมีรายละเอียดเยอะดี

เก็บอะไรบ้าง ?
log ที่เราจะให้ endian ผลิตให้และนำไปเก็บไว้ที่ log server ได้แก่
1. Mail : จากใคร ไปถึงใคร หัวข้ออะไร สถานะเป็นอย่างไร โดยเก็บจาก /var/log/maillog
2. Authenticated การใช้ internet เก็บจาก squid
3. เส้นทางการเดินของ data นั้น ๆ เก็บจาก iptables

ขั้นตอน ;
1. ตรวจสอบไฟล์และไดเรกทอรี /etc/syslog/
configuration ในที่นี้คือ syslog.conf
/etc/syslog/syslog.d/
ไฟล์ที่สำคัญคือ firewall.tmp1,squid.tmp1,smtp.tmp1

1. แก้ไข template ไฟลื firewall.tmp1 โดยเพิ่ม
#firewall
destination logserver { udp("192.168.2.249" port(514)); };
destination d_firewall {
file("/var/log/firewall" owner("root") group("nobody") perm(0640));
};
filter f_firewall {
facility(local2);
};
log {
source(s_sys);
filter(f_firewall);
destination(d_firewall);
destination(logserver);};
};
2. แก้ไขไฟล์ squid.tmp1

#squid access
destination logserver {udp("192.168.2.249" port(514));};
destination d_squid_access {
file("/var/log/squid/access.log" owner("root") group("nobody") perm(0640));
};
destination d_squid_access_short {
file("/var/log/squid/access.log_short" template("\\$MSGONLY\n") owner("root") group("nobody") perm(0640));
};
filter f_squid {
facility(local6) and priority(info) and program(squid);
};
log {
source(s_sys);
filter(f_squid);
destination(d_squid_access);
destination(d_squid_access_short);
destination(logserver);};

};

3. แก้ไขไฟล์ smtp.tmp1

#mail
destination logserver { udp("192.168.2.249" port(514)); };
destination d_mail {
file("/var/log/maillog" owner("root") group("nobody") perm(0640));
};
destination d_mail_short {
file("/var/log/maillog_short" template("\\$MSGONLY\n") owner("root") group("root") perm(0640));
};
filter f_filter4 {
facility(mail) and not match('connect from localhost\[127.0.0.1\]');
};
log {
source(s_sys);
filter(f_filter4);
destination(d_mail);
destination(d_mail_short);
destination(logserver);};


Reboot endian firewall หรือจะโหลด /etc/init.d/syslog-ng reload ก้ได้
ลองกลับไปตรวจสอบดู log server ดูควรจะมี log ที่ส่งมาจาก endian server ให้ได้ชมแล้ว....

mrt2514
บ.ไอทีทิปเปิลพลัส จำกัด

Tuesday, November 4, 2008

Endian กับการติดตั้งโปรแกรมชุดพัฒนา

Endian Firewall ชุดติดตั้งไม่ได้ลงตัว library สำหรับกลุ่ม develop ให้ด้วย เช่น พวก gcc / kernel-header เป็นต้น ทำให้ไม่สามารถ compile โปรแกรมต่าง ๆ ที่ตัองติดตั้งเพื่อให้ endian มีความสามารถได้
แต่ปัญหานี้ทีม endian ได้เห็นความสำคัญจึงได้มีชุด endian develop ให้ดาวน์โหลด และติดตั้งลงใน endian
เพื่อให้สามารถ compile โปรแกรมเสริมอื่นๆ ได้อย่างลงตัว ผมได้ทดลอง โดยมีสถานการณ์ดังนี้
1. ติดตั้งชุด endian develop ลงในเครื่อง endian firewall
2. ติดตั้งโปรแกรม imspector เพื่อกรอง และดักจับข้อมูลการใช้ msn ต่าง ๆ

โดยมีขั้นตอน ดังนี้
1. ดาวน์โหลดชุด endian develop จาก www.endian.com
EFW-COMMUNITY-2.2-rc3-devel-rpms.tar.gz
2. นำไฟล์ไปวางไว้ใน endian firewall ด้วย WinSCP
3. เข้าไปที่ endian firewall และคลี่ไฟล์ออกมาด้วยคำสั่ง
tar xvfz EFW-COMMUNITY-2.2-rc3.devel-rpms.tar.gz
จะได้ไดเรกทอรี /RPMS/devel เข้าไปในไดเรกทอรี และใช้คำสั่ง
rpm -ivh *



โปรแกรมจะดำเนินการติดตั้งแพกเกจทั้งหมดจนแล้วเสร็จถึงตอนนี้ endian ของเราก็จะมีชุดคำสั่ง gcc และ make พร้อม
compile โปรแกรมแล้ว
4. ดาวน์โหลด imspector ไฟล์ .tar.gz และโยนไปไว้ใน endian เข้าไปคลี่ไฟล์ออก
5. compile ด้วยคำสั่งต่อไปนี้
make



make install



เราก็จะได้ไฟล์ imspector ไว้ใช้งานใน endian แล้ว

Friday, October 17, 2008

Install Joomla บน Centos 4.5

ได้ติดตั้ง joomla บน vista โดยใช้โปรแกรม xampp ช่วยติดตั้ง และ คอนฟิก Mysql,PHP,Apache ดูเหมือนจะ
เสร็จได้อย่างง่ายดายและรวดเร็วมาก วันนี้มีความจำเป็นบางอย่างต้องติดตั้ง joomla บน Linux ด้วยความรู้สึกว่าง่าย
เหมือนติดตั้งบน vista ทำให้เสียเวลาไปเป็นวันเหมือนกันกว่าจะติดตั้งได้เสร็จ และโดยเฉพาะติดตั้งบน CentOS ที่
รันผ่าน vmware บนเครื่อง vista อะไรบ้างที่เป็นปัญหา และแก้ไขปัญหานั้นอย่างไร ลองพิจารณาดูครับ

แพกเกจที่ต้องติดตั้งให้เรียบร้อยก่อน Joomla
- Mysql
- Apache
- PHP
หมายความว่าต้องให้โปรแกรมต่าง ๆ เหล่านี้ รันได้ด้วยนะ

ติดตั้ง Mysql

1. ตรวจสอบว่าได้เคยติดตั้ง Mysql ไว้แล้วหรือยัง
rpm -ql mysql-server
ถ้ายังไม่ติดตั้งให้ดำเนินการเสียก่อน

rpm -ivh mysql-server* ->> OK

config ไฟล์ที่ควรตรวจสอบหลังติดตั้งผ่านแล้ว
/etc/init.d/mysqld -> process สำหรับรัน MySql
/var/lib/msql -> MySQL จะสร้างฐานข้อมูลไว้แถวๆนี้

2. สร้าง user และก

Sunday, September 28, 2008

IPCop GUI เชื่อได้จริงหรือ?

บ่อยครั้งมาก ๆ ที่เซตค่าด้วย gui ใน IPCop ในสไตร์คลิกถูก แล้วคลิกเลือก save หรือ save and start
คุณมั่นใจได้อย่างไรว่ามัน save ให้จริง ๆ โดยเฉพาะ Advanproxy และ urlfilter

Monday, September 15, 2008

IPCop ก่อนจะเป็น .ISO ยุ่งเหลือเกิน

อย่างที่เกริ่นหัวเไว้เรื่องนั่นแหละครับ ถึงคราวต้องติดตั้งจริง ๆ กลับดาวน์โหลดไฟล์ที่เป็น ISO จาก ipcop.org ไม่ได้ หรือไม่มีซะงั้น เอาไงดีหล่ะอ่าน IPCop howto ต่าง ๆทั่วอินทอร์เน็ต ก็แนะนำให้ใส่แผ่นบูตหรือบูตจาก CD-rom กันทั้งนั้น และคลิก next ตั้งค่า next ตั้งค่าไปเรื่อยจนจบ

Monday, September 1, 2008

clamav with rpm package

ติดตั้งด้วย RPM ดูเหมือนจะง่ายมาก ๆ แต่การใช้งานกลับไม่ได้อะไรเหมือนที่ง่าย ๆ นั้นเลย เดี่ยวจะมาเฉลยภายหลังว่าอะไรมีอะไรไม่มี ตอนนี้แก้ปัยหาจากากร compile เองดีกว่า

1. ดาวน์โหลดไฟล์ และ compile เป็นไฟล์พร้อมใช้งาน
- download
- ./configure --prefix=/usr/local/clamav --sysconfig=/etc/clamav --disable-clamav
- No error -> make
- No error -> make install
- No error -> ls /usr/local/clamav

ประกอบด้วย directory -> bin include lib sbin share
ls /etc/clamav -> ประกอบด้วย file clamd.conf freshclam.conf

Tuesday, August 26, 2008

ClamAV Antivirus และ Samba



Error จาก /var/log/message เมื่อมีการเปิดใช้ไฟล์จาก windows

smbd_vscan_clamav[290099]: ERROR : file /home/tawich/Policy/Poledit.exe not found,
not readable or an error occured
ERROR : daemon failed with a minor error - access to file Policy/poledit.exe denied

ความหมายคือ โปรแกรม clamd สิทธิ์ไม่ถึงที่จะตรวจสอบไฟล์นั้นได้ รู้ได้ยังไงเหรอ ลองตรวจสอบสถานะ process
ด้วยคำสั่ง ps -aux | grep clamd จะเห็นว่า daemon clamd รันด้วย user clamav อยู่ ถ้าหากเปลี่ยนสถานะ
เป็น root คงจะแก้ปัญหานี้ได้ ทีนี้ลองมาแก้ดูตามที่สันนิษฐานกันต่อ

1. แก้ไขไฟล์ /etc/clamav/clamd.conf เพื่อกำหนดให้ clamd รันเป็น root

#Run as another user
User root

2. save file แล้วรัน clamd อีกครั้งตรวจสอบสถานะว่ารันเป็น root แล้วหรือไม่ดู

เมื่อทุกอย่าง OK แล้วคราวนี้เปิดไฟล์ตามปกติใน windows และทดสอบเปิดไฟล์ที่ติดไวรัส พบว่ามีการกำจัดไวรัสให้
แล้ว

clamav samba


Resources:

ManPage clamd.conf (5) : -> http://linux.die.net/man/5/clamd.conf
Clam Antivirus: Installation -> http://www.proscrutiny.com/howtos/clamav-qmail-ldap.html

มี package rpm สำหรับ Mandriva ที่นี่

Monday, August 25, 2008

Vtfp with CentOS

วันนี้ต้อง upgrade firmware ของอุปกรณ์ thin client โดยผ่าน ftp ด้วยความกรุณาของช่าง
แนะนำให้เราสร้าง ftp server บน windows 2003 ไอ้ความที่เราไม่ค่อยถนัดนักในเรื่องของ window
จึงได้ทำบน linux ของเราดีกว่า เสร็จแล้วค่อยโทรไปหาฝ่าย support ของ thin client อีกครั้ง

VNC server with CentOS 4 ว่าด้วยการ config

สวัสดีครับพี่น้อง ผมได้อ่านและทำตามการติดตั้ง vncserver ด้วย CentOS 4.6 ของบทความนี้ และใช้งานได้
จึงเห็นสมควรอนุรักษ์ไว้ จึง copy มาทั้งดุ้นแบบนี้ เชิญท่านทัศนาได้แล้ว ณ บัดนี้


Contents

1. Installing the required packages
2. Configuring un-encrypted VNC
1. Create your VNC users
2. Set your users' VNC passwords
3. Edit the server configuration
4. Create xstartup scripts
5. Test each VNC user
1. Testing with a java enabled browser
2. Testing with a vnc client
3. Starting vncserver at boot
3. VNC encrypted through an ssh tunnel
4. Recovery from a logout
5. VNC-Sever setup with no hassles with vnc-ltsp-config
6. VNC-Server for an already logged in GUI console session

VNC is used to display an X windows session running on another computer. Unlike a remote X connection, the xserver is running on the remote computer, not on your local workstation. Your workstation ( Linux or Windows ) is only displaying a copy of the display ( real or virtual ) that is running on the remote machine.

There are several ways to configure the vnc server. This HOWTO shows you how to configure VNC using the 'vncserver' service as supplied by CentOS.

1. Installing the required packages

The server package is called 'vnc-server'. Run the command rpm -q vnc-server.

The result will be either package vnc-server is not installed or something like vnc-server-4.0-11.el4.

If the server is not installed, install it with the command: yum install vnc-server.

The client program is 'vnc'. You can use the command yum install vnc to install the client if rpm -q vnc shows that it is not already installed.

Make sure to install a window manager in order to get a normal GUI desktop. You can use the command yum groupinstall "GNOME Desktop Environment" to install the Gnome Desktop and requirements, for example. Other popular desktop environments are "KDE" and "XFCE-4.4". XFCE is more light-weight than Gnome or KDE and available from the "extras" repository.

ตรงนี้หากเราติดตั้ง CentOS และเลือก Xwindows พร้อมกับ KDE หรือ Gnome แล้วตั้งแต่แรกก็สามารถข้ามไปได้ อนึ่ง
ในลินุกซ์การติดตั้ง package เป็นขบวนแบบนี้ภายหลังยุ่งยากมาก เพราะไฟล์ที่ต้องการและขึ้นต่อกันมีเยอะเกินไป
จึงควรทำเสียให้เสร็จตั้งแต่ตอนแรกแล้ว....

2. Configuring un-encrypted VNC

We will be setting up VNC for 3 users. These will be 'larry', 'moe', and 'curly'.

You will perform the following steps to configure your VNC server:

1. Create your VNC users.
2. Set your users' VNC passwords.
3. Edit the server configuration.
4. Create xstartup scripts.
5. Test each VNC user.

2.1. Create your VNC users หรือ นัยหนึ่่งคือสร้าง user ในลินุกซ์ หากมี user อยู่แล้วให้ข้ามไปขั้นตอน
สร้าง password เลย

As root:

# useradd larry
# useradd moe
# useradd curly
# passwd larry
# passwd moe
# passwd curly

2.2. Set your users' VNC passwords

Login to each user, and run vncpasswd. This will create a .vnc directory. ให้ login
ด้วย user แต่ละคนก่อนในแต่ละคนนั้นให้สร้างพาสเวิร์ดด้วยคำสั่ง vncpasswd ซึ่งจะมีการสร้างไดเรกทอรี .vnc
ขึ้นในนั้นประกอบด้วยไฟล์ passwd ขึ้นมา

[~]$ cd .vnc
[.vnc]$ ls
passwd

2.3. Edit the server configuration
# เสร็จแล้วให้แก้ไขไฟล์ vncservers ใน /etc/sysconfig ด้วยการเพิ่มเข้าไปอีก 4 บรรทัด คงพอเดาได้หล่ะนะ
ว่าคืออะไร

Edit /etc/sysconfig/vncservers, and add the following to the end of the file.

VNCSERVERS="1:larry 2:moe 3:curly" # กำหนดว่าให้ใช้ได้ 3 คน
VNCSERVERARGS[1]="-geometry 640x480" # คนที่ 1 ได้รายละเอียดของภาพที่ 640x480
VNCSERVERARGS[2]="-geometry 640x480" # คนที่ 2 ได้รายละเอียดของภาพที่ 640x480
VNCSERVERARGS[1]="-geometry 800x600" # คนที่ 3 ได้รายละเอียดของภาพที่ 800x600

Larry will have a 640 by 480 screen, as will moe. Curly will have an 800 by 600 screen.

2.4. Create xstartup scripts # จะเป็นการสร้างไฟล์ xstartup ที่จะใช้รันเมื่อมีการ connect เข้ามา
จาก vncviewer ต่าง ๆ ไฟล์นี้จะถูกสร้างในไดเรกทอรี .vnc ของ user ทั้งสามคนที่กำหนดไว้ข้างต้น ไฟล์นี้
ให้สร้างด้วย scrip โดยรัน vncserver service จะสร้างให้โดยอัตโนมัติ ตามขั้นตอนสามบรรทัดถัดจากนี้ไป

We will create the xstartup scripts by starting and stopping the vncserver as root.

# service vncserver start
# service vncserver stop

Login to each user and edit the xstartup script. To use Larry as an example, first login as larry.

[~]$ cd .vnc
[.vnc] ls
mymachine.localnet:1.log passwd xstartup

Edit xstartup. Add the line indicated here, and uncomment the two lines as directed.
=============== อันนี้เป็นค่า default ที่สร้างจาก vncserver service เลย ===============
#!/bin/sh (-)
# Add the following line to ensure you always have an xterm available.
( while true ; do xterm ; done ) &
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER # ให้เอา # ออก
exec /etc/X11/xinit/xinitrc # ให้เอา # ออก
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &

# ค่าสุดท้ายนี้หากต้องการ รัน gnome แก้เป็น exec gnome-session
หากต้องการรัน kde แก้เป็น startkde ของผมใช้ kde จึงเป็น startkde &

2.5. Test each VNC user ทดสอบดูว่าแต่ละคนจะใช้ vncserver ที่ port ต่างกันตามลำดับ

ก่อนจะทดสอบ ให้รัน vncserver เสียก่อน ด้วยคำสั่ง #service vncserver start
เห็น vncserver โชว์หรือเปล่าพร้อมสำหรับ 3 คนแล้ว

2.5.1. Testing with a java enabled browser

Let us assume that mymachine has an IP address of 192.168.0.10. The URL to connect to each of the users will be:

Larry is http://192.168.0.10:5801
Moe is http://192.168.0.10:5802
Curly is http://192.168.0.10:5803

Connect to http://192.168.0.10:5801. A java applet window will pop-up showing a conection to your machine at port 1. Click the [ok] button. Enter larry's VNC password, and a 640x480 window should open using larry's default window manager.

2.5.2. Testing with a vnc client

For Larry: vncviewer 192.168.0.10:1
For Moe: vncviewer 192.168.0.10:2
For Curly: vncviewer 192.168.0.10:3

To test larry using vncviewer, vncviewer 192.168.0.10:1. Enter Larry's VNC password, and a 640x480 window sholud open using Larry's default window manager.

เมื่อ vncserver รันได้แล้ว และพร้อมสำหรับการคอนเนกแล้ว ก็ให้รัน vncserver ทุกครั้งที่ boot ซะ
2.5.3. Starting vncserver at boot

To start vncserver at boot, enter the command chkconfig vncserver on.

# chkconfig --level 35 vncserver on


=========== ต่อไปของ howto นี้เป็นการ config VNC ในแบบ encrypted โดยผ่าน ssh tunnel ก็หาอ่านต่อได้จากลิงค์ต้นฉบับครับ ===========================

ต้นฉบับลอกมาจาก: http://wiki.centos.org/HowTos/VNC-Server
TightVNC

Setup VNC Server on Linux

Run VNCserver on CentOS

Short notes on how to run VNCserver under CentOS 5

1. install the app
#> sudo yum install vnc-server

2. create a password file
#> vncpasswd password

3. edit vnc config file
#> sudo vi /etc/sysconfig/vncserver
VNCSERVERS="1:yourusername"
- uncomment this if you want to force VNC connections only via SSH tunnel
#VNCSERVERARGS[1]="-geometry 800×600 -nolisten tcp -nohttpd -localhost"

4. start vncserver
#> sudo service vncserver start

Tweaks : what ever vnc start for you is in $HOME/.vnc/xstartup,uncomment the following two lines to have your default desktop
#unset SESSION_MANAGER # exec /etc/X11/xinit/xinitrc

Sorce: http://www.101tech.net/wordpress/2007/07/20/run-vncserver-on-centos/

Thursday, August 14, 2008

Samba Video tutorial

วันนี้ท่องเน็ตอยู่ ๆ ก็เจอวีดีโอช่วยสอนการใช้และการ setup Samba server ที่ดีๆเข้า จึงได้ดาวน์โหลดมาศึกษา
เนื้อหาง่ายดี ยังไม่เข้าขั้น advance เท่าไหร admin มือเก๋า ข้ามไปได้ ส่วนผู้ใช้งานมื่อใหม่อย่างเรา น่าสนใจทีเดียว

ในวิดีโอ 1 สอนให้ใช้ linux เข้าถึงแชร์ไฟล์ใน windows โดยเรียกไฟล์จาก windows ผ่าน msclient ได้โชว์
คำสั่งต่าง ๆ ให้เห็นเป็นบุญ ดังนี้

rpm -qa | grep smb
rpm -ql | grep samba

ผลของคำสั่งแสดงให้เห็นว่ามีการติดตั้ง package samba เวอร์ชั่นอะไรลงไป



คำสั่ง smbclient -L winxp -U administrator
ตามด้วยพร้อมสำหรับใส่พาสเวิร์ด

เป็นคำสั่งให้มองเห็นว่าในเครื่อง windowsXP นั้นมีแชร์อะไรเปิดอยู่บ้าง โดย ชื่อ winxp ที่อยู่หลัง -L นั้น
เป็นชื่อของคอมพิวเตอร์ windowsXP ตรวจสอบได้จากการคลิกขวา MyComputer และเลือกดูที่ชื่อคอมพิวเตอร์

smbclient //winxp/install -U administrator
password:

เป็นคำสั่งเข้าใช้งานแชร์ชื่อว่า install ในเครื่อง XP ด้วย administrator user

ตรวจสอบดูว่าเราสามารถใช้คำสั่งอะไรได้บ้างจาก msclient ด้วยเครื่องหมาย ? ที่พร้อมของ smbclient
จะปรากฏคำสั่งเรียงรายออกมาให้เลือกใช้ได้ตามความเหมาะสม



ในพร้อมของคำสั่ง msclient เหมือนคำสั่ง ftp ที่ได้เข้าไปยัง ftp server ได้แล้ว เหมือนหนึ่งว่าได้เข้าไปนั่ง
ที่คอมพิวเตอร์เครื่องนั้น ๆ แล้ว จึงสามารถจัดการไฟล์ด้วยการ copy มาไว้ที่เครื่องเราหรือจะโยนไฟล์ที่เครื่องเราไป
ที่เครื่องของ xp ก็ได้ คำสั่งต่าง ๆ ที่เราได้รู้จาก ? เอามาใช้ประโยชน์ เช่น

get filename คำสั่ง get ตามด้วยชื่อไฟล์ เป็นการ copy ไฟล์ที่ระบุมายัง linux
mget * เหมือนคำสั่ง get เพียงแต่ copy ครั้งละหลาย ๆไฟล์
ls ตรวจสอบว่าทีไดเรกปัจจุบันที่เรา login เข้ามาแล้วมีไฟล์อะไรบ้าง หากเราจะดูว่าแล้วที่ linux ของเราหละ
ขณะนี้มีไฟล์อะไรบ้างก็ใช้คำสั่ง ! ls
cd directory คำสั่ง cd ตามด้วย ไดเรกทอรีเป็นการเข้าไปยังไดเรกทอรีนั้น ๆ การตรวจสอบว่าขณะนี้เราอยู่ที่
ไดเรกทอรีอะไรให้ใช้คำสั่ง pwd
put และ mput เป็นคำสั่งโยนไฟล์จากเครื่อง linux ไปยังไดเรกทอรีปลายทางใน windows
ออกจากคำสั่ง msclient ด้วย quit

ใน windows เราไดเคย map drive ของเครื่องอื่น ๆ เข้ามาเป็น drive ตัวหนึ่งในเครื่องเพื่อจะได้ใช้งานได้โดยสะดวก
ใน linux ก็สามารถ map drive ลักษณะนั้นได้ เรียกว่าการ mount ซึ่งการ mount ในลีนุกซ์จะแตกต่างจากวินโดสว์
ที่ต้องสร้างไดเรกทอรีขึ้นมารองรับเสียก่อน และเข้าถึงแชร์นั้นโดยผ่านไดเรกทอรีที่สร้างนั้น ในตัวอย่างของวีดีโอนี้ map แชร์ชื่อว่า install ในวินโดวส์เข้ามาเป็นไดเรกทอรีในลีนุกซ์ และเข้าใช้งาน แชร์ install ผ่านไดเรกทอรี นั้น ดังนี้

สร้างไดเรกทอรีขึ้นมารองรับ mkdir /media/samba
map แชร์ด้วยคำสั่ง

smbmount //winxp/install /media/samba -o username=administrator

การยกเลิก drive ที่ map เข้ามาแล้ว ด้วยคำสั่ง smbumount /media/samba

จบวีดีช่วยสอนในไฟล์ที่ 1 เท่านี้

Samba Linux Server


Samba sets up network shares for chosen Unix directories (including all contained
subdirectories). These appear to Microsoft Windows users as normal Windows folders
accessible via the network. Unix users can either mount the shares directly as part of their file structure or, alternatively, can use a utility, smbclient (libsmb) installed with Samba to read the shares with a similar interface to a standard command line FTP program. Each directory can have different access privileges overlaid on top of the normal Unix file protections. For example: home directories would have read/write access for all known users, allowing each to access their own files. However they would still not have access to the files of others unless that permission would normally exist. Note that the netlogon
share, typically distributed as a read only share from /etc/samba/netlogon, is the logon

directory for user logon scripts.

Configuration is achieved by editing a single file (typically installed as /etc/smb.conf or /etc/samba/smb.conf). samba can also provide user logon scripts and group policy
implementation through poledit.

CODE

http://rapidshare.com/files/132632180/samba1.avi
http://rapidshare.com/files/132686954/samba2.avi
http://rapidshare.com/files/132632793/samba3.avi
http://rapidshare.com/files/132633169/samba4.avi
http://rapidshare.com/files/132633301/samba5.avi
http://rapidshare.com/files/132634112/samba6.avi
http://rapidshare.com/files/132751641/samba7_cupsprinting.avi

Wednesday, August 13, 2008

Samba with IPtables

หลังจากที่ set เครื่อง PDC ด้วย samba ขึ้นมาแล้ว หากรัน service iptables ด้วยจะทำให้เครื่องอื่น ๆเข้ามาใช้บริการไม่ได้เพราะถูกป้องกันด้วย firewall iptables ไปด้วย ไอ้ครั้นจะยกเลิก service iptables ไป PDC server ของเราก็จะไม่ปลอดภัย และดูเป็นธรรมดาๆ เสียเหลือเกิน (อายพวกมือเก๋า ๆ) อย่ากระนั้นเลยมาลองมั่วเปิด service iptables ร่วมกับ samba ดูสักตั้งหนึ่งประไร.....

ได้ยินมาว่าเจ้า samba ให้บริการผ่าน port 137,138,139 และ 445 มีคนแนะนำให้เปิดดูในไฟล์ /etc/services
ก็จะพบความจริงที่แสดงในบรรทัดดังนี้

netbios-ns 137/tcp # NetBIOS Name Service
netbios-ns 137/udp
netbios-dgm 138/tcp # NetBIOS Datagram Service
netbios-dgm 138/udp
netbios-ssn 139/tcp # NetBIOS Session Service
netbios-ssn 139/udp
microsoft-ds 445/tcp # Microsoft Directory Service
microsoft-ds 445/udp



เห็นกับตาอาจเป็นเพียงทฤษฏี มาลองดูของจริง ๆ ว่า samba มันเปิดพอร์ตไหนไว้บริการแน่ที่เครื่อง PDC ก่อนอื่นให้ stop
samba ก่อน แล้วตรวจสอบ พอร์ตที่เปิดบริการ จากนั้น start samba และตรวจสอบเทียบเคียงกันอีกชั้นหนึ่ง ดังนี้

# service smb stop
# netstat -ln > netstat-ln-smb.before
# service smb start
# netstat -ln > netstat-ln-smb.after
# diff netstat-ln-smb.*


edit /etc/sysconfig/iptables

*filter
:INPUT ACCEPT [56005:161967936]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [55983:161988082]
-A INPUT -p udp -m udp --dport 138 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 139 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 445 -j ACCEPT
-A INPUT -p udp -m udp --dport 137 -j ACCEPT
COMMIT





แหล่งอ้างอิง http://troy.jdmz.net/samba/fw/

Twitter Delicious Facebook Digg Stumbleupon Favorites More