Setting up NTP Client on Solaris 10

1. vi /etc/inet/ntp.conf

#Created by bankster: 2009-05-07
#follow the last modified by Mr.Kitti :2008-06-17

#
# To start/stop/restart process :
#    # svcadm disable ntp
#    # svcadm enable ntp
#    # svcadm restart ntp

driftfile /etc/inet/ntp.drift

logfile /var/log/xntpd.log

server  clock.thaicert.org
server  time1.nimt.or.th
server  time2.nimt.or.th
server  time3.nimt.or.th

# end of /etc/inet/ntp.conf

2.
# touch /etc/inet/ntp.drift
# touch /var/log/xntpd.log

3. svcadm enable ntp

Posted in sysadmin | Tagged , , , | Leave a comment

SUN Solaris 10 and the word “Secure by Default” in practice

คำว่า secure by default คิดว่าหลายๆ คนในวงการ sysadmin ได้ยิน ได้เห็น แล้วคงต้องนึกถึง OS ที่ ถูกตั้งค่ามาให้มีความปลอดภัยแบบ  out of the box โดยแทบจะไม่ต้อง tune กันเลยทีเดียว อย่างเช่น ระบบปฏิบัติการที่เป็นที่รู้จักกันดีอย่าง OpenBSD นอกจากนั้น ระบบปฏิบัติการใหม่ๆ อย่าง ubuntu และ windows vista ก็เข้าข่าย secure by default กับเค้าบ้างเหมือนกัน โดย ubuntu และ vista มุ่งเน้นไปที่ administrative priviledges ใน ubuntu จะไม่มี root account มากับการติดตั้งครั้งแรก โดยจะให้สิทธิ์ super user กับ user account แรกของระบบ ส่วน windows vista ก็ได้เน้นเรื่องของ administrative priviledges เหมือนกัน โดยเมื่อมีการทำอะไรสักอย่างที่เกี่ยวข้องกับระบบ หรือ ระบบจะได้รับผลกระทบ ไม่ว่าจะเป็นการกระทำโดย Software หรือ User เอง ก็จะมี prompt ขึ้นมา alert ซึ่งก็คือ UAC นั่นเอง

Solaris/OpenSolaris เองก็ concern เรื่อง secure by default เหมือนกัน โดยวิธีการของ solaris ก็คือ สร้าง profile สำหรับ Service Management Facilities (SMF) เพื่อ limit การทำงาน service ต่างๆ ตามความเหมาะสมของ ระบบ

สำหรับการ apply profile ต่างๆ ให้กับ SMF สามารถทำได้ดังนี้

#svccfg apply /var/svc/profile/generic_limited_net.xml

หรือเข้าไปดู profile ทั้งหมดได้ที่ /var/svc/profile

#cd /var/svc/profile
#ls -la
drwxr-xr-x   2 root     sys          512 Apr 24 11:59 .
drwxr-xr-x   5 root     sys          512 Apr 24 11:26 ..
lrwxrwxrwx   1 root     other         18 Apr 24 11:26 generic.xml -> ./generic_open.xml
-r–r–r–   1 root     sys        11830 Mar 12  2008 generic_limited_net.xml
-r–r–r–   1 root     sys         5860 Mar 12  2008 generic_open.xml
-r–r–r–   1 root     sys         3118 Mar 12  2008 inetd_generic.xml
lrwxrwxrwx   1 root     other         17 Apr 24 11:26 inetd_services.xml -> inetd_generic.xml
-r–r–r–   1 root     sys          739 Jan 22  2005 inetd_upgrade.xml
lrwxrwxrwx   1 root     root          12 Apr 24 11:52 name_service.xml -> ns_files.xml
-r–r–r–   1 root     sys          755 Jan 22  2005 ns_dns.xml
-r–r–r–   1 root     sys          547 Jan 22  2005 ns_files.xml
-r–r–r–   1 root     sys          661 Jan 22  2005 ns_ldap.xml
-r–r–r–   1 root     sys          779 Jan 22  2005 ns_nis.xml
-r–r–r–   1 root     sys          785 Jan 22  2005 ns_nisplus.xml
-r–r–r–   1 root     sys         1762 Jan 22  2005 ns_none.xml
lrwxrwxrwx   1 root     root          18 Apr 24 11:59 platform.xml -> platform_i86pc.xml
-r–r–r–   1 root     sys          663 Jan 22  2005 platform_i86pc.xml
-r–r–r–   1 root     sys          560 Jan 22  2005 platform_none.xml
-r–r–r–   1 root     sys        13838 Aug  9  2007 prophist.SUNWcsr
-rw-r–r–   1 root     other       6618 Apr 24 11:37 upgrade.app.20090424115945

จะพบว่า solaris ได้จัดทำ Profile ไว้ให้เรียกใช้ ได้อย่างเหมาะสมตามความต้องการของการให้บริการ ซึ่งเป็นอีกวิธีหนึ่งที่จะช่วย disable service ที่ไม่จำเป็น ซึ่งจะส่งผลในแง่ของ security แล้วยังส่งผลในเรื่องของประสิทธิภาพของ resources ด้วย

Posted in sysadmin | Tagged , , , , | 1 Comment

change user’s shell

solution 1. edit /etc/passwd

or

solution 2. usermod -s /bin/bash user

Posted in sysadmin | Tagged , , , | 4 Comments

Solaris Home Directory

Under Solaris, home directories are conventionally kept on one of two places, /home or /export/home. The /home directory is under control of the automounter and only the automounter can create directories there. The /export/home directory is where users home directories can be created by the system administrator.

To create an account for user ‘oops’ where the UID is 400 and users home directory is not automounted:

  1. useradd -u 400 -g user -c useroops -m -d /export/home/oops oops
  2. passwd oops (To set the password)
  3. chown oops /export/home/oops
  4. chgrp user /export/home/oops

To create an account for ‘oops’ where the home directory is automounted and the mount point for /home is /etc/auto_home:

  1. useradd -u 400 -g user -c useroops oops
  2. passwd oops (To set the password)
  3. mkdir /export/home/oops
  4. chown oops /export/home/oops
  5. chgrp user /export/home/oops
  6. vi /etc/auto_home and add the line:oops remotehost:/home/&

This sets the user oops’ home directory to /home/oops exported from a remote host.

Posted in sysadmin | Tagged , , | Leave a comment

wget problem [solved]

อยู่ดีดี wget ที่เคยใช้ download อะไรต่างๆนาๆ บน Linux/Unix Server ที่ไม่มี GUI
เกิดใช้ไม่ได้ขึ้นมาซะงั้น  อาการก็เป็นแบบนี้อ่ะ

# wget http://awstats.sourceforge.net/awstats.ftp.urldetail.html
–04:17:37–  http://awstats.sourceforge.net/awstats.ftp.urldetail.html
Resolving awstats.sourceforge.net… 216.34.181.96
Connecting to awstats.sourceforge.net|216.34.181.96|:80… connected.
HTTP request sent, awaiting response…

เหมือนจะ http request ผ่าน แต่ http response กลับไม่มาถึงซะงั้น
ก็เลย ลอง man wget ดูว่าัมันมี option อะไีรให้้ใช้บ้าง เพราะว่า ลอง download file เดียวกันจาก windows server
ที่อยู่บน subnet เดียวกันกับ เจ้า linux server ตัวนี้ มันดัน download ได้ เลยคิดว่าต้องเป็นที่ wget แน่ๆ
อ่าน man ไปเรื่อยๆ ก็เจอกับ –user-agent ที่เอาไว้กำหนดชื่อ ของ browser หรือ http client
ก็เลยลอง wget ด้วย option นี้ดู

# wget –user-agent=”Bankster Browser 1.0″ http://awstats.sourceforge.net/awstats.ftp.urldetail.html
–04:22:42–  http://awstats.sourceforge.net/awstats.ftp.urldetail.html
Resolving awstats.sourceforge.net… 216.34.181.96
Connecting to awstats.sourceforge.net|216.34.181.96|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 238747 (233K) [text/html]
Saving to: `awstats.ftp.urldetail.html.2′

100%[============>] 238,747     79.5K/s   in 2.9s

04:22:46 (79.5 KB/s) - `awstats.ftp.urldetail.html.2′ saved [238747/238747]

เย้ download ได้แล้ว แต่ขี้เกียจพิมพ์ –user-agent=”xx” ทุกครั้งอ่ะ
เลยสร้าง bash script ขึ้นมา โดยเฉพาะเลย ตั้งชื่อว่า fooget ละกัน
ก็ cd /usr/bin/ แล้ว vi fooget

#!/bin/bash
/usr/bin/wget –user-agent=”wget” ${1}

แล้วก็ chmod +x /usr/bin/fooget ให้ execute ได้ เวลาเรียกก็ fooget URL
เสร็จแล้วครับ

Posted in sysadmin | Tagged , , , , | 1 Comment

Proposal Language and Presentation Training at Microsoft Thailand

วันนี้ก็ไป train proposal language และัก็ presentation ที่ MS มาแหละ
เจ้า MS ที่ไปนี่อยู่ที่ ชั้น 38 ตึก CRC All Season Place เพลินจิต

ก็ตื่นตั้งแต่ตีสาม อย่าเข้าใจผิดว่าอยากจะไปอะไรขนาดนั้น
จริงๆ มันชอบตื่นเวลานี้อ่ะ ตื่นมาแล้วก็เลยออกไปหาอะไรกิน 7-eleven แล้วก็นั่ง set server ไปเรื่อยๆ
จน หกโมงก็อาบน้ำ แต่งตัว ใส่ชุด Imagine Cup 2009 วันแรก วันนี้เลย 555

เจ็ดโมง 15 ก็ไปขึ้นรถตู้อนุสาวรีย์ กับพี่ลิง Bushido
ถึง อนุสาวรีย์ก็ไปขึ้น BTS ไปลงสถานีเพลินจิต
เหอๆๆ  งงกะทางเข้าตึกมาก สุดท้ายก็เจอ

พอดีเห็นทีมจาก Mahidol เลยทำเนียน เดินตามเค้าไป ก๊าากก
lift ขาขึ้นนี่ไม่เท่าไหร่ แต่ขาลงนี่ เสียวมาก ==”

ไปถึงชั้น 38 พี่เค้าก็บอกว่า IC2009 Train ที่ Audirium 3
ก็เดินเข้าไปนั่ง

พอคนมาเกือบครบ ครูสอนก็เดินเข้ามา โอ้โห ทุ่มทุน
ไม่ผิดคาด wallstreet จัดซะอย่าง มี ครูสอนฝรั่งสองคน
ชื่อ Jesse กับ Luke  ตอนเช้าก็เรียน Proposal Language
พวก persuative writing , emotive adjective , powerful and strong verbs,
logical , cause and effect , seems to be facts
โดยตอนเรียนก็แบ่งกลุ่ม ให้คละๆ กัน

ในทีมก็มี ตั้ม จาก จุฬา พี่แคน จาก สุรนารี
พี่ทิพย์ จาก Mahidol , พัฒน์ จาก Mahidol และก็มีพี่เบิร์ด MSP มารวมกลุ่มด้วย

เค้าก็สอนดีอ่ะนะ แล้วตอนหลังก็มีให้เอาความรู้ในช่วงเช้า มา
prove proposal ของแต่ละทีม โดยกระจาย proposal ไปตามทีมต่างๆ
แล้วก็รวมกลุ่มกลับมาเป็น University แล้วแจกคืน และก็เิปิดโอกาสให้
ทีมที่ Prove proposal ได้ discuss กัน

เหนื่อยมากมายวันนี้
กลัีบมาถึงบ่ายสอง อาบน้ำ แล้วนอนเลย
ข้าวปลาไม่กินละ เพิ่งจะตื่นเนี่ย

Posted in life | Tagged , , , , , | Leave a comment

Linux Performance Tuning (sysctl.conf)

1. timeout timewait parameter
Determines the time that must elapse before TCP/IP can release a closed connection and reuse its resources.

echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout

2. TCP_KEEPALIVE_INTERVAL

* Description: Determines the wait time between isAlive interval probes.
* How to view or set: Issue the following command to set the value:

echo 15 > /proc/sys/net/ipv4/tcp_keepalive_intvl

3. open file limit
ulimit -a
ulimit -n 8000

4.# Connection backlog

* Description: Change the following parameters when a high rate of incoming connection requests result in connection failures:

echo 3000 > /proc/sys/net/core/netdev_max_backlog
echo 3000 > /proc/sys/net/core/somaxconn

5. sysctrl.conf
Edit /etc/sysctl.conf - tighten
1. net.ipv4.tcp_syncookies = 1          # Enable TCP SYN Cookie Protection
2. net.ipv4.conf.all.accept_source_route = 0    # Disables IP source routing
3. net.ipv4.conf.all.accept_redirects = 0     # Disable ICMP Redirect Acceptance
4. net.ipv4.conf.all.rp_filter = 1        # Enable IP spoofing protection, turn on source route verification
5. net.ipv4.icmp_echo_ignore_broadcasts = 1 # Enable ignoring broadcasts request
6. net.ipv4.icmp_ignore_bogus_error_responses = 1 # Enable bad error message Protection
7 net.ipv4.conf.all.log_martians = 1         # Log Spoofed Packets, Source Routed Packets, Redirect Packets

for more information:

http://www.performancewiki.com/linux-tuning.html
http://www.webhostingtalk.com/showthread.php?t=257654
http://tldp.org/HOWTO/TCP-Keepalive-HOWTO/usingkeepalive.html

Posted in sysadmin | Tagged , , , , , | 209 Comments

ตั้งเวลาใน CentOS

date mmddhhmmyyyy
date 040203052009

เพิ่มเติม sync เวลาอัตโนมัติด้วย ntpdate

yum install ntp

chkconfig –levels 235 ntpd on

ntpdate 0.pool.ntp.org

service ntpd start

Posted in Uncategorized | Tagged , , , , | Leave a comment

วันนี้

1. กู้คืน www.it.kmitl.net/forums

2. กู้คืน http://student.it.kmitl.net/bankster

3. เรียน summer วันแรก

4. วันเกิดผมเอง

5. centos 5.3 ออกวันนี้

post ไว้หน่อยกัน blog ร้าง

Posted in mylife | Tagged | Leave a comment

query interface

find_all : return multiple records
_by_* : replace * with your column
(false) : where complete like ‘false’

def incomplete
@tasks = Task.find_all_by_complete(false)
end

find : return single record
_by_* : replace * with your column
(false,:order => ‘created_at’ DESC) : where complete like ‘false’ and order by created_at descending

def last_incomplete
@task = Task.find_by_complete(false, :order => ‘created_at DESC’)
end

Posted in project, rails, rubyonrials | Tagged , , , | Leave a comment
  • Tags

  • Pages

  • Categories

  • Archives