Tip : การรักษาความปลอดภัย โดยปิด Service ที่ไม่ได้ใช้งาน บน CentOS สำหรับ Gateway อย่างเดียว
จากท่าน ton-or""""
Ton-Or — 26 September, 2009 - 11:41
กรณีที่เราไม่ได้ใช้งานด้านอื่นๆ เช่น mail server เน้นนำมาใช้เป็น gateway ต่อ ADSL ของเราอย่างเดียวนั้น Srevice หลายๆตัวที่ run อยู่ ไม่จำเป็นต้องใช้มาปิด Service พวกนั้นกัน
ตรวจสอบ Service ทั้งหมดที่เปิดอยู่ก่อน
chkconfig –list | grep on
จะได้ประมาณนี้
atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
messagebus 0:off 1:off 2:off 3:on 4:on 5:on 6:off
smartd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
portmap 0:off 1:off 2:off 3:on 4:on 5:on 6:off
sendmail 0:off 1:off 2:on 3:on 4:on 5:on 6:off
netfs 0:off 1:off 2:off 3:on 4:on 5:on 6:off
cups 0:off 1:off 2:on 3:on 4:on 5:on 6:off
irqbalance 0:off 1:off 2:off 3:on 4:on 5:on 6:off
rpcgssd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
xfs 0:off 1:off 2:on 3:on 4:on 5:on 6:off
isdn 0:off 1:off 2:on 3:on 4:on 5:on 6:off
autofs 0:off 1:off 2:off 3:on 4:on 5:on 6:off
gpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off
apmd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
acpid 0:off 1:off 2:off 3:on 4:on 5:on 6:off
microcode_ctl 0:off 1:off 2:on 3:on 4:on 5:on 6:off
pcmcia 0:off 1:off 2:on 3:on 4:on 5:on 6:off
cpuspeed 0:off 1:on 2:on 3:on 4:on 5:on 6:off
xinetd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
rpcidmapd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
readahead_early 0:off 1:off 2:off 3:off 4:off 5:on 6:off
readahead 0:off 1:off 2:off 3:off 4:off 5:on 6:off
sshd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
anacron 0:off 1:off 2:on 3:on 4:on 5:on 6:off
network 0:off 1:off 2:on 3:on 4:on 5:on 6:off
kudzu 0:off 1:off 2:off 3:on 4:on 5:on 6:off
syslog 0:off 1:off 2:on 3:on 4:on 5:on 6:off
nfslock 0:off 1:off 2:off 3:on 4:on 5:on 6:off
rawdevices 0:off 1:off 2:off 3:on 4:on 5:on 6:off
mdmonitor 0:off 1:off 2:on 3:on 4:on 5:on 6:off
haldaemon 0:off 1:off 2:off 3:on 4:on 5:on 6:off
ลอกเขามาเลยแล้วกัน
/sbin/chkconfig --level 0123456 portmap off
/sbin/chkconfig --level 0123456 nfslock off
/sbin/chkconfig --level 0123456 netfs off
/sbin/chkconfig --level 0123456 rpcgssd off
/sbin/chkconfig --level 0123456 rpcidmapd off
/sbin/chkconfig --level 0123456 autofs off
/sbin/chkconfig --level 0123456 sendmail off
/sbin/chkconfig --level 0123456 cups off
/sbin/chkconfig --level 0123456 xfs off
/sbin/chkconfig --level 0123456 isdn off
/sbin/chkconfig --level 0123456 pcmcia off
อ้างอิง
http://prefetch.net/blog/index.php/2006/12/27/securing-centos-installations-by-disabling-unneeded-services/
linux - cafedevel - News
1910 reads
วันอาทิตย์ที่ 12 มิถุนายน พ.ศ. 2554
วันอาทิตย์ที่ 3 เมษายน พ.ศ. 2554
เข้าหน้า login ต้องคลิ๊กหลายครั้งวิธีแก้ไข
แก้ปัญหา user ต้อง Login 2 ครั้งจึงจะเข้าสู่ระบบได้
พบคำตอบแล้วครับ ปัญหา user ต้อง Login 2 ครั้งจึงเข้าสู่ระบบได้ เป็นที่ไฟล์ radiusd.conf ศึกษาวิธีแก้ปัญหาจากบทความนี้
# nano /etc/raddb/radiusd.conf
กดปุ่ม Ctrl + w แล้วพิมพ์ cleanup_delay = 5 กดปุ่ม Enter
โปรแกรมจะวิ่งไปที่บรรทัด cleanup_deay = 5 ให้แก้ไขใหม่เป็น cleanup_deay = 0
บันทึกไฟล์ กดปุ่ม Ctrl + o ตามด้วยปุ่ม Enter ออกจากการแก้ไข กดปุ่ม Ctrl + x
สั่งให้ radiusd ทำงานใหม่ด้วยคำสั่ง
# /etc/init.d/radiusd restart
หรือ
# service radiusd restart
แหล่งข้อมูลจาก
http://www.kroonis.org/index.php?name=authen&file=readauthen&id=13
พบคำตอบแล้วครับ ปัญหา user ต้อง Login 2 ครั้งจึงเข้าสู่ระบบได้ เป็นที่ไฟล์ radiusd.conf ศึกษาวิธีแก้ปัญหาจากบทความนี้
# nano /etc/raddb/radiusd.conf
กดปุ่ม Ctrl + w แล้วพิมพ์ cleanup_delay = 5 กดปุ่ม Enter
โปรแกรมจะวิ่งไปที่บรรทัด cleanup_deay = 5 ให้แก้ไขใหม่เป็น cleanup_deay = 0
บันทึกไฟล์ กดปุ่ม Ctrl + o ตามด้วยปุ่ม Enter ออกจากการแก้ไข กดปุ่ม Ctrl + x
สั่งให้ radiusd ทำงานใหม่ด้วยคำสั่ง
# /etc/init.d/radiusd restart
หรือ
# service radiusd restart
แหล่งข้อมูลจาก
http://www.kroonis.org/index.php?name=authen&file=readauthen&id=13
วันเสาร์ที่ 26 กุมภาพันธ์ พ.ศ. 2554
กรณี error เกี่ยวกับ auto tool ทุกตัว
In /usr/ports/www/apache22/Makefile, replace
Code:
USE_AUTOTOOLS= autoconf:267 libtool:22with
Code:
USE_AUTOTOOLS= autoconf libtool
ตัวโปรแกรมอื่น ๆ เช่นกันเช่น proftp หรือ php5
Code:
USE_AUTOTOOLS= autoconf:267 libtool:22with
Code:
USE_AUTOTOOLS= autoconf libtool
ตัวโปรแกรมอื่น ๆ เช่นกันเช่น proftp หรือ php5
วันศุกร์ที่ 25 กุมภาพันธ์ พ.ศ. 2554
วิธีโม squid จากเวบ linuxthai
บทความจากเวบ linuxthai.org/forum คุณFAK-MUW
http_port 3128 transparent no-connection-auth
tcp_outgoing_address 0.0.0.0
udp_incoming_address 0.0.0.0
udp_outgoing_address 0.0.0.0
icp_port 0
# Time Out
request_timeout 5 minutes
forward_timeout 5 minutes
connect_timeout 5 minutes
peer_connect_timeout 1 minutes
pconn_timeout 120 seconds
read_timeout 15 minutes
request_timeout 5 minutes
persistent_request_timeout 2 minute
shutdown_lifetime 5 seconds
negative_ttl 2 minutes
negative_ttl 3 minutes
positive_dns_ttl 120 seconds
negative_dns_ttl 120 seconds
netdb_low 900
netdb_high 1000
client_db on
client_lifetime 1 day
# mark for no cache
hierarchy_stoplist cgi-bin ? localhost .asp .aspx .php .inf .dll .Xt .xtp .ini localhost php$ inf$ dll$ Xt$ xtp$ ini$ asp$ aspx$ patch_lv1
acl QUERY urlpath_regex cgi-bin \? localhost .asp .aspx .php .inf .dll .Xt .xtp .ini .exe localhost php$ inf$ dll$ Xt$ xtp$ ini$ asp$ aspx$ updatelist$ patch_lv1
cache deny QUERY
# OPTIONS WHICH AFFECT THE CACHE SIZE
# -----------------------------------
#---- ËÒÃ 3
cache_mem 1536 MB
cache_swap_low 90
cache_swap_high 95
memory_pools on
memory_pools_limit 512 MB
maximum_object_size 256 MB
maximum_object_size_in_memory 1024 KB
ipcache_size 4096
ipcache_low 90
ipcache_high 95
fqdncache_size 4096
cache_replacement_policy heap LFUDA
memory_replacement_policy heap GDSF
# LOGFILE
# -------------------------------------
#cache_dir aufs /data/squid 20480 24 256
cache_dir ufs /var/spool/squid 9000 16 256
cache_access_log /var/log/squid/access.log
cache_log /var/log/squid/cache.log
cache_store_log none
# mime_table /usr/share/squid/mime.conf
pid_filename /var/run/squid.pid
log_fqdn off
client_netmask 255.255.255.255
ftp_passive on
ftp_sanitycheck on
#DNS ¢Í§SERVER
dns_nameservers 127.0.0.1 203.146.237.237 203.146.237.222
# OPTIONS FOR TUNING THE CACHE
# --------------------------------------
# refresh_pattern ^ftp: 10080 95% 241920 reload-into-ims override-lastmod
# refresh_pattern . 180 95% 120960 reload-into-ims override-lastmod
refresh_pattern -i \.*$ 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^https://*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^https://*.in.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^https://www.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^https://www.*.in.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.co.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.*-*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*-*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*-*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*-*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.*-*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*-*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*-*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*-*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.co.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.in.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.gg.in.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.org 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.co.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.in.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.org 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.*.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.*.*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.co.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.in.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.org 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.co.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.in.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.org 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.*.*-* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.*-* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*-* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*-* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*-* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.*.* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i .(gif|tif|tiff|jpeg|xbm|png|wrl|ico|pnm|pbm|pgm|ppm|rgb|xpm|xwd|pic|pict|bmp|jpg|jpe)$ 0 25000% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i .(arj|sit|zip|rar|rgz|cfg|rtf|psf|hqx|exe|lzh|lha|cab|tar|tgz|gz|Z|wp|wp5|ps|prn|srf|pdf|tex|latax|txt|doc|ppt|gpf|upd|iso|jar|bz2|uue|gzip|ace|cab|kf|a[0-9][0-9]|r[0-9][0-9])$ 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i .(midi|wav|aif|aiff|au|ram|ra|snd|mid|mp2|mp3|mp4|mov|mpg|mpeg|mpe|avi|qt|qtm|viv)$ 0 120% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i .(swf)$ 525960 18000% 525960 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320 reload-into-ims
refresh_pattern -i \\.flv$ 10080 90% 999999 ignore-no-cache override-expire ignore-private
quick_abort_min 0 KB
quick_abort_max 0 KB
quick_abort_pct 100
half_closed_clients off
# ACL CONTROLS
# ---------------------------------------------------------------
acl virus_nimda urlpath_regex -i .*/system32/cmd\.exe.*
acl virus_nimda2 urlpath_regex -i .*/winnt/system32/cmd.exe.*
acl virus_nimda2 urlpath_regex -i .*/MSADC/root.exe..c.dir$
acl virus_nimda2 urlpath_regex -i .*/scripts/root.exe..c.dir$
acl virus_nimda2 urlpath_regex -i .*/appie.exe
acl virus_nimda2 urlpath_regex -i .*/app.exe
acl Manager proto cache_object
acl all src 0.0.0.0/0
acl localhost src 127.0.0.1/32
acl our_networks src 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16
acl All_Port port 1-65535
acl CONNECT method CONNECT
acl blockweb dst 208.73.212.0/24
acl bitword urlpath_regex \.torrent\*?$
acl bittorrent_announce url_regex -i http://.+announce.+info_hash= #announce.php?passkey
##############################
# Limited file download < 128 MB ´ÒǹìâËÅ´äÁèà¡Ô¹ 128 M
# reply_body_max_size SizeInByte deny|allow acl
reply_body_max_size 134217728 deny our_networks
request_body_max_size 128 MB
##############################
http_access deny virus_nimda
http_access deny virus_nimda2
http_access deny bitword
http_access deny bittorrent_announce
http_access deny blockweb
http_access allow Manager all
http_access deny Manager
http_access allow All_Port
http_access allow CONNECT All_Port
http_access allow localhost
http_access allow our_networks
http_access deny all
http_reply_access allow all
icp_access allow all
# ADMINISTRATIVE PARAMETERS
# ------------------------------
cache_mgr squid@localhost
visible_hostname cache.hadyaiinternet.com
# MISCELLANEOUS
# -------------------------------
logfile_rotate 3
log_icp_queries off
query_icmp off
buffered_logs off
reload_into_ims on
nonhierarchical_direct off
prefer_direct on
strip_query_terms off
pipeline_prefetch on
ie_refresh on
forwarded_for on
vary_ignore_expire on
store_dir_select_algorithm round-robin
ignore_unknown_nameservers on
header_access Allow allow all
header_access Authorization allow all
header_access Cache-Control allow all
header_access Content-Encoding allow all
header_access Content-Length allow all
header_access Content-Type allow all
header_access Date allow all
header_access Expires allow all
header_access Host allow all
header_access If-Modified-Since allow all
header_access Last-Modified allow all
header_access Location allow all
header_access Pragma allow all
header_access Accept allow all
header_access Accept-Charset allow all
header_access Accept-Encoding allow all
header_access Accept-Language allow all
header_access Content-Language allow all
header_access Mime-Version allow all
header_access Retry-After allow all
header_access Title allow all
header_access Connection allow all
header_access Proxy-Connection allow all
header_access All allow all
http_port 3128 transparent no-connection-auth
tcp_outgoing_address 0.0.0.0
udp_incoming_address 0.0.0.0
udp_outgoing_address 0.0.0.0
icp_port 0
# Time Out
request_timeout 5 minutes
forward_timeout 5 minutes
connect_timeout 5 minutes
peer_connect_timeout 1 minutes
pconn_timeout 120 seconds
read_timeout 15 minutes
request_timeout 5 minutes
persistent_request_timeout 2 minute
shutdown_lifetime 5 seconds
negative_ttl 2 minutes
negative_ttl 3 minutes
positive_dns_ttl 120 seconds
negative_dns_ttl 120 seconds
netdb_low 900
netdb_high 1000
client_db on
client_lifetime 1 day
# mark for no cache
hierarchy_stoplist cgi-bin ? localhost .asp .aspx .php .inf .dll .Xt .xtp .ini localhost php$ inf$ dll$ Xt$ xtp$ ini$ asp$ aspx$ patch_lv1
acl QUERY urlpath_regex cgi-bin \? localhost .asp .aspx .php .inf .dll .Xt .xtp .ini .exe localhost php$ inf$ dll$ Xt$ xtp$ ini$ asp$ aspx$ updatelist$ patch_lv1
cache deny QUERY
# OPTIONS WHICH AFFECT THE CACHE SIZE
# -----------------------------------
#---- ËÒÃ 3
cache_mem 1536 MB
cache_swap_low 90
cache_swap_high 95
memory_pools on
memory_pools_limit 512 MB
maximum_object_size 256 MB
maximum_object_size_in_memory 1024 KB
ipcache_size 4096
ipcache_low 90
ipcache_high 95
fqdncache_size 4096
cache_replacement_policy heap LFUDA
memory_replacement_policy heap GDSF
# LOGFILE
# -------------------------------------
#cache_dir aufs /data/squid 20480 24 256
cache_dir ufs /var/spool/squid 9000 16 256
cache_access_log /var/log/squid/access.log
cache_log /var/log/squid/cache.log
cache_store_log none
# mime_table /usr/share/squid/mime.conf
pid_filename /var/run/squid.pid
log_fqdn off
client_netmask 255.255.255.255
ftp_passive on
ftp_sanitycheck on
#DNS ¢Í§SERVER
dns_nameservers 127.0.0.1 203.146.237.237 203.146.237.222
# OPTIONS FOR TUNING THE CACHE
# --------------------------------------
# refresh_pattern ^ftp: 10080 95% 241920 reload-into-ims override-lastmod
# refresh_pattern . 180 95% 120960 reload-into-ims override-lastmod
refresh_pattern -i \.*$ 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^https://*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^https://*.in.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^https://www.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^https://www.*.in.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.co.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.*-*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*-*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*-*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*-*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.*-*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*-*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*-*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*-*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.co.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.in.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.gg.in.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.org 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.co.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.in.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.org 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.*.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.com 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.*.*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.net 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.co.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.in.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.org 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.co.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.in.th 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://www.*.*.org 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.*.*-* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.*-* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*-* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*-* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*-* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.*.* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.*.* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.*.* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://*.* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i ^http://* 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i .(gif|tif|tiff|jpeg|xbm|png|wrl|ico|pnm|pbm|pgm|ppm|rgb|xpm|xwd|pic|pict|bmp|jpg|jpe)$ 0 25000% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i .(arj|sit|zip|rar|rgz|cfg|rtf|psf|hqx|exe|lzh|lha|cab|tar|tgz|gz|Z|wp|wp5|ps|prn|srf|pdf|tex|latax|txt|doc|ppt|gpf|upd|iso|jar|bz2|uue|gzip|ace|cab|kf|a[0-9][0-9]|r[0-9][0-9])$ 0 100% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i .(midi|wav|aif|aiff|au|ram|ra|snd|mid|mp2|mp3|mp4|mov|mpg|mpeg|mpe|avi|qt|qtm|viv)$ 0 120% 1440 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern -i .(swf)$ 525960 18000% 525960 override-lastmod override-expire reload-into-ims ignore-reload
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320 reload-into-ims
refresh_pattern -i \\.flv$ 10080 90% 999999 ignore-no-cache override-expire ignore-private
quick_abort_min 0 KB
quick_abort_max 0 KB
quick_abort_pct 100
half_closed_clients off
# ACL CONTROLS
# ---------------------------------------------------------------
acl virus_nimda urlpath_regex -i .*/system32/cmd\.exe.*
acl virus_nimda2 urlpath_regex -i .*/winnt/system32/cmd.exe.*
acl virus_nimda2 urlpath_regex -i .*/MSADC/root.exe..c.dir$
acl virus_nimda2 urlpath_regex -i .*/scripts/root.exe..c.dir$
acl virus_nimda2 urlpath_regex -i .*/appie.exe
acl virus_nimda2 urlpath_regex -i .*/app.exe
acl Manager proto cache_object
acl all src 0.0.0.0/0
acl localhost src 127.0.0.1/32
acl our_networks src 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16
acl All_Port port 1-65535
acl CONNECT method CONNECT
acl blockweb dst 208.73.212.0/24
acl bitword urlpath_regex \.torrent\*?$
acl bittorrent_announce url_regex -i http://.+announce.+info_hash= #announce.php?passkey
##############################
# Limited file download < 128 MB ´ÒǹìâËÅ´äÁèà¡Ô¹ 128 M
# reply_body_max_size SizeInByte deny|allow acl
reply_body_max_size 134217728 deny our_networks
request_body_max_size 128 MB
##############################
http_access deny virus_nimda
http_access deny virus_nimda2
http_access deny bitword
http_access deny bittorrent_announce
http_access deny blockweb
http_access allow Manager all
http_access deny Manager
http_access allow All_Port
http_access allow CONNECT All_Port
http_access allow localhost
http_access allow our_networks
http_access deny all
http_reply_access allow all
icp_access allow all
# ADMINISTRATIVE PARAMETERS
# ------------------------------
cache_mgr squid@localhost
visible_hostname cache.hadyaiinternet.com
# MISCELLANEOUS
# -------------------------------
logfile_rotate 3
log_icp_queries off
query_icmp off
buffered_logs off
reload_into_ims on
nonhierarchical_direct off
prefer_direct on
strip_query_terms off
pipeline_prefetch on
ie_refresh on
forwarded_for on
vary_ignore_expire on
store_dir_select_algorithm round-robin
ignore_unknown_nameservers on
header_access Allow allow all
header_access Authorization allow all
header_access Cache-Control allow all
header_access Content-Encoding allow all
header_access Content-Length allow all
header_access Content-Type allow all
header_access Date allow all
header_access Expires allow all
header_access Host allow all
header_access If-Modified-Since allow all
header_access Last-Modified allow all
header_access Location allow all
header_access Pragma allow all
header_access Accept allow all
header_access Accept-Charset allow all
header_access Accept-Encoding allow all
header_access Accept-Language allow all
header_access Content-Language allow all
header_access Mime-Version allow all
header_access Retry-After allow all
header_access Title allow all
header_access Connection allow all
header_access Proxy-Connection allow all
header_access All allow all
อบรม advance network
วันศุกร์ที่ 5 พฤศจิกายน พ.ศ. 2553
mrtg บน freebsd
1. ติดตั้ง snmp ผ่าน ports
#cd /usr/ports/net-mgmt/net-snmp/
#make ; make install clean
#rehash
แก้ไข config ไฟล์ ในที่นี้ผมใช้ editor ee นะครับ ท่านจะใช้ pico ก็ได้
#ee /usr/local/share/snmp/snmpd.conf
พิมพ์ 4 บรรทัดนี้ลงไปครับ ของเดิมหากมี ลบ ให้หมด เอา 4 บรรทัดนี้พอ
rouser public noauth
rocommunity public localhost
syslocation gateway at service room
syscontact webmaster@xxx.com
(2 บรรทัดสุดท้าย แก้ไขตามใจชอบครับ)
แล้ว save ครับ
เรียก snmpd ให้ทำงาน
#snmpd &
ตรวจดูว่ามี process snmpd จริงป่าว....
#ps -ax | grep snmpd
หากอยากให้ snmp ทำงานทุกครั้งก็แก้ไข /etc/rc.conf เพิ่ม สองบรรทัดนี้ลงไป
snmpd_enable="YES"
snmpd_flags="-a -Lsd -p /var/run/snmpd.pid"
2. ติดตั้ง MRTG ผ่าน port
#cd /usr/ports/net-mgmt/mrtg/
#make ; make install clean
#rehash
#cfgmaker public@localhost> /usr/local/etc/mrtg/mrtg.cfg
แก้ไข config
#ee /usr/local/etc/mrtg/mrtg.cfg
WorkDir: /home/webmrtg/public_html
Options[_]:growright,bits
***ผม adduser มา 1 คนชื่อ webmrtg แล้วสร้าง public_html ไว้เพื่อใช้เป็น mrtg เวบครับ
#indexmaker --columns=1 --output=/home/webmrtg/public_html/index.html /usr/local/etc/mrtg/mrtg.cfg
#mrtg /usr/local/etc/mrtg/mrtg.cfg
รันไป 3 ครั้ง ก็จะไม่มี warning ครับ
#ee /etc/crontab
พิมพ์ บรรทัดนี้ ต่อท้ายของเดิม
*/5 * * * * root /usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg
เพื่อให้กราฟ update ทุก ๆ 5 นาที
ถ้าอยากให้กราฟแสดง cpu และ ram ก็เพิ่ม
code ด้านล่างลงไปในไฟล์ mrtg.cfg
แทรกต่อจาก code html ที่เค้าแสดงสาถานะครับเข้าไปดูแล้วจะรู้เองครับว่าควรแทรกแถวไหน ครับ
### Load Average ###
Target[cpu]: .1.3.6.1.4.1.2021.10.1.5.1&.1.3.6.1.4.1.2021.10.1.5.2:public@127.0.0.1
MaxBytes[cpu]: 100
Unscaled[cpu]: dwmy
Options[cpu]: gauge, absolute, growright, noinfo, nopercent
YLegend[cpu]: CPU Load(%)
ShortLegend[cpu]: (%)
LegendI[cpu]: CPU System
LegendO[cpu]: CPU User
Title[cpu]: CPU Analysis
PageTop[cpu]:
### Memory Free ###
Target[mem]: .1.3.6.1.4.1.2021.4.6.0&.1.3.6.1.4.1.2021.4.4.0:public@127.0.0.1
MaxBytes1[mem]: 1030288
MaxBytes2[mem]: 1052216
Unscaled[mem]: dwmy
Options[mem]: gauge, absolute, growright, noinfo
YLegend[mem]: Memory Free
ShortLegend[mem]: Bytes
kilo[mem]: 1024
kMG[mem]: k,M,G,T,P
LegendI[mem]: Real
LegendO[mem]: Swap
Legend1[mem]: (MBytes)
Legend2[mem]: (MBytes)
Title[mem]: Memory Analysis
PageTop[mem]:
#cd /usr/ports/net-mgmt/net-snmp/
#make ; make install clean
#rehash
แก้ไข config ไฟล์ ในที่นี้ผมใช้ editor ee นะครับ ท่านจะใช้ pico ก็ได้
#ee /usr/local/share/snmp/snmpd.conf
พิมพ์ 4 บรรทัดนี้ลงไปครับ ของเดิมหากมี ลบ ให้หมด เอา 4 บรรทัดนี้พอ
rouser public noauth
rocommunity public localhost
syslocation gateway at service room
syscontact webmaster@xxx.com
(2 บรรทัดสุดท้าย แก้ไขตามใจชอบครับ)
แล้ว save ครับ
เรียก snmpd ให้ทำงาน
#snmpd &
ตรวจดูว่ามี process snmpd จริงป่าว....
#ps -ax | grep snmpd
หากอยากให้ snmp ทำงานทุกครั้งก็แก้ไข /etc/rc.conf เพิ่ม สองบรรทัดนี้ลงไป
snmpd_enable="YES"
snmpd_flags="-a -Lsd -p /var/run/snmpd.pid"
2. ติดตั้ง MRTG ผ่าน port
#cd /usr/ports/net-mgmt/mrtg/
#make ; make install clean
#rehash
#cfgmaker public@localhost> /usr/local/etc/mrtg/mrtg.cfg
แก้ไข config
#ee /usr/local/etc/mrtg/mrtg.cfg
WorkDir: /home/webmrtg/public_html
Options[_]:growright,bits
***ผม adduser มา 1 คนชื่อ webmrtg แล้วสร้าง public_html ไว้เพื่อใช้เป็น mrtg เวบครับ
#indexmaker --columns=1 --output=/home/webmrtg/public_html/index.html /usr/local/etc/mrtg/mrtg.cfg
#mrtg /usr/local/etc/mrtg/mrtg.cfg
รันไป 3 ครั้ง ก็จะไม่มี warning ครับ
#ee /etc/crontab
พิมพ์ บรรทัดนี้ ต่อท้ายของเดิม
*/5 * * * * root /usr/local/bin/mrtg /usr/local/etc/mrtg/mrtg.cfg
เพื่อให้กราฟ update ทุก ๆ 5 นาที
ถ้าอยากให้กราฟแสดง cpu และ ram ก็เพิ่ม
code ด้านล่างลงไปในไฟล์ mrtg.cfg
แทรกต่อจาก code html ที่เค้าแสดงสาถานะครับเข้าไปดูแล้วจะรู้เองครับว่าควรแทรกแถวไหน ครับ
### Load Average ###
Target[cpu]: .1.3.6.1.4.1.2021.10.1.5.1&.1.3.6.1.4.1.2021.10.1.5.2:public@127.0.0.1
MaxBytes[cpu]: 100
Unscaled[cpu]: dwmy
Options[cpu]: gauge, absolute, growright, noinfo, nopercent
YLegend[cpu]: CPU Load(%)
ShortLegend[cpu]: (%)
LegendI[cpu]: CPU System
LegendO[cpu]: CPU User
Title[cpu]: CPU Analysis
PageTop[cpu]:
CPU Analysis
### Memory Free ###
Target[mem]: .1.3.6.1.4.1.2021.4.6.0&.1.3.6.1.4.1.2021.4.4.0:public@127.0.0.1
MaxBytes1[mem]: 1030288
MaxBytes2[mem]: 1052216
Unscaled[mem]: dwmy
Options[mem]: gauge, absolute, growright, noinfo
YLegend[mem]: Memory Free
ShortLegend[mem]: Bytes
kilo[mem]: 1024
kMG[mem]: k,M,G,T,P
LegendI[mem]: Real
LegendO[mem]: Swap
Legend1[mem]: (MBytes)
Legend2[mem]: (MBytes)
Title[mem]: Memory Analysis
PageTop[mem]:
Memory Analysis
วันจันทร์ที่ 1 พฤศจิกายน พ.ศ. 2553
cpu 64 bit กับการทำ authen บน freebsd
บทความจากเวบ thaibsd.comโดยครูมานิส
ทำเหมือนเดิมครับ แต่เปลี่ยนมาใช้ FreeBSD8.0-amd64 แทน FreeBSD8.0-i386
ยกเลิกการใช้งาน natd แล้วใช้ PF แทน การปรับค่า Config ประมาณนี้ สรุป คือ ใช้ PF เป็น NAT แต่ Squid ให้ใช้ ipfw เหมือนเดิม
# nano /etc/pf.conf
int_if = "em1"
ext_if = "em0"
chilli_if = "tun0"
tcp_services = "{ 80 , 2000, 9000 , 21 }"
icmp_types = "echoreq"
priv_nets = "{ 10.8.0.0/16, 192.168.2.0/24, 192.168.212.0/24 }"
อธิบาย
int_if ="ชื่อการ์ดแลนวงใน"
ext_if ="ชื่อการ์ดแลนวงนอก"
tcp_services = "{ หมายเลข port ที่ต้องการเปิดใช้งาน }"
priv_nets = "{Class IP ของวงภายในที่อนุญาตให้ใช้งานได้}"
แก้ไขไฟล์ /etc/rc.conf
ยกเลิก natd แล้วใช้ pf แทนดังนี้
#natd_enable="YES"
#natd_interface="LAN ขา WAN"
#natd_flags="-s -u -m"
pf_enable="YES"
pf_rules="/etc/pf.conf"
pf_flags=""
pflog_enable="YES"
pflog_logfile="/var/log/pflog"
pflog_flags=""
บันทึกไฟล์
# reboot
ตอนนี้ผมเอา FreeBSD 5-6 เครื่อง ที่มี FreeBSD ต่าง versionกัน เช่น
FreeBSD 5.4 , 6.1 , 6.2 , 6.3 , 8.0 , 8.1 ที่ติดตั้งต่างกรรมต่างวาระเพื่อให้เป็น server ที่ให้บริการต่างๆ ในเครือข่าย Cloning มาวิ่งบน VMware EXSi 4.0 นิ่งมากครับ....
RAM 8 GB บนเครื่อง host ยังเหลืออีกเยอะเลยครับ... แบ่งให้ FreeBSDไป เครื่องละ 256 , 512 , 1024 MB. แล้วแต่ว่า load มากน้อยครับ...
ทำเหมือนเดิมครับ แต่เปลี่ยนมาใช้ FreeBSD8.0-amd64 แทน FreeBSD8.0-i386
ยกเลิกการใช้งาน natd แล้วใช้ PF แทน การปรับค่า Config ประมาณนี้ สรุป คือ ใช้ PF เป็น NAT แต่ Squid ให้ใช้ ipfw เหมือนเดิม
# nano /etc/pf.conf
int_if = "em1"
ext_if = "em0"
chilli_if = "tun0"
tcp_services = "{ 80 , 2000, 9000 , 21 }"
icmp_types = "echoreq"
priv_nets = "{ 10.8.0.0/16, 192.168.2.0/24, 192.168.212.0/24 }"
อธิบาย
int_if ="ชื่อการ์ดแลนวงใน"
ext_if ="ชื่อการ์ดแลนวงนอก"
tcp_services = "{ หมายเลข port ที่ต้องการเปิดใช้งาน }"
priv_nets = "{Class IP ของวงภายในที่อนุญาตให้ใช้งานได้}"
แก้ไขไฟล์ /etc/rc.conf
ยกเลิก natd แล้วใช้ pf แทนดังนี้
#natd_enable="YES"
#natd_interface="LAN ขา WAN"
#natd_flags="-s -u -m"
pf_enable="YES"
pf_rules="/etc/pf.conf"
pf_flags=""
pflog_enable="YES"
pflog_logfile="/var/log/pflog"
pflog_flags=""
บันทึกไฟล์
# reboot
ตอนนี้ผมเอา FreeBSD 5-6 เครื่อง ที่มี FreeBSD ต่าง versionกัน เช่น
FreeBSD 5.4 , 6.1 , 6.2 , 6.3 , 8.0 , 8.1 ที่ติดตั้งต่างกรรมต่างวาระเพื่อให้เป็น server ที่ให้บริการต่างๆ ในเครือข่าย Cloning มาวิ่งบน VMware EXSi 4.0 นิ่งมากครับ....
RAM 8 GB บนเครื่อง host ยังเหลืออีกเยอะเลยครับ... แบ่งให้ FreeBSDไป เครื่องละ 256 , 512 , 1024 MB. แล้วแต่ว่า load มากน้อยครับ...
วันอาทิตย์ที่ 31 ตุลาคม พ.ศ. 2553
วิธีแก้ไข apahe22 error กรณี libtool
บทความจากเวบ www.kroonis.org
มีเทคนิคมาฝากครับ จะไม่พบกับ Error-code1 อีกเลย สำหรับมือใหม่ เปิดแล้ว 997 | แสดงความคิดเห็น : 1
มีเทคนิคมาฝากครับ จะไม่พบกับ Error-code1 อีกเลย สำหรับมือใหม่
1. Setup FreeBSD รุ่นที่ชอบ ล่าสุดก็ FreeBSD8.0
2. ตรวจสอบเวลาเครื่องก่อน ว่าเป็นปัจจุบันไหม
# date
ถ้าไม่ตรง ตั้งใหม่ date ปีค.ศ.เดือนวันชั่วโมงนาทีวินาที เช่น
# date 201005110915
3. Update Ports ก่อน ทำตามนี้
# cd /usr/ports/lang/perl5.8
# make install clean
# rehash
# cd /usr/ports/net/cvsup/
# make install clean
ระบบถามอะไร ก็เลือก ตอบ Ok ไปเรื่อยครับ
# rehash
# /usr/local/bin/cvsup -g -L 2 -h cvsup5.freebsd.org /usr/share/examples/cvsup/ports-supfile
# cd /usr/ports && make fetchindex
หลังจาก Update Ports เสร็จใหม่ ๆ อย่าเพิ่งติดตั้งโปรแกรมเสริมนะ ให้ใช้คำสั่งด้านล่างก่อน
# cd /usr/ports/devel/libtool22/ && make FORCE_PKG_REGISTER=yes install && make clean
# rehash
Start ตาม STEP ได้เลย
1. Compile Kernel
2. Setup FAMP (Mysql5 + Apache22 + PHP5 / extensions)
3. โปรแกรมอื่น ๆ
จะไม่พบกับคำว่า Error-code1 อีกเลยครับ
ถ่ายทอดจากประสบการณ์ตรง จริง ๆ ครับ คัดลอกบรรทัดต่อบรรทัด
ฝากจากคุณพรหมมาศ แซ่ลั่ว
ช่วยให้การ error ลดลงแต่อาจจะยังมีบ้างครับ แนะนำอีกอย่างว่าควรทำการ update ports tree ด้วย โดยใช้คำสั่งต่อไปนี้ในครั้งแรก
# portsnap fetch extract update
และในการ update ครั้งต่อ ๆ ไปใช้คำสั่งนี้ครับ
# portsnap fetch update
มีเทคนิคมาฝากครับ จะไม่พบกับ Error-code1 อีกเลย สำหรับมือใหม่ เปิดแล้ว 997 | แสดงความคิดเห็น : 1
มีเทคนิคมาฝากครับ จะไม่พบกับ Error-code1 อีกเลย สำหรับมือใหม่
1. Setup FreeBSD รุ่นที่ชอบ ล่าสุดก็ FreeBSD8.0
2. ตรวจสอบเวลาเครื่องก่อน ว่าเป็นปัจจุบันไหม
# date
ถ้าไม่ตรง ตั้งใหม่ date ปีค.ศ.เดือนวันชั่วโมงนาทีวินาที เช่น
# date 201005110915
3. Update Ports ก่อน ทำตามนี้
# cd /usr/ports/lang/perl5.8
# make install clean
# rehash
# cd /usr/ports/net/cvsup/
# make install clean
ระบบถามอะไร ก็เลือก ตอบ Ok ไปเรื่อยครับ
# rehash
# /usr/local/bin/cvsup -g -L 2 -h cvsup5.freebsd.org /usr/share/examples/cvsup/ports-supfile
# cd /usr/ports && make fetchindex
หลังจาก Update Ports เสร็จใหม่ ๆ อย่าเพิ่งติดตั้งโปรแกรมเสริมนะ ให้ใช้คำสั่งด้านล่างก่อน
# cd /usr/ports/devel/libtool22/ && make FORCE_PKG_REGISTER=yes install && make clean
# rehash
Start ตาม STEP ได้เลย
1. Compile Kernel
2. Setup FAMP (Mysql5 + Apache22 + PHP5 / extensions)
3. โปรแกรมอื่น ๆ
จะไม่พบกับคำว่า Error-code1 อีกเลยครับ
ถ่ายทอดจากประสบการณ์ตรง จริง ๆ ครับ คัดลอกบรรทัดต่อบรรทัด
ฝากจากคุณพรหมมาศ แซ่ลั่ว
ช่วยให้การ error ลดลงแต่อาจจะยังมีบ้างครับ แนะนำอีกอย่างว่าควรทำการ update ports tree ด้วย โดยใช้คำสั่งต่อไปนี้ในครั้งแรก
# portsnap fetch extract update
และในการ update ครั้งต่อ ๆ ไปใช้คำสั่งนี้ครับ
# portsnap fetch update
วันเสาร์ที่ 9 ตุลาคม พ.ศ. 2553
การติดตั้ง dhcpd บน freebsd
การติดตั้ง DHCP บน FreeBSD 7.0 บทความโดย dekdar แห่ง www.thaibsd.com
1. เริ่มจากค้นหา พอร์ตของ dhcp
freebsd# cd /usr/ports/
2. ค้นหาพอร์ตของ dhcp
freebsd# make search name=dhcpd
Port: isc-dhcp3-server-3.0.5_2
Path: /usr/ports/net/isc-dhcp3-server
3. เข้าไดเรกทรอรี่ dhcp เพื่อทำการติดตั้งโปรแกรม
freebsd# cd /usr/ports/net/isc-dhcp3-server
4. เลือกออพชั่น การติดตั้งโปรแกรม
freebsd# make config
Options for isc-dhcp3-server 3.0.5_2
[X] DHCP_PARANOIA add -user, -group and -chroot options
[ ] DHCP_JAIL add -chroot and -jail options
[ ] DHCP_SOCKETS use sockets instead of /dev/bpf (jail-only)
[ ] DHCP_LDAP add experimental LDAP backend support
[X] DHCP_LDAP_SSL support LDAP connection over SSL/TLS
[X] OPENSSL_BASE use the base system OpenSSL (required by TLS)
[ ] OPENSSL_PORT use OpenSSL from ports (required by TLS)
[ ] DHCP_LQ DHCPLEASEQUERY support used by Cisco uBR's
[ OK ] Cancel
5. ทำการติดตั้งโปรแกรม
freebsd# make
freebsd# make install
6. สร้างไฟล์คอนฟิก dhcpd.conf
freebsd# cp /usr/local/etc/dhcpd.conf.sample /usr/local/etc/dhcpd.conf.sample
หรือ
freebsd# touch /usr/local/etc/dhcpd.conf
7. กำหนดค่าคอนฟิกไฟล์
freebsd# pico /usr/local/etc/dhcpd.conf
ddns-update-style ad-hoc;
option domain-name "yiu.edu";
option domain-name-servers 118.175.87.11, 203.113.24.199;
default-lease-time 6000;
max-lease-time 72000;
subnet 118.175.87.8 netmask 255.255.255.248 {
}
# This is a very basic subnet declaration.
subnet 172.30.2.0 netmask 255.255.255.0
{ range 172.30.2.20 172.30.2.250;
option routers 172.30.2.1;
option broadcast-address 172.30.2.255;
}
host server_controll {
hardware ethernet 00:04:e2:80:f7:f0;
fixed-address 172.30.2.254;
} //เป็นการกำหนดค่า แจกไอพี แบบกำหนด
8. สร้างไฟล์จัดเก็บรายละเอียดไอพี ปกติมีมาให้เรียบร้อยแล้วครับ หากไม่มีก็ให้ทำ
freebsd# touch /var/db/dhcpd.leases
freebsd# chmod 777 /var/db/dhcpd.leases
9. ทดสอบการให้บริการ DHCP
//แจกทางการ์ดทุกใบที่เชื่อมต่อ เราสามารถกำหนดเฉพาะการ์ด Network ที่ต้องการได้
freebsd# /usr/local/sbin/dhcpd &
[1] 22810
freebsd# Internet Systems Consortium DHCP Server V3.0.5
Copyright 2004-2006 Internet Systems Consortium.All rights reserved.
For info, please visithttp://www.isc.org/sw/dhcp/
Wrote 0 deleted host decls to leases file.
Wrote 0 new dynamic host decls to leases file.
Wrote 32 leases to leases file.
Listening on BPF/vr0/00:13:d3:11:5c:98/118.175.87.8/29
Sending on BPF/vr0/00:13:d3:11:5c:98/118.175.87.8/29
Listening on BPF/rl0/00:e0:4c:5a:5f:0a/172.30.2/24
Sending on BPF/rl0/00:e0:4c:5a:5f:0a/172.30.2/24
Sending on Socket/fallback/fallback-net
[1] Done /usr/local/sbin/dhcpd
10. ตรวจสอบโปรเซส dhcpd
freebsd# ps ax | grep dhcpd
22811 ?? Is 0:00.00 /usr/local/sbin/dhcpd
11. เพิ่มคำสั่งใน /etc/rc.local
freebsd# echo ‘/usr/local/sbin/dhcpd rl0 &’ >> /etc/rc.local //กรณีที่ต้องการแจกทางการ์ด rl0 เท่านั้น
12. เพิ่มคำสั่งใน /etc/rc.conf
freebsd# echo ‘dhcpd_enable="YES"’ >> /etc/rc.conf
สามารถให้งานบริการ DHCP แล้วละครับ ลง reboot เครื่องสักรอบก็ได้ครับ
freebsd# shutdown –r now
ตัวอย่าง ไฟล์ข้อมูลที่แจกไอพีให้แก่เครื่องลูกข่าย จาก /var/db/dhcpd.leases
freebsd# cat /var/db/dhcpd.leases
lease 172.30.2.247 {
starts 5 2008/07/11 15:52:07;
ends 5 2008/07/11 17:32:07;
binding state active;
next binding state free;
hardware ethernet 00:15:af:8b:83:20;
uid "\001\000\025\257\213\203 ";
client-hostname "codename";
}
ตัวอย่าง การคอนฟิกพาธใน เว็ปมิน
System configuration
DHCP server config file /usr/local/etc/dhcpd.conf
DHCP server executable /usr/local/sbin/dhcpd
Path to DHCP server PID file /var/run/dhcpd.pid
DHCP server lease file /var/db/dhcpd.leases
***แนะนำ เมื่อทำถึงขั้นตอนที่ 5 แล้ว ปกติดสามารถทำผ่าน เว็ปมิน
ได้เลยครับ และง่ายกว่าที่ต้องมาพิมพ์และคอนฟิกเอง มีเครื่องมือ
อำนวยความสะดวกก็ใช้ดีกว่าครับ หากจะพิมพ์เองก็ไม่ว่าอะไร (แต่
มันช้า และโอกาสผิดพลาดมีสูงครับ หุหุหุ++)
Detail Test : Install DHCP3 on FreeBSD 7.0
OS : FreeBSD7.0 After Update Ports
Software : Install Ports Program
Apache apache-2.2.9
MySQL mysql-server-5.1.25
PHP php5-5.2.6
Test by dekdard @ gmail.com
ใช้ FreeBSD 7 เป็น DHCP Server ใช้งานได้ปกติ แต่มีข้อความที่ Server ตลอดเมื่อเครื่องลูกข่ายขอหรือ dhcp หมดเวลา ทั้งที่สร้าง /var/db/dhcpd.leases และ chmod 777 แล้ว แก้ไขไงครับ ขอบคุณครับ
แก้ไข dhcpd.conf บรรทัดนี้ครับ
ddns-update-style แก้ไขเป็น ddns-update-style none;
อย่าลืม restart dhcpd ด้วยนะครับ
1. เริ่มจากค้นหา พอร์ตของ dhcp
freebsd# cd /usr/ports/
2. ค้นหาพอร์ตของ dhcp
freebsd# make search name=dhcpd
Port: isc-dhcp3-server-3.0.5_2
Path: /usr/ports/net/isc-dhcp3-server
3. เข้าไดเรกทรอรี่ dhcp เพื่อทำการติดตั้งโปรแกรม
freebsd# cd /usr/ports/net/isc-dhcp3-server
4. เลือกออพชั่น การติดตั้งโปรแกรม
freebsd# make config
Options for isc-dhcp3-server 3.0.5_2
[X] DHCP_PARANOIA add -user, -group and -chroot options
[ ] DHCP_JAIL add -chroot and -jail options
[ ] DHCP_SOCKETS use sockets instead of /dev/bpf (jail-only)
[ ] DHCP_LDAP add experimental LDAP backend support
[X] DHCP_LDAP_SSL support LDAP connection over SSL/TLS
[X] OPENSSL_BASE use the base system OpenSSL (required by TLS)
[ ] OPENSSL_PORT use OpenSSL from ports (required by TLS)
[ ] DHCP_LQ DHCPLEASEQUERY support used by Cisco uBR's
[ OK ] Cancel
5. ทำการติดตั้งโปรแกรม
freebsd# make
freebsd# make install
6. สร้างไฟล์คอนฟิก dhcpd.conf
freebsd# cp /usr/local/etc/dhcpd.conf.sample /usr/local/etc/dhcpd.conf.sample
หรือ
freebsd# touch /usr/local/etc/dhcpd.conf
7. กำหนดค่าคอนฟิกไฟล์
freebsd# pico /usr/local/etc/dhcpd.conf
ddns-update-style ad-hoc;
option domain-name "yiu.edu";
option domain-name-servers 118.175.87.11, 203.113.24.199;
default-lease-time 6000;
max-lease-time 72000;
subnet 118.175.87.8 netmask 255.255.255.248 {
}
# This is a very basic subnet declaration.
subnet 172.30.2.0 netmask 255.255.255.0
{ range 172.30.2.20 172.30.2.250;
option routers 172.30.2.1;
option broadcast-address 172.30.2.255;
}
host server_controll {
hardware ethernet 00:04:e2:80:f7:f0;
fixed-address 172.30.2.254;
} //เป็นการกำหนดค่า แจกไอพี แบบกำหนด
8. สร้างไฟล์จัดเก็บรายละเอียดไอพี ปกติมีมาให้เรียบร้อยแล้วครับ หากไม่มีก็ให้ทำ
freebsd# touch /var/db/dhcpd.leases
freebsd# chmod 777 /var/db/dhcpd.leases
9. ทดสอบการให้บริการ DHCP
//แจกทางการ์ดทุกใบที่เชื่อมต่อ เราสามารถกำหนดเฉพาะการ์ด Network ที่ต้องการได้
freebsd# /usr/local/sbin/dhcpd &
[1] 22810
freebsd# Internet Systems Consortium DHCP Server V3.0.5
Copyright 2004-2006 Internet Systems Consortium.All rights reserved.
For info, please visithttp://www.isc.org/sw/dhcp/
Wrote 0 deleted host decls to leases file.
Wrote 0 new dynamic host decls to leases file.
Wrote 32 leases to leases file.
Listening on BPF/vr0/00:13:d3:11:5c:98/118.175.87.8/29
Sending on BPF/vr0/00:13:d3:11:5c:98/118.175.87.8/29
Listening on BPF/rl0/00:e0:4c:5a:5f:0a/172.30.2/24
Sending on BPF/rl0/00:e0:4c:5a:5f:0a/172.30.2/24
Sending on Socket/fallback/fallback-net
[1] Done /usr/local/sbin/dhcpd
10. ตรวจสอบโปรเซส dhcpd
freebsd# ps ax | grep dhcpd
22811 ?? Is 0:00.00 /usr/local/sbin/dhcpd
11. เพิ่มคำสั่งใน /etc/rc.local
freebsd# echo ‘/usr/local/sbin/dhcpd rl0 &’ >> /etc/rc.local //กรณีที่ต้องการแจกทางการ์ด rl0 เท่านั้น
12. เพิ่มคำสั่งใน /etc/rc.conf
freebsd# echo ‘dhcpd_enable="YES"’ >> /etc/rc.conf
สามารถให้งานบริการ DHCP แล้วละครับ ลง reboot เครื่องสักรอบก็ได้ครับ
freebsd# shutdown –r now
ตัวอย่าง ไฟล์ข้อมูลที่แจกไอพีให้แก่เครื่องลูกข่าย จาก /var/db/dhcpd.leases
freebsd# cat /var/db/dhcpd.leases
lease 172.30.2.247 {
starts 5 2008/07/11 15:52:07;
ends 5 2008/07/11 17:32:07;
binding state active;
next binding state free;
hardware ethernet 00:15:af:8b:83:20;
uid "\001\000\025\257\213\203 ";
client-hostname "codename";
}
ตัวอย่าง การคอนฟิกพาธใน เว็ปมิน
System configuration
DHCP server config file /usr/local/etc/dhcpd.conf
DHCP server executable /usr/local/sbin/dhcpd
Path to DHCP server PID file /var/run/dhcpd.pid
DHCP server lease file /var/db/dhcpd.leases
***แนะนำ เมื่อทำถึงขั้นตอนที่ 5 แล้ว ปกติดสามารถทำผ่าน เว็ปมิน
ได้เลยครับ และง่ายกว่าที่ต้องมาพิมพ์และคอนฟิกเอง มีเครื่องมือ
อำนวยความสะดวกก็ใช้ดีกว่าครับ หากจะพิมพ์เองก็ไม่ว่าอะไร (แต่
มันช้า และโอกาสผิดพลาดมีสูงครับ หุหุหุ++)
Detail Test : Install DHCP3 on FreeBSD 7.0
OS : FreeBSD7.0 After Update Ports
Software : Install Ports Program
Apache apache-2.2.9
MySQL mysql-server-5.1.25
PHP php5-5.2.6
Test by dekdard @ gmail.com
ใช้ FreeBSD 7 เป็น DHCP Server ใช้งานได้ปกติ แต่มีข้อความที่ Server ตลอดเมื่อเครื่องลูกข่ายขอหรือ dhcp หมดเวลา ทั้งที่สร้าง /var/db/dhcpd.leases และ chmod 777 แล้ว แก้ไขไงครับ ขอบคุณครับ
แก้ไข dhcpd.conf บรรทัดนี้ครับ
ddns-update-style แก้ไขเป็น ddns-update-style none;
อย่าลืม restart dhcpd ด้วยนะครับ
วันเสาร์ที่ 18 กันยายน พ.ศ. 2553
update ports tree บน freebsd
บทความ จาก thaibsd.com xdisc
ไหนๆจะอัพเดทล่ะก็เอาให้หมดทีเดียวไปเลยครับใช้เวลาไม่นานหรอก แพคเกจบางตัวก็จำเป็นใช้งานร่วมกัน ถ้าตัวใดตัวหนึ่งเก่าเกินไปเวลาติดตั้งอาจมีปัญหาได้
การทำ cvsup เพื่อปรับปรุง ports(ส่วนที่ใช้ในการติดตั้งโปรแกรมอัตโนมัติผ่านอินเตอร์เน็ต)
cvsup จะใช้เพื่อทำการปรับปรุง ports ต่างๆ ของเราให้ทันสมัย เพราะบาง package จำเป็นต้องปรับปรุงให้เป็นเวอร์ชั่นใหม่
ติดตั้ง cvsup ก่อน
# cd /usr/ports/net/cvsup-without-gui
# make install && make clean
# rehash
หรือ
# pkg_add -r cvsup-without-gui
# rehash
ทำการ synchronize ports index กับ cvsup server
# /usr/local/bin/cvsup -g -L 2 -h cvsup.freebsd.org /usr/share/examples/cvsup/ports-supfile
รอจนกว่าจะติดตั้งเสร็จ
# cd /usr/ports && make fetchindex
จากนั้นก็จะทำให้เราได้โปรแกรมใน /usr/ports เป็นตัวใหม่ล่าสุดแล้ว
อันนี้ของ ครูมานิส..น่าสนใจ..
.................................
1. Setup FreeBSD รุ่นที่ชอบ ล่าสุดก็ FreeBSD8.0
2. ตรวจสอบเวลาเครื่องก่อน ว่าเป็นปัจจุบันไหม
# date
ถ้าไม่ตรง ตั้งใหม่ date ปีค.ศ.เดือนวันชั่วโมงนาทีวินาที เช่น
# date 201005110915
3. Update Ports ก่อน ทำตามนี้
# cd /usr/ports/lang/perl5.8
# make install clean
# rehash
# cd /usr/ports/net/cvsup/
# make install clean
ระบบถามอะไร ก็เลือก ตอบ Ok ไปเรื่อยครับ
# rehash
# /usr/local/bin/cvsup -g -L 2 -h cvsup5.freebsd.org /usr/share/examples/cvsup/ports-supfile
# cd /usr/ports && make fetchindex
หลังจาก Update Ports เสร็จใหม่ ๆ อย่าเพิ่งติดตั้งโปรแกรมเสริมนะ ให้ใช้คำสั่งด้านล่างก่อน
# cd /usr/ports/devel/libtool22/ && make FORCE_PKG_REGISTER=yes install && make clean
# rehash
Start ตาม STEP ได้เลย
1. Compile Kernel
2. Setup FAMP (Mysql5 + Apache22 + PHP5 / extensions)
3. โปรแกรมอื่น ๆ
จะไม่พบกับคำว่า Error-code1 อีกเลยครับ
ถ่ายทอดจากประสบการณ์ตรง จริง ๆ ครับ คัดลอกบรรทัดต่อบรรทัด
ไหนๆจะอัพเดทล่ะก็เอาให้หมดทีเดียวไปเลยครับใช้เวลาไม่นานหรอก แพคเกจบางตัวก็จำเป็นใช้งานร่วมกัน ถ้าตัวใดตัวหนึ่งเก่าเกินไปเวลาติดตั้งอาจมีปัญหาได้
การทำ cvsup เพื่อปรับปรุง ports(ส่วนที่ใช้ในการติดตั้งโปรแกรมอัตโนมัติผ่านอินเตอร์เน็ต)
cvsup จะใช้เพื่อทำการปรับปรุง ports ต่างๆ ของเราให้ทันสมัย เพราะบาง package จำเป็นต้องปรับปรุงให้เป็นเวอร์ชั่นใหม่
ติดตั้ง cvsup ก่อน
# cd /usr/ports/net/cvsup-without-gui
# make install && make clean
# rehash
หรือ
# pkg_add -r cvsup-without-gui
# rehash
ทำการ synchronize ports index กับ cvsup server
# /usr/local/bin/cvsup -g -L 2 -h cvsup.freebsd.org /usr/share/examples/cvsup/ports-supfile
รอจนกว่าจะติดตั้งเสร็จ
# cd /usr/ports && make fetchindex
จากนั้นก็จะทำให้เราได้โปรแกรมใน /usr/ports เป็นตัวใหม่ล่าสุดแล้ว
อันนี้ของ ครูมานิส..น่าสนใจ..
.................................
1. Setup FreeBSD รุ่นที่ชอบ ล่าสุดก็ FreeBSD8.0
2. ตรวจสอบเวลาเครื่องก่อน ว่าเป็นปัจจุบันไหม
# date
ถ้าไม่ตรง ตั้งใหม่ date ปีค.ศ.เดือนวันชั่วโมงนาทีวินาที เช่น
# date 201005110915
3. Update Ports ก่อน ทำตามนี้
# cd /usr/ports/lang/perl5.8
# make install clean
# rehash
# cd /usr/ports/net/cvsup/
# make install clean
ระบบถามอะไร ก็เลือก ตอบ Ok ไปเรื่อยครับ
# rehash
# /usr/local/bin/cvsup -g -L 2 -h cvsup5.freebsd.org /usr/share/examples/cvsup/ports-supfile
# cd /usr/ports && make fetchindex
หลังจาก Update Ports เสร็จใหม่ ๆ อย่าเพิ่งติดตั้งโปรแกรมเสริมนะ ให้ใช้คำสั่งด้านล่างก่อน
# cd /usr/ports/devel/libtool22/ && make FORCE_PKG_REGISTER=yes install && make clean
# rehash
Start ตาม STEP ได้เลย
1. Compile Kernel
2. Setup FAMP (Mysql5 + Apache22 + PHP5 / extensions)
3. โปรแกรมอื่น ๆ
จะไม่พบกับคำว่า Error-code1 อีกเลยครับ
ถ่ายทอดจากประสบการณ์ตรง จริง ๆ ครับ คัดลอกบรรทัดต่อบรรทัด
วันจันทร์ที่ 13 กันยายน พ.ศ. 2553
clear squid อัตโนมัติ...
สร้างไฟล์ /usr/local/sbin/clear-squid-cache.sh
#!/bin/sh
#clear squid cache script
/usr/local/etc/rc.d/squid stop
/bin/sleep 10
rm -rf /var/cache/*
/bin/sleep 10
/usr/local/sbin/squid -z
/bin/sleep 10
/usr/local/etc/rc.d/squid start
กำหนดโหมดไฟล์
# chmod 755 /usr/local/sbin/clear-squid-cache.sh
การกำหนดเวลาการทำ log rotate แก้ไขไฟล์ /etc/crontab
0 0 * * * root /usr/local/sbin/squid -k rotate -f /usr/local/etc/squid/squid.conf
0 0 * * 0 root /usr/local/sbin/clear-squid-cache.sh
คำสั่งแรกจะทำการ rotate logfile ของ squid ทุกวัน
คำสั่งที่สองจะทำการเคลียร์ cache ของ squid ทุกสัปดาห์
ขอบคุณ คุณพรหมมาศ
#!/bin/sh
#clear squid cache script
/usr/local/etc/rc.d/squid stop
/bin/sleep 10
rm -rf /var/cache/*
/bin/sleep 10
/usr/local/sbin/squid -z
/bin/sleep 10
/usr/local/etc/rc.d/squid start
กำหนดโหมดไฟล์
# chmod 755 /usr/local/sbin/clear-squid-cache.sh
การกำหนดเวลาการทำ log rotate แก้ไขไฟล์ /etc/crontab
0 0 * * * root /usr/local/sbin/squid -k rotate -f /usr/local/etc/squid/squid.conf
0 0 * * 0 root /usr/local/sbin/clear-squid-cache.sh
คำสั่งแรกจะทำการ rotate logfile ของ squid ทุกวัน
คำสั่งที่สองจะทำการเคลียร์ cache ของ squid ทุกสัปดาห์
ขอบคุณ คุณพรหมมาศ
วันพุธที่ 14 กรกฎาคม พ.ศ. 2553
tip ป้องกัน Ultrasurf
ป้องกัน Ultrasurf tips จาก yim แห่งthaibsd
สำหรับ freebsd ใช้ route add -net 65.49.2.0/24 10.00.2
สำหรับ linux ใช้ route add -net 65.49.2.0/24 gw 127.0.0.1
ของท่าน chet แห่ง linuxthai
ไฟล์วอลผมครับ
#!/bin/sh
#
# Firewall script for ChilliSpot
# A Wireless LAN Access Point Controller
#
# Uses $EXTIF (eth0) as the external interface (Internet or intranet) and
# $INTIF (eth1) as the internal interface (access points).
#
#
# SUMMARY
# * All connections originating from chilli are allowed.
# * Only ssh is allowed in on external interface.
# * Nothing is allowed in on internal interface.
# * Forwarding is allowed to and from the external interface, but disallowed
# to and from the internal interface.
# * NAT is enabled on the external interface.
IPTABLES="/sbin/iptables"
EXTIF="eth0"
INTIF="eth1"
#Flush all rules
$IPTABLES -F
$IPTABLES -F -t nat
$IPTABLES -F -t mangle
#Set default behaviour
$IPTABLES -P INPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT
$IPTABLES -P OUTPUT ACCEPT
#Block Ultrasurf
iptables -A FORWARD -p tcp --dport 9666 -j DROP
iptables -A FORWARD -p udp --dport 9666 -j DROP
$IPTABLES -A INPUT -s 67.15.183.30 -j DROP
$IPTABLES -A FORWARD -s 67.15.183.30 -j DROP
$IPTABLES -A OUTPUT -s 67.15.183.30 -j DROP
$IPTABLES -A INPUT -p tcp -m tcp --dport 9666 -j DROP
$IPTABLES -A FORWARD -p tcp -m tcp --dport 9666 -j DROP
$IPTABLES -A OUTPUT -p tcp -m tcp --dport 9666 -j DROP
#iptables -A FORWARD -p tcp --dport 443 -j DROP_CUSTOM
#iptables -A FORWARD -p udp --dport 443 -j DROP_CUSTOM
IPALLOW=`cat /root/special.txt | awk '{print $1}'`
iptables -N DROP_CUSTOM
for ipall in $IPALLOW
do
iptables -A DROP_CUSTOM -s $ipall -j ACCEPT
iptables -A DROP_CUSTOM -d $ipall -j ACCEPT
done
iptables -A DROP_CUSTOM -j DROP
# เจอคำพวกนี้ผ่านตา อย่าให้เล็ดลอด
iptables -A FORWARD -m string --string "info_hash" --algo bm --to 65535 -j DROP
iptables -A FORWARD -m string --string ".torrent" --algo bm --to 65535 -j DROP
iptables -A FORWARD -m string --string "get_peers" --algo bm --to 65535 -j DROP
iptables -A FORWARD -m string --string "announce_peers" --algo bm --to 65535 -j DROP
#Allow related and established on all interfaces (input)
$IPTABLES -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
#Allow releated, established and ssh on $EXTIF. Reject everything else.
$IPTABLES -A INPUT -i $EXTIF -p tcp -m tcp --dport 22 --syn -j ACCEPT
$IPTABLES -A INPUT -i $EXTIF -j REJECT
#Allow related and established from $INTIF. Drop everything else.
$IPTABLES -A INPUT -i $INTIF -j DROP
#Allow http and https on other interfaces (input).
#This is only needed if authentication server is on same server as chilli
$IPTABLES -A INPUT -p tcp -m tcp --dport 80 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 443 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 22 --syn -j ACCEPT
#Allow 3990 on other interfaces (input).
$IPTABLES -A INPUT -p tcp -m tcp --dport 3990 --syn -j ACCEPT
#Allow ICMP echo on other interfaces (input).
$IPTABLES -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
#Allow everything on loopback interface.
$IPTABLES -A INPUT -i lo -j ACCEPT
# Drop everything to and from $INTIF (forward)
# This means that access points can only be managed from ChilliSpot
$IPTABLES -A FORWARD -i $INTIF -j DROP
$IPTABLES -A FORWARD -o $INTIF -j DROP
##### chalee edit
#Allow releated, established and ssh on $EXTIF. Reject everything else.
$IPTABLES -A INPUT -i $EXTIF -p tcp -m tcp --dport 22 --syn -j ACCEPT
$IPTABLES -A INPUT -i $EXTIF -p tcp -m tcp --dport 80 --syn -j ACCEPT
$IPTABLES -A INPUT -i $EXTIF -p tcp -m tcp --dport 10000 --syn -j ACCEPT
#Allow 3990 on other interfaces (input).
$IPTABLES -A INPUT -p tcp -m tcp --dport 3990 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 3128 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 3306 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 22 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 10000 --syn -j ACCEPT
#Enable NAT on output device
$IPTABLES -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE
##Allow transparent proxy ##
$IPTABLES -A INPUT -p tcp -m tcp --dport 8080 --syn -j ACCEPT
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp --dport 8080 --syn -j DROP
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp -d 192.168.0.0/16 --dport 80 -j RETURN
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp -d 172.16.0.0/12 --dport 80 -j RETURN
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp -d 10.0.0.0/8 --dport 80 -j RETURN
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
# Drop package wrom Virus Input, Output
$IPTABLES -A INPUT -p tcp --dport 135 -j DROP
$IPTABLES -A INPUT -p udp --dport 135 -j DROP
$IPTABLES -A INPUT -p tcp --dport 445 -j DROP
$IPTABLES -A INPUT -p udp --dport 445 -j DROP
$IPTABLES -A INPUT -p tcp --dport 4444 -j DROP
$IPTABLES -A INPUT -p udp --dport 4444 -j DROP
$IPTABLES -A INPUT -p tcp --dport 5554 -j DROP
$IPTABLES -A INPUT -p udp --dport 5554 -j DROP
$IPTABLES -A INPUT -p tcp --dport 9996 -j DROP
$IPTABLES -A INPUT -p udp --dport 9996 -j DROP
$IPTABLES -A INPUT -p tcp --dport 137 -j DROP
$IPTABLES -A INPUT -p udp --dport 137 -j DROP
$IPTABLES -A INPUT -p tcp --dport 138 -j DROP
$IPTABLES -A INPUT -p udp --dport 138 -j DROP
$IPTABLES -A INPUT -p tcp --dport 139 -j DROP
$IPTABLES -A INPUT -p udp --dport 139 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 135 -j DROP
$IPTABLES -A OUTPUT -p udp --dport 135 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 445 -j DROP
$IPTABLES -A OUTPUT -p udp --dport 445 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 4444 -j DROP
$IPTABLES -A OUTPUT -p udp --dport 4444 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 5554 -j DROP
$IPTABLES -A OUTPUT -p udp --dport 5554 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 9996 -j DROP
$IPTABLES -A OUTPUT -p udp --dport 9996 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 137 -j DROP
$IPTABLES -A OUTPUT -p udp --dport 137 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 138 -j DROP
$IPTABLES -A OUTPUT -p udp --dport 138 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 139 -j DROP
ส่วนไอพีที่ผมใส่ไปมีแค่นี้ครับ
217.12.8.76
64.4.20.169
97.74.144.165
สำหรับ freebsd ใช้ route add -net 65.49.2.0/24 10.00.2
สำหรับ linux ใช้ route add -net 65.49.2.0/24 gw 127.0.0.1
ของท่าน chet แห่ง linuxthai
ไฟล์วอลผมครับ
#!/bin/sh
#
# Firewall script for ChilliSpot
# A Wireless LAN Access Point Controller
#
# Uses $EXTIF (eth0) as the external interface (Internet or intranet) and
# $INTIF (eth1) as the internal interface (access points).
#
#
# SUMMARY
# * All connections originating from chilli are allowed.
# * Only ssh is allowed in on external interface.
# * Nothing is allowed in on internal interface.
# * Forwarding is allowed to and from the external interface, but disallowed
# to and from the internal interface.
# * NAT is enabled on the external interface.
IPTABLES="/sbin/iptables"
EXTIF="eth0"
INTIF="eth1"
#Flush all rules
$IPTABLES -F
$IPTABLES -F -t nat
$IPTABLES -F -t mangle
#Set default behaviour
$IPTABLES -P INPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT
$IPTABLES -P OUTPUT ACCEPT
#Block Ultrasurf
iptables -A FORWARD -p tcp --dport 9666 -j DROP
iptables -A FORWARD -p udp --dport 9666 -j DROP
$IPTABLES -A INPUT -s 67.15.183.30 -j DROP
$IPTABLES -A FORWARD -s 67.15.183.30 -j DROP
$IPTABLES -A OUTPUT -s 67.15.183.30 -j DROP
$IPTABLES -A INPUT -p tcp -m tcp --dport 9666 -j DROP
$IPTABLES -A FORWARD -p tcp -m tcp --dport 9666 -j DROP
$IPTABLES -A OUTPUT -p tcp -m tcp --dport 9666 -j DROP
#iptables -A FORWARD -p tcp --dport 443 -j DROP_CUSTOM
#iptables -A FORWARD -p udp --dport 443 -j DROP_CUSTOM
IPALLOW=`cat /root/special.txt | awk '{print $1}'`
iptables -N DROP_CUSTOM
for ipall in $IPALLOW
do
iptables -A DROP_CUSTOM -s $ipall -j ACCEPT
iptables -A DROP_CUSTOM -d $ipall -j ACCEPT
done
iptables -A DROP_CUSTOM -j DROP
# เจอคำพวกนี้ผ่านตา อย่าให้เล็ดลอด
iptables -A FORWARD -m string --string "info_hash" --algo bm --to 65535 -j DROP
iptables -A FORWARD -m string --string ".torrent" --algo bm --to 65535 -j DROP
iptables -A FORWARD -m string --string "get_peers" --algo bm --to 65535 -j DROP
iptables -A FORWARD -m string --string "announce_peers" --algo bm --to 65535 -j DROP
#Allow related and established on all interfaces (input)
$IPTABLES -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
#Allow releated, established and ssh on $EXTIF. Reject everything else.
$IPTABLES -A INPUT -i $EXTIF -p tcp -m tcp --dport 22 --syn -j ACCEPT
$IPTABLES -A INPUT -i $EXTIF -j REJECT
#Allow related and established from $INTIF. Drop everything else.
$IPTABLES -A INPUT -i $INTIF -j DROP
#Allow http and https on other interfaces (input).
#This is only needed if authentication server is on same server as chilli
$IPTABLES -A INPUT -p tcp -m tcp --dport 80 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 443 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 22 --syn -j ACCEPT
#Allow 3990 on other interfaces (input).
$IPTABLES -A INPUT -p tcp -m tcp --dport 3990 --syn -j ACCEPT
#Allow ICMP echo on other interfaces (input).
$IPTABLES -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
#Allow everything on loopback interface.
$IPTABLES -A INPUT -i lo -j ACCEPT
# Drop everything to and from $INTIF (forward)
# This means that access points can only be managed from ChilliSpot
$IPTABLES -A FORWARD -i $INTIF -j DROP
$IPTABLES -A FORWARD -o $INTIF -j DROP
##### chalee edit
#Allow releated, established and ssh on $EXTIF. Reject everything else.
$IPTABLES -A INPUT -i $EXTIF -p tcp -m tcp --dport 22 --syn -j ACCEPT
$IPTABLES -A INPUT -i $EXTIF -p tcp -m tcp --dport 80 --syn -j ACCEPT
$IPTABLES -A INPUT -i $EXTIF -p tcp -m tcp --dport 10000 --syn -j ACCEPT
#Allow 3990 on other interfaces (input).
$IPTABLES -A INPUT -p tcp -m tcp --dport 3990 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 3128 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 3306 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 22 --syn -j ACCEPT
$IPTABLES -A INPUT -p tcp -m tcp --dport 10000 --syn -j ACCEPT
#Enable NAT on output device
$IPTABLES -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE
##Allow transparent proxy ##
$IPTABLES -A INPUT -p tcp -m tcp --dport 8080 --syn -j ACCEPT
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp --dport 8080 --syn -j DROP
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp -d 192.168.0.0/16 --dport 80 -j RETURN
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp -d 172.16.0.0/12 --dport 80 -j RETURN
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp -d 10.0.0.0/8 --dport 80 -j RETURN
$IPTABLES -t nat -A PREROUTING -i tun0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
# Drop package wrom Virus Input, Output
$IPTABLES -A INPUT -p tcp --dport 135 -j DROP
$IPTABLES -A INPUT -p udp --dport 135 -j DROP
$IPTABLES -A INPUT -p tcp --dport 445 -j DROP
$IPTABLES -A INPUT -p udp --dport 445 -j DROP
$IPTABLES -A INPUT -p tcp --dport 4444 -j DROP
$IPTABLES -A INPUT -p udp --dport 4444 -j DROP
$IPTABLES -A INPUT -p tcp --dport 5554 -j DROP
$IPTABLES -A INPUT -p udp --dport 5554 -j DROP
$IPTABLES -A INPUT -p tcp --dport 9996 -j DROP
$IPTABLES -A INPUT -p udp --dport 9996 -j DROP
$IPTABLES -A INPUT -p tcp --dport 137 -j DROP
$IPTABLES -A INPUT -p udp --dport 137 -j DROP
$IPTABLES -A INPUT -p tcp --dport 138 -j DROP
$IPTABLES -A INPUT -p udp --dport 138 -j DROP
$IPTABLES -A INPUT -p tcp --dport 139 -j DROP
$IPTABLES -A INPUT -p udp --dport 139 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 135 -j DROP
$IPTABLES -A OUTPUT -p udp --dport 135 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 445 -j DROP
$IPTABLES -A OUTPUT -p udp --dport 445 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 4444 -j DROP
$IPTABLES -A OUTPUT -p udp --dport 4444 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 5554 -j DROP
$IPTABLES -A OUTPUT -p udp --dport 5554 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 9996 -j DROP
$IPTABLES -A OUTPUT -p udp --dport 9996 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 137 -j DROP
$IPTABLES -A OUTPUT -p udp --dport 137 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 138 -j DROP
$IPTABLES -A OUTPUT -p udp --dport 138 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 139 -j DROP
ส่วนไอพีที่ผมใส่ไปมีแค่นี้ครับ
217.12.8.76
64.4.20.169
97.74.144.165
วันเสาร์ที่ 26 มิถุนายน พ.ศ. 2553
kick user บน freebsd
บทความจากเวบไซด์ ครูมานิส www.kroonis.org
โปรแกรม Kick User ใช้งานได้แล้วครับ โดยให้ผู้ใช้งานสามารถ Clear Login ของตนเองได้แล้ว ทำตามดังนี้
1. Setup sudo
# cd /usr/ports/security/sudo
# make install clean
เลือกรายการ 1 และ 2 กดแท็บไปที่ OK กดปุ่ม Enter รอจนกว่าระบบจะติดตั้ง sudo เสร็จ
2. ปรับแต่งไฟล์ sudoers ใช้คำสั่งดังนี้
# echo 'www-data ALL=NOPASSWD: /bin/echo, /usr/bin/radclient' >> /usr/local/etc/sudoers
# echo 'www-data ALL=NOPASSWD: /usr/local/etc/rc.d/squid restart' >> /usr/local/etc/sudoers
# echo 'www-data ALL=NOPASSWD: /usr/local/sbin/squid -k reconfig' >> /usr/local/etc/sudoers
3. กำหนดสิทธิไฟล์ sudoers และ radiusd ใหม่
# chmod 777 /usr/local/etc/sudoers
# chmod 711 /usr/local/etc/raddb
# chmod 755 /usr/local/etc/raddb/dictionary
# rehash
4. เตรียมไฟล์ user_online.php และ kick.php ดาวโหลดจากเว็บไซต์ด้านล่าง
http://www.kroonis.org/Authen6.4/kick.rar (อับไฟล์ให้ใหม่ครับ)
จากนั้นให้ใช้โปรแกรม SSH โยนไฟล์ user_online.php และ kick.php
ไปไว้ที่ห้อง /usr/local/www/apache22/data/admin
5. เข้าเว็บ http://10.0.0.1/admin แล้วคลิกเมนู รายชื่อผู้ที่กำลังใช้งานอยู่ ให้คลิกรูป กากบาท ตรง user ที่ค้างในระบบ
เพียงเท่านี้ admin ก็สามารถเคลียร์ผู้ใช้งานที่ค้างในระบบโดยใช้ผ่านโปรแกรม ม.บูรพาได้แล้วครับ
6. กำหนดสิทธิ sudo ใหม่ดังนี้
# chmod 440 /usr/local/etc/sudoers
ถ้าต้องการให้ผู้ใช้งาน clear Login ตนเองได้ ทำตามดังนี้
1. เข้าเว็บ http://10.0.0.1/admin/kick.php
2. กรอกข้อมูลเข้าสู่ระบบให้ถูกต้อง แล้วคลิกปุ่ม clear user
3. ระบบจะรายงานว่าได้เคลียร์ข้อมูลผู้ใช้งานแล้ว สามารถ Login เพื่อเข้าสู่ระบบใหม่ได้
ขอขอบคุณ เพื่อน ๆ ที่ร่วมแลกเปลี่ยนประสบการณ์ ที่พัฒนาโปรแกรม kick user จากเว็บบอร์ด
ที่มา : http://www.linuxthai.org/forum/index.php?board=18.0
โปรแกรม Kick User ใช้งานได้แล้วครับ โดยให้ผู้ใช้งานสามารถ Clear Login ของตนเองได้แล้ว ทำตามดังนี้
1. Setup sudo
# cd /usr/ports/security/sudo
# make install clean
เลือกรายการ 1 และ 2 กดแท็บไปที่ OK กดปุ่ม Enter รอจนกว่าระบบจะติดตั้ง sudo เสร็จ
2. ปรับแต่งไฟล์ sudoers ใช้คำสั่งดังนี้
# echo 'www-data ALL=NOPASSWD: /bin/echo, /usr/bin/radclient' >> /usr/local/etc/sudoers
# echo 'www-data ALL=NOPASSWD: /usr/local/etc/rc.d/squid restart' >> /usr/local/etc/sudoers
# echo 'www-data ALL=NOPASSWD: /usr/local/sbin/squid -k reconfig' >> /usr/local/etc/sudoers
3. กำหนดสิทธิไฟล์ sudoers และ radiusd ใหม่
# chmod 777 /usr/local/etc/sudoers
# chmod 711 /usr/local/etc/raddb
# chmod 755 /usr/local/etc/raddb/dictionary
# rehash
4. เตรียมไฟล์ user_online.php และ kick.php ดาวโหลดจากเว็บไซต์ด้านล่าง
http://www.kroonis.org/Authen6.4/kick.rar (อับไฟล์ให้ใหม่ครับ)
จากนั้นให้ใช้โปรแกรม SSH โยนไฟล์ user_online.php และ kick.php
ไปไว้ที่ห้อง /usr/local/www/apache22/data/admin
5. เข้าเว็บ http://10.0.0.1/admin แล้วคลิกเมนู รายชื่อผู้ที่กำลังใช้งานอยู่ ให้คลิกรูป กากบาท ตรง user ที่ค้างในระบบ
เพียงเท่านี้ admin ก็สามารถเคลียร์ผู้ใช้งานที่ค้างในระบบโดยใช้ผ่านโปรแกรม ม.บูรพาได้แล้วครับ
6. กำหนดสิทธิ sudo ใหม่ดังนี้
# chmod 440 /usr/local/etc/sudoers
ถ้าต้องการให้ผู้ใช้งาน clear Login ตนเองได้ ทำตามดังนี้
1. เข้าเว็บ http://10.0.0.1/admin/kick.php
2. กรอกข้อมูลเข้าสู่ระบบให้ถูกต้อง แล้วคลิกปุ่ม clear user
3. ระบบจะรายงานว่าได้เคลียร์ข้อมูลผู้ใช้งานแล้ว สามารถ Login เพื่อเข้าสู่ระบบใหม่ได้
ขอขอบคุณ เพื่อน ๆ ที่ร่วมแลกเปลี่ยนประสบการณ์ ที่พัฒนาโปรแกรม kick user จากเว็บบอร์ด
ที่มา : http://www.linuxthai.org/forum/index.php?board=18.0
หลักการ clonefreebsd แบบคร่าว ๆ
หลักการ clone freebsd แบบคร่าว จากเวบไซด์ www.kroonis.org
1. Setup FreeBSD แบบ Express ใช้เวลาราว ๆ 2 นาที เร็วมาก ๆ
2. ให้บีบอัดห้องหลัก ๆ คือ usr var etc root boot home
โดยใช้คำสั่ง
# cd เข้าไปที่ห้องหลัก ๆ ก่อน เช่น cd /usr
# tar -cvf - * | gzip > /home/admin/usr.tar.gz
ทำแบบนี้ไปเรื่อย ๆ จนครบ ทุกห้องที่กล่าวมาแล้ว
จากนั้นก็ใช้โปรแกรม SSH ดึงไฟล์มาไว้ที่เครื่องของเรา
แล้วเขียน Shellscript ติดตั้ง EasyInstall123 ก็พร้อมใช้งานแล้วครับ ใช้เวลาโดยรวมแล้วไม่น่าจะเกิน 25 นาที
script"""ต้องปรับเอานะครับ..บางเครื่องอาจมีปัญหา
#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin
echo "#############################################################"
echo " Script Auto Install Authen and Log Server System By FreeBSDAuthen "
echo " www.kroonis.org "
echo " E-mail namo_nis@hotmail.com Setup Time 20 -30 Minute "
echo " ############################################################"
mkdir /home/admin/
cp /etc/fstab /cdrom/
cp /cdrom/usr.tar.gz /usr/
cp /cdrom/etc.tar.gz /etc/
cp /cdrom/var.tar.gz /var/
cp /cdrom/root.tar.gz /root/
cp /cdrom/boot.tar.gz /boot/
cp /cdrom/home.tar.gz /home/
cd /usr/
tar xvf usr.tar.gz
rm -rf usr.tar.gz
cd /etc/
tar xvf etc.tar.gz
rm -rf etc.tar.gz
cd /var/
tar xvf var.tar.gz
rm -rf var.tar.gz
cd /root/
tar xvf root.tar.gz
rm -rf root.tar.gz
cd /boot/
tar xvf boot.tar.gz
rm -rf boot.tar.gz
cd /home/
tar xvf home.tar.gz
rm -rf home.tar.gz
/usr/local/www/lightsquid/lightparser.pl
cp /home/admin/fstab /etc
chmod -R 777 /tmp
cp -R /cdrom/kroomanis /root
#bash /cdrom/kroomanis/netconfig.bash
echo " Install1 FreeBSD6.4 & Authen Finish By Manis Slangsingha Thank You "
reboot
1. Setup FreeBSD แบบ Express ใช้เวลาราว ๆ 2 นาที เร็วมาก ๆ
2. ให้บีบอัดห้องหลัก ๆ คือ usr var etc root boot home
โดยใช้คำสั่ง
# cd เข้าไปที่ห้องหลัก ๆ ก่อน เช่น cd /usr
# tar -cvf - * | gzip > /home/admin/usr.tar.gz
ทำแบบนี้ไปเรื่อย ๆ จนครบ ทุกห้องที่กล่าวมาแล้ว
จากนั้นก็ใช้โปรแกรม SSH ดึงไฟล์มาไว้ที่เครื่องของเรา
แล้วเขียน Shellscript ติดตั้ง EasyInstall123 ก็พร้อมใช้งานแล้วครับ ใช้เวลาโดยรวมแล้วไม่น่าจะเกิน 25 นาที
script"""ต้องปรับเอานะครับ..บางเครื่องอาจมีปัญหา
#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/root/bin
echo "#############################################################"
echo " Script Auto Install Authen and Log Server System By FreeBSDAuthen "
echo " www.kroonis.org "
echo " E-mail namo_nis@hotmail.com Setup Time 20 -30 Minute "
echo " ############################################################"
mkdir /home/admin/
cp /etc/fstab /cdrom/
cp /cdrom/usr.tar.gz /usr/
cp /cdrom/etc.tar.gz /etc/
cp /cdrom/var.tar.gz /var/
cp /cdrom/root.tar.gz /root/
cp /cdrom/boot.tar.gz /boot/
cp /cdrom/home.tar.gz /home/
cd /usr/
tar xvf usr.tar.gz
rm -rf usr.tar.gz
cd /etc/
tar xvf etc.tar.gz
rm -rf etc.tar.gz
cd /var/
tar xvf var.tar.gz
rm -rf var.tar.gz
cd /root/
tar xvf root.tar.gz
rm -rf root.tar.gz
cd /boot/
tar xvf boot.tar.gz
rm -rf boot.tar.gz
cd /home/
tar xvf home.tar.gz
rm -rf home.tar.gz
/usr/local/www/lightsquid/lightparser.pl
cp /home/admin/fstab /etc
chmod -R 777 /tmp
cp -R /cdrom/kroomanis /root
#bash /cdrom/kroomanis/netconfig.bash
echo " Install1 FreeBSD6.4 & Authen Finish By Manis Slangsingha Thank You "
reboot
หลักการ clonefreebsd แบบคร่าว ๆ
หลักการ clone freebsd แบบคร่าว จากเวบไซด์ www.kroonis.org
1. Setup FreeBSD แบบ Express ใช้เวลาราว ๆ 2 นาที เร็วมาก ๆ
2. ให้บีบอัดห้องหลัก ๆ คือ usr var etc root boot home
โดยใช้คำสั่ง
# cd เข้าไปที่ห้องหลัก ๆ ก่อน เช่น cd /usr
# tar -cvf - * | gzip > /home/admin/usr.tar.gz
ทำแบบนี้ไปเรื่อย ๆ จนครบ ทุกห้องที่กล่าวมาแล้ว
จากนั้นก็ใช้โปรแกรม SSH ดึงไฟล์มาไว้ที่เครื่องของเรา
แล้วเขียน Shellscript ติดตั้ง EasyInstall123 ก็พร้อมใช้งานแล้วครับ ใช้เวลาโดยรวมแล้วไม่น่าจะเกิน 25 นาที
1. Setup FreeBSD แบบ Express ใช้เวลาราว ๆ 2 นาที เร็วมาก ๆ
2. ให้บีบอัดห้องหลัก ๆ คือ usr var etc root boot home
โดยใช้คำสั่ง
# cd เข้าไปที่ห้องหลัก ๆ ก่อน เช่น cd /usr
# tar -cvf - * | gzip > /home/admin/usr.tar.gz
ทำแบบนี้ไปเรื่อย ๆ จนครบ ทุกห้องที่กล่าวมาแล้ว
จากนั้นก็ใช้โปรแกรม SSH ดึงไฟล์มาไว้ที่เครื่องของเรา
แล้วเขียน Shellscript ติดตั้ง EasyInstall123 ก็พร้อมใช้งานแล้วครับ ใช้เวลาโดยรวมแล้วไม่น่าจะเกิน 25 นาที
วันอาทิตย์ที่ 13 มิถุนายน พ.ศ. 2553
ใช้ axel แทน fetch
TIPSจาก thaibsd.com
โปรแกรม axel เป็นเครื่องมือที่ใช้ในการ download file จาก URL ที่เราต้องการซึ่งจะเป็นโปรแกรมที่มีความเร็วมากกว่า wget , fetch หลายเท่าตัว หากเปรียบกับ Win ก็ประมาณ flashget และมีจุดเด่นคือ สามารถ download ต่อจากจุดที่ทำงานเสร็จก่อนหน้านี้ได้
cd /usr/ports/ftp/axel
make install
rehash
การใช้งาน axel
axel
edit /etc/make.conf
insert
FETCH_CMD = /usr/local/bin/axel
มันจะใช้ axel แทน fetch ไวเร็วดุจนรก
ผมใช้ prozilla อยู่ครับ ก็ดีเหมือนกัน
#cd /usr/ports/ftp/prozilla
#make; make install
การใช้งาน
#proz
ค่า default ตั้งไว้ที่ 4 connections หาก server รองรับการ resume
หรือ
#proz -k=n
กำหนดให้เพิ่มจำนวน connect ได้ เช่น -k=10
หากตั้งไว้หลัง proxy ที่มีการ authen ก็ไปแก้ไขไปได้ที่
/root/.prozilla/prozconfig
โปรแกรม axel เป็นเครื่องมือที่ใช้ในการ download file จาก URL ที่เราต้องการซึ่งจะเป็นโปรแกรมที่มีความเร็วมากกว่า wget , fetch หลายเท่าตัว หากเปรียบกับ Win ก็ประมาณ flashget และมีจุดเด่นคือ สามารถ download ต่อจากจุดที่ทำงานเสร็จก่อนหน้านี้ได้
cd /usr/ports/ftp/axel
make install
rehash
การใช้งาน axel
axel
edit /etc/make.conf
insert
FETCH_CMD = /usr/local/bin/axel
มันจะใช้ axel แทน fetch ไวเร็วดุจนรก
ผมใช้ prozilla อยู่ครับ ก็ดีเหมือนกัน
#cd /usr/ports/ftp/prozilla
#make; make install
การใช้งาน
#proz
ค่า default ตั้งไว้ที่ 4 connections หาก server รองรับการ resume
หรือ
#proz -k=n
กำหนดให้เพิ่มจำนวน connect ได้ เช่น -k=10
หากตั้งไว้หลัง proxy ที่มีการ authen ก็ไปแก้ไขไปได้ที่
/root/.prozilla/prozconfig
ทำให้ userไม่ใช้ตัวหนอนทำเวบได้
TIPS จากเวบไซด์ www.thaibsd.com/
แก้ไข httpd.conf ดังนี้
# pico /usr/local/etc/apache22/httpd.conf
กด Ctrl + w พิมพ์ DocumentRoot
เปลี่ยนเป็น
DocumentRoot "/home/"
ไปที่กลุ่มบรรทัด
AllowOverride None
Order deny,allow
Deny from all
แล้วเปลี่ยนใหม่เป็น
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
แทรกคำสั่ง
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
บันทึกไฟล์และออก
# /usr/local/sbin/apachectl restart
อ้างอิง::http://gotoknow.org/blog/tammarat/308437
แก้ไข httpd.conf ดังนี้
# pico /usr/local/etc/apache22/httpd.conf
กด Ctrl + w พิมพ์ DocumentRoot
เปลี่ยนเป็น
DocumentRoot "/home/"
ไปที่กลุ่มบรรทัด
AllowOverride None
Order deny,allow
Deny from all
แล้วเปลี่ยนใหม่เป็น
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
แทรกคำสั่ง
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
บันทึกไฟล์และออก
# /usr/local/sbin/apachectl restart
อ้างอิง::http://gotoknow.org/blog/tammarat/308437
วันเสาร์ที่ 5 มิถุนายน พ.ศ. 2553
mrtg บน centos
proftpd บน centos
บทความโดย mr.gril
โดยปกติแล้ว CentOS จะไม่สามารถติดตั้ง proftpd ผ่านคำสั่ง yum ได้จำเป็นต้องติดตั้ง third-party yum repository เสียก่อน
1.) ติดตั้ง third-party yum repository ผมใช้ repository ของ securityteam.us นะครับ
# rpm -Uvh http://repo.securityteam.us/repository/redhat/securityteamus-repo-latest.rpm
# rpm --import http://repo.securityteam.us/repository/RPM-GPG-KEY
2.) ติดตั้ง ProFTPd
# yum install proftpd
หลังจากติดตั้งเสร็จแล้วไฟล์คอนฟิกของ ProFTPd จะอยู่ที่ /etc/proftpd.conf ซึ่งสามารถใช้ค่าปกตินี้ได้เลย
3.) หากบนเครื่องเซิร์ฟเวอร์มีโปรแกรมให้บริการ FTP ตัวอื่นเช่น vsFTPd ก็ควรหยุดการทำงานของโปรแกรมดังกล่าวเสียก่อนหรือถอนการติดตั้งเสียก่อน(หากไม่มีข้ามขั้นตอนนี้ไปได้เลย)
# yum remove vsftpd
4.) กำหนดให้ ProFTPd ทำงานทุกครั้งเมื่อเริ่มต้นระบบและเริ่มการทำงานของ ProFTPd
# chkconfig proftpd on
# /etc/init.d/proftpd start
5.) ทดสอบว่า ProFTPd ทำงานจริงหรือไม่
# netstat -pant | grep 21
tcp 0 0 :::21 :::* LISTEN 31150/proftpd: (acc
# ps aux | grep proftpd
nobody 31150 0.0 0.1 5068 1236 ? Ss 18:30 0:00 proftpd: (accepting connections)
# ftp localhost
Connected to localhost.localdomain.
220 FTP Server ready.
500 AUTH not understood
500 AUTH not understood
KERBEROS_V4 rejected as an authentication type
Name (localhost:root): webmaster << กรอกชื่อ user เข้าไป
331 Password required for webmaster
Password: << กรอกรหัสผ่าน
230 User webmaster logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> #แสดงว่า login ได้แล้ว
***หมายเหตุ กรณีที่เครื่องเซิร์ฟเวอร์อยู่หลังไฟล์วอล์หรือมีการเปิดการใช้งานไฟล์วอล์ เช่น iptables จำเป็นต้อง allow TCP port 21 ด้วย
โดยปกติแล้ว CentOS จะไม่สามารถติดตั้ง proftpd ผ่านคำสั่ง yum ได้จำเป็นต้องติดตั้ง third-party yum repository เสียก่อน
1.) ติดตั้ง third-party yum repository ผมใช้ repository ของ securityteam.us นะครับ
# rpm -Uvh http://repo.securityteam.us/repository/redhat/securityteamus-repo-latest.rpm
# rpm --import http://repo.securityteam.us/repository/RPM-GPG-KEY
2.) ติดตั้ง ProFTPd
# yum install proftpd
หลังจากติดตั้งเสร็จแล้วไฟล์คอนฟิกของ ProFTPd จะอยู่ที่ /etc/proftpd.conf ซึ่งสามารถใช้ค่าปกตินี้ได้เลย
3.) หากบนเครื่องเซิร์ฟเวอร์มีโปรแกรมให้บริการ FTP ตัวอื่นเช่น vsFTPd ก็ควรหยุดการทำงานของโปรแกรมดังกล่าวเสียก่อนหรือถอนการติดตั้งเสียก่อน(หากไม่มีข้ามขั้นตอนนี้ไปได้เลย)
# yum remove vsftpd
4.) กำหนดให้ ProFTPd ทำงานทุกครั้งเมื่อเริ่มต้นระบบและเริ่มการทำงานของ ProFTPd
# chkconfig proftpd on
# /etc/init.d/proftpd start
5.) ทดสอบว่า ProFTPd ทำงานจริงหรือไม่
# netstat -pant | grep 21
tcp 0 0 :::21 :::* LISTEN 31150/proftpd: (acc
# ps aux | grep proftpd
nobody 31150 0.0 0.1 5068 1236 ? Ss 18:30 0:00 proftpd: (accepting connections)
# ftp localhost
Connected to localhost.localdomain.
220 FTP Server ready.
500 AUTH not understood
500 AUTH not understood
KERBEROS_V4 rejected as an authentication type
Name (localhost:root): webmaster << กรอกชื่อ user เข้าไป
331 Password required for webmaster
Password: << กรอกรหัสผ่าน
230 User webmaster logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> #แสดงว่า login ได้แล้ว
***หมายเหตุ กรณีที่เครื่องเซิร์ฟเวอร์อยู่หลังไฟล์วอล์หรือมีการเปิดการใช้งานไฟล์วอล์ เช่น iptables จำเป็นต้อง allow TCP port 21 ด้วย
ปรับ apache บน centos ให้รองรับภาษาไทย
วันพุธที่ 26 พฤษภาคม พ.ศ. 2553
tip backup mysql ผ่าน command line
tip จาก อ.กิตติพงษ์ แห่ง thaibsd.com
เราสามารถใช้คำสั่งนี้ได้ครับ
mysqldump --all-databases > backup.sql -u root -pXXXXX
เมื่อ XXXXX คือรหัสผ่านครับ
ส่วน backup.sql คือ ชื่อไฟล์ที่ต้องการสำรอง
เพิ่มเติมโดย yim แห่ง thaibsd.com
แถม
mysqldump -uroot -pxxx syslog | gzip > syslog.tar.gz
บีบอัดไปในตัว
บางทีทำ crontab บีบไฟล์แล้วโยนไปที่ server อีกตัว ก็ได้
เราสามารถใช้คำสั่งนี้ได้ครับ
mysqldump --all-databases > backup.sql -u root -pXXXXX
เมื่อ XXXXX คือรหัสผ่านครับ
ส่วน backup.sql คือ ชื่อไฟล์ที่ต้องการสำรอง
เพิ่มเติมโดย yim แห่ง thaibsd.com
แถม
mysqldump -uroot -pxxx syslog | gzip > syslog.tar.gz
บีบอัดไปในตัว
บางทีทำ crontab บีบไฟล์แล้วโยนไปที่ server อีกตัว ก็ได้
วันอาทิตย์ที่ 2 พฤษภาคม พ.ศ. 2553
freebsd บูตไม่ขึ้นไฟดับ
แนวทางแก้ไขไฟฟ้าดับบน freebsd บูตไม่ได้วิธีแก้ไขโดยพี่มะขาม...คุณพรมมาศ
# fsck -p
# mount -u /
# mount -a -t ufs
หาก fsck -p ไม่ผ่าน ลอง fsck -f ดูครับ
ท่าที่เคยทำ ไม่ได้เม้าหรอก ลุยเลย
# /sbin/adjkerntz -i
อาจจะไม่ได้เน้อ ตอนนี้ ผ่านไป ถ้ามันติด
# fsck_ufs /dev/da0s1a
ถ้าว่า root partition นั้นอยู่ที่ /dev/da0s1a น่ะ อย่ไปลบวาย (-y) ทนเอาครับ ทนทำเอา รึอยากจะใส่แต่ทีแรกเลย ก็ไม่ว่า
แล้วก็ไล่ทำไปทีละ partition น่ะ จนหมด
จากนั้นค่อยสั่งเม้าลบเอ mount -a แล้วก็ exit ไปสู่ multiuser mode
โชคดีน่ะ
อ้าว มาโพสไล่ๆกัน
จำไว้ เวลาอยู่ใน single user mode อย่าลบ
/etc/fstab ถ้าหาย ก็โชคร้ายแล้ว เว้นเสียแต่จะจำได้ว่า partition ไหน mount device อะไรไว้
ซึ่ง ถ้าจำได้ ก็ทำฟิ้สกี้ไป พอจบอย่างสะอาดแล้ว ก็ไล่ mount ไปทีละ partition ซะ แล้วก็เขียนแฟ้ม /etc/fstab ใหม่น่ะ
ถ้าลบ /etc/fstab ก็คงจะหมดทางที่จะบูตด้วยระบบเดิมครับ เพราะไฟล์นี้จะมีรายการ partition ทั้งหมด คงต้องบูตด้วยแผ่น live fs ครับ ไปที่เมนู Fix จะเข้าสู่ shell ได้ ทำการ mount partition แล้วคัดลอกข้อมูลออกมาครับ
โดยส่วนใหญ่จะชื่อ dev จะเป็นแบบนี้ครับ
/dev/ad0s1a
/dev/ad0s1d
/dev/ad0s1e
/dev/ad0s1f
บางเครื่องอาจไม่เหมืือนกันเป็น ad0, ad1, da0
พอจะสังเกตได้โดยใช้คำสั่ง ls /dev ครับ
ดาวน์โหลดแผ่น live fs
ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/ISO-IMAGES/8.0/8.0-RELEASE-i386-livefs.iso
บูตด้วยแผ่น live fs เลือก fix จนเข้า shell ได้
mount patition / โดย
# mount -t ufs /dev/ad0s1a /mnt
ตอนนี้ก็จะเข้า partition / ของระบบเดิมได้โดยจะอยู่ใน /mnt
ถ้าจำได้ว่า /home อยู่ partition ไหนก็ทำการ mount โดยใช้คำสั่งรูปแบบเีดียวกับ mount partition /
แล้วคัดลอกไฟล์ fstab ไปไว้ที่ /mnt/etc หรือจะสร้างใหม่ก็ได้ครับดูตัวอย่างจากเครื่องอื่นก็ได้ครับ เอาแค่ partition ที่จำเป็นก็พอ
วิธีค่อนข้างยุ่งยากครับ ผมอธิบายย่อ ๆ ไว้ก่อนครับ
อยู่บ้านรึ
ปกติ ถ้าพอจำได้ว่ามีแค่ /, /var, /usr, /home ละก็ มันจะอยู่ partition สุดท้ายแหละ f ไง
ลองดูน่ะ fsck_ufs /dev/da0s1f
ลำดับของมันจะแปลกๆ คือ /, /home, /usr, /var และ partition ที่อยู่จะเป็น a, f, e, d ตามลำดับ และ /etc/fstab เท่าที่ใช้ ก็เป็น
/dev/ad0s1b none swap sw 0 0
/dev/da0s1b none swap sw 0 0
/dev/ad0s1a / ufs rw 1 1
/dev/ad0s1f /home ufs rw 2 2
/dev/ad0s1e /usr ufs rw 2 2
/dev/ad0s1d /var ufs rw 2 2
/dev/da0s1d /kaitag ufs rw 2 2
/dev/acd0 /cdrom cd9660 ro,noauto 0 0
ดูยากหน่อยน่ะ เพราะที่นี่เขามีสวยๆกันไม่ได้ สวยๆ เป็นโดนเก็บไปหมดรึไงก็ไม่รู้แฮะ
นี่นี่ ในแฟ้ม /etc/fstab นั้น ลำดับที่ ๒ เป็น swap partition ที่ หาค่าเทอม ใช้เองน่ะ ปกติ มีแต่ swap partition แรกเท่านั้นระวังให้มากมาก
[~] % cat /etc/fstab
# Device Mountpoint FStype Options Dump Pass#
/dev/ad0s1b none swap sw 0 0
/dev/ad0s1a / ufs rw 1 1
/dev/ad0s1f /home ufs rw 2 2
/dev/ad0s1e /usr ufs rw 2 2
/dev/ad0s1d /var ufs rw 2 2
/dev/da0s1d /kaitag ufs rw 2 2
/dev/acd0 /cdrom cd9660 ro,noauto 0 0
proc /proc procfs rw 0 0
นั่นแหละ เอามาเถอะ คือ ปกติ คนเรามักจะทำอะไรซ้ำๆกันน่ะ เพราะฉะนั้น ลูกใหม่ที่ลงมา มันก็คงใช้ partition เดิมๆแหละ
ส่วน dmesg นั้นก็เพียงอยากทราบชื่อของ hard disk ลูกนั้นเท่านั้นเอง ไม่มีอะไรปิดบังกันหรอก เห็นบอกว่ามันเป็นลูกแรกไม่ใช่หรือ ดังนี้แล้ว unit number จะเป็น 0 และถ้าใช้ทั้งลูก slice number ก็คงเป็น 1
พอรู้ ก็เอามาประกอบได้เลย สังเคราะห์ได้เลย
/dev/XX0s1a คือ partition / ของ hard disk ที่ชื่อ XX
พอได้ก็สั่งฟิ้สกี้ได้เลย
fsck_ufs /dev/XX0s1a
แล้วก็ไล่ไปทีละ partition จาก d,e,f สำหรับ /var, /usr, /home เท่านั้นเอง
เดาเอาน่ะ ว่ามีเพียง usr, var , home
เฮ้อ
พอดี รายการทีวีช่องหนึ่งออกรายการให้ทารกมาร้องเพลงหาค่าเทอม มันมาออกรายการเอาตอนตอบ เลยใช้ชื่อว่า หาค่าเทอม
ความจริง ก็กำลังจะบอกว่า ให้ boot ด้วยแผ่นที่สามารถให้ระบบวิ่งได้ซะก่อน
จากนั้น สั่ง
# fsck_ufs /dev/da0s1g
# fsck_ufs /dev/da0s1a
จากนั้น ถ้า มันจบอย่างสะอาดน่ะ ให้สั่ง
# mount /dev/da0s1g /mnt
แล้วก็ ไปเอาแฟ้ม fstab ที่ว่า เอาไว้ที่ /home นั่นแหละ จด คัดลอกออกมา
แล้วก็ umount /mnt ซะ แล้วก็สั่ง
# mount /dev/da0s1a /mnt
แล้วถึงเรียก หรือสั่ง
# vi /mnt/etc/fstab
แล้วก็พิพม์ลงไป ข้อความที่ได้คัดลอกออกมาแล้วนั่นแหละ แล้วก็ save และ exit จาก vi ซะ
แล้วก็ reboot ด้วยก้อนแรก ก้อนที่เพิ่งเขียนแฟ้ม /etc/fstab ไปนี่แหละ ซึ่งน่าจะได้ และมาจบที่ single user mode ตามเดิม
แต่เมื่อ file system พัง ก็เป็นอันจบเห่กันพอดี
ยังไงก็ตามทีเหอะ น่ะ ขอให้โชคดี และสนุกกับ FreeBSD น่ะ
# fsck -p
# mount -u /
# mount -a -t ufs
หาก fsck -p ไม่ผ่าน ลอง fsck -f ดูครับ
ท่าที่เคยทำ ไม่ได้เม้าหรอก ลุยเลย
# /sbin/adjkerntz -i
อาจจะไม่ได้เน้อ ตอนนี้ ผ่านไป ถ้ามันติด
# fsck_ufs /dev/da0s1a
ถ้าว่า root partition นั้นอยู่ที่ /dev/da0s1a น่ะ อย่ไปลบวาย (-y) ทนเอาครับ ทนทำเอา รึอยากจะใส่แต่ทีแรกเลย ก็ไม่ว่า
แล้วก็ไล่ทำไปทีละ partition น่ะ จนหมด
จากนั้นค่อยสั่งเม้าลบเอ mount -a แล้วก็ exit ไปสู่ multiuser mode
โชคดีน่ะ
อ้าว มาโพสไล่ๆกัน
จำไว้ เวลาอยู่ใน single user mode อย่าลบ
/etc/fstab ถ้าหาย ก็โชคร้ายแล้ว เว้นเสียแต่จะจำได้ว่า partition ไหน mount device อะไรไว้
ซึ่ง ถ้าจำได้ ก็ทำฟิ้สกี้ไป พอจบอย่างสะอาดแล้ว ก็ไล่ mount ไปทีละ partition ซะ แล้วก็เขียนแฟ้ม /etc/fstab ใหม่น่ะ
ถ้าลบ /etc/fstab ก็คงจะหมดทางที่จะบูตด้วยระบบเดิมครับ เพราะไฟล์นี้จะมีรายการ partition ทั้งหมด คงต้องบูตด้วยแผ่น live fs ครับ ไปที่เมนู Fix จะเข้าสู่ shell ได้ ทำการ mount partition แล้วคัดลอกข้อมูลออกมาครับ
โดยส่วนใหญ่จะชื่อ dev จะเป็นแบบนี้ครับ
/dev/ad0s1a
/dev/ad0s1d
/dev/ad0s1e
/dev/ad0s1f
บางเครื่องอาจไม่เหมืือนกันเป็น ad0, ad1, da0
พอจะสังเกตได้โดยใช้คำสั่ง ls /dev ครับ
ดาวน์โหลดแผ่น live fs
ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/ISO-IMAGES/8.0/8.0-RELEASE-i386-livefs.iso
บูตด้วยแผ่น live fs เลือก fix จนเข้า shell ได้
mount patition / โดย
# mount -t ufs /dev/ad0s1a /mnt
ตอนนี้ก็จะเข้า partition / ของระบบเดิมได้โดยจะอยู่ใน /mnt
ถ้าจำได้ว่า /home อยู่ partition ไหนก็ทำการ mount โดยใช้คำสั่งรูปแบบเีดียวกับ mount partition /
แล้วคัดลอกไฟล์ fstab ไปไว้ที่ /mnt/etc หรือจะสร้างใหม่ก็ได้ครับดูตัวอย่างจากเครื่องอื่นก็ได้ครับ เอาแค่ partition ที่จำเป็นก็พอ
วิธีค่อนข้างยุ่งยากครับ ผมอธิบายย่อ ๆ ไว้ก่อนครับ
อยู่บ้านรึ
ปกติ ถ้าพอจำได้ว่ามีแค่ /, /var, /usr, /home ละก็ มันจะอยู่ partition สุดท้ายแหละ f ไง
ลองดูน่ะ fsck_ufs /dev/da0s1f
ลำดับของมันจะแปลกๆ คือ /, /home, /usr, /var และ partition ที่อยู่จะเป็น a, f, e, d ตามลำดับ และ /etc/fstab เท่าที่ใช้ ก็เป็น
/dev/ad0s1b none swap sw 0 0
/dev/da0s1b none swap sw 0 0
/dev/ad0s1a / ufs rw 1 1
/dev/ad0s1f /home ufs rw 2 2
/dev/ad0s1e /usr ufs rw 2 2
/dev/ad0s1d /var ufs rw 2 2
/dev/da0s1d /kaitag ufs rw 2 2
/dev/acd0 /cdrom cd9660 ro,noauto 0 0
ดูยากหน่อยน่ะ เพราะที่นี่เขามีสวยๆกันไม่ได้ สวยๆ เป็นโดนเก็บไปหมดรึไงก็ไม่รู้แฮะ
นี่นี่ ในแฟ้ม /etc/fstab นั้น ลำดับที่ ๒ เป็น swap partition ที่ หาค่าเทอม ใช้เองน่ะ ปกติ มีแต่ swap partition แรกเท่านั้นระวังให้มากมาก
[~] % cat /etc/fstab
# Device Mountpoint FStype Options Dump Pass#
/dev/ad0s1b none swap sw 0 0
/dev/ad0s1a / ufs rw 1 1
/dev/ad0s1f /home ufs rw 2 2
/dev/ad0s1e /usr ufs rw 2 2
/dev/ad0s1d /var ufs rw 2 2
/dev/da0s1d /kaitag ufs rw 2 2
/dev/acd0 /cdrom cd9660 ro,noauto 0 0
proc /proc procfs rw 0 0
นั่นแหละ เอามาเถอะ คือ ปกติ คนเรามักจะทำอะไรซ้ำๆกันน่ะ เพราะฉะนั้น ลูกใหม่ที่ลงมา มันก็คงใช้ partition เดิมๆแหละ
ส่วน dmesg นั้นก็เพียงอยากทราบชื่อของ hard disk ลูกนั้นเท่านั้นเอง ไม่มีอะไรปิดบังกันหรอก เห็นบอกว่ามันเป็นลูกแรกไม่ใช่หรือ ดังนี้แล้ว unit number จะเป็น 0 และถ้าใช้ทั้งลูก slice number ก็คงเป็น 1
พอรู้ ก็เอามาประกอบได้เลย สังเคราะห์ได้เลย
/dev/XX0s1a คือ partition / ของ hard disk ที่ชื่อ XX
พอได้ก็สั่งฟิ้สกี้ได้เลย
fsck_ufs /dev/XX0s1a
แล้วก็ไล่ไปทีละ partition จาก d,e,f สำหรับ /var, /usr, /home เท่านั้นเอง
เดาเอาน่ะ ว่ามีเพียง usr, var , home
เฮ้อ
พอดี รายการทีวีช่องหนึ่งออกรายการให้ทารกมาร้องเพลงหาค่าเทอม มันมาออกรายการเอาตอนตอบ เลยใช้ชื่อว่า หาค่าเทอม
ความจริง ก็กำลังจะบอกว่า ให้ boot ด้วยแผ่นที่สามารถให้ระบบวิ่งได้ซะก่อน
จากนั้น สั่ง
# fsck_ufs /dev/da0s1g
# fsck_ufs /dev/da0s1a
จากนั้น ถ้า มันจบอย่างสะอาดน่ะ ให้สั่ง
# mount /dev/da0s1g /mnt
แล้วก็ ไปเอาแฟ้ม fstab ที่ว่า เอาไว้ที่ /home นั่นแหละ จด คัดลอกออกมา
แล้วก็ umount /mnt ซะ แล้วก็สั่ง
# mount /dev/da0s1a /mnt
แล้วถึงเรียก หรือสั่ง
# vi /mnt/etc/fstab
แล้วก็พิพม์ลงไป ข้อความที่ได้คัดลอกออกมาแล้วนั่นแหละ แล้วก็ save และ exit จาก vi ซะ
แล้วก็ reboot ด้วยก้อนแรก ก้อนที่เพิ่งเขียนแฟ้ม /etc/fstab ไปนี่แหละ ซึ่งน่าจะได้ และมาจบที่ single user mode ตามเดิม
แต่เมื่อ file system พัง ก็เป็นอันจบเห่กันพอดี
ยังไงก็ตามทีเหอะ น่ะ ขอให้โชคดี และสนุกกับ FreeBSD น่ะ
วันอาทิตย์ที่ 25 เมษายน พ.ศ. 2553
ลืมรหัส root บน centos
บทความจากคุณสกอร์เปี้ยน เวบ www.thaiadmin.org
ในกรณี ที่ท่านใช้ GRUB
1. ให้ทำการ Reboot เครื่อง
2. ถ้าท่านตั้ง password ใน GRUB ให้กด p แล้วใส่ Password (ถ้าไม่ได้ตั้ง password ของ GRUB ไว้ให้ทำการข้ามขั้นตอนนี้)
3. ให้เลือก Linux version ที่ท่านต้องการ boot (ในกรณีที่ท่าน ได้ลง linux หลายค่าย หรือ หลาย version )
4. กด e ( เพื่อเข้าไปทำการแก้ไข )
5. ให้กด ลูกศร เพื่อเลื่อนไป บรรทัดที่ขึ้น ต้นคำว่า "kernel" แล้ว พิมพ์ e อีก เพื่อทำการแก้ไข เช่น
kernal /vmlinuz-2.4.18.14 ro root=LABEL=/ hdc=ide-scsi
6. ให้เลื่อนไปท้าย สุด แล้ว กด Spacebar เพื่อเว้นวรรค แล้วพิมพ์ "single"
จากนั้นให้ กด Enter เพื่อสิ้นสุดการแก้ไข ตัวอย่าง
kernal /vmlinuz-2.4.18.14 ro root=LABEL=/ hdc=ide-scsi single
7. พิมพ์ b เพื่อ boot แบบ single mode
8. เมื่อ อยู่ ใน single mode ท่านอยู่ในสถานะของ root สามารถ แก้ไข password โดยการใช้คำสั่ง "passwd"
9. ทำการ reboot โดยใช้คำสั่ง "reboot" หรือ "shutdown -r now"
Password root ใช้ GRUB เป็นบูตโหลดเดอร์ ที่ง่ายกว่า
1. ให้ทำการ Reboot เครื่อง
2. เมื่อเครื่องถึงหน้าจอบูตโหลดเดอร์ของ Grub แล้วให้กด ปุ่ม A
3. ให้ไปท้ายคำสั่ง กด Spacebar เพื่อเว้นวรรค แล้วพิมพ์ "single" ต่อท้าย แล้วกด Enter
การเปลี่ยน Password ในกรณีที่ท่านใช้ LILO
1. ให้ทำการ Reboot เครื่อง
2. ถ้าอยู่ในรูปแบบ LILO boot Prompt ให้พิมพ์ "linux single"
แต่ถ้าอยู่ในรูปแบบ กราฟฟิค ให้ทำการกด Ctrl-x เพื่อออกจากรูปแบบกราฟฟิคก่อน แล้วพิมพ์ "linux single"
3. เมื่อ อยู่ ใน single mode ท่านอยู่ในสถานะของ root สามารถ แก้ไข password โดยการใช้คำสั่ง "passwd"
4. ทำการ reboot โดยใช้คำสั่ง "reboot" หรือ "shutdown -r now"
ในกรณี ที่ท่านใช้ GRUB
1. ให้ทำการ Reboot เครื่อง
2. ถ้าท่านตั้ง password ใน GRUB ให้กด p แล้วใส่ Password (ถ้าไม่ได้ตั้ง password ของ GRUB ไว้ให้ทำการข้ามขั้นตอนนี้)
3. ให้เลือก Linux version ที่ท่านต้องการ boot (ในกรณีที่ท่าน ได้ลง linux หลายค่าย หรือ หลาย version )
4. กด e ( เพื่อเข้าไปทำการแก้ไข )
5. ให้กด ลูกศร เพื่อเลื่อนไป บรรทัดที่ขึ้น ต้นคำว่า "kernel" แล้ว พิมพ์ e อีก เพื่อทำการแก้ไข เช่น
kernal /vmlinuz-2.4.18.14 ro root=LABEL=/ hdc=ide-scsi
6. ให้เลื่อนไปท้าย สุด แล้ว กด Spacebar เพื่อเว้นวรรค แล้วพิมพ์ "single"
จากนั้นให้ กด Enter เพื่อสิ้นสุดการแก้ไข ตัวอย่าง
kernal /vmlinuz-2.4.18.14 ro root=LABEL=/ hdc=ide-scsi single
7. พิมพ์ b เพื่อ boot แบบ single mode
8. เมื่อ อยู่ ใน single mode ท่านอยู่ในสถานะของ root สามารถ แก้ไข password โดยการใช้คำสั่ง "passwd"
9. ทำการ reboot โดยใช้คำสั่ง "reboot" หรือ "shutdown -r now"
Password root ใช้ GRUB เป็นบูตโหลดเดอร์ ที่ง่ายกว่า
1. ให้ทำการ Reboot เครื่อง
2. เมื่อเครื่องถึงหน้าจอบูตโหลดเดอร์ของ Grub แล้วให้กด ปุ่ม A
3. ให้ไปท้ายคำสั่ง กด Spacebar เพื่อเว้นวรรค แล้วพิมพ์ "single" ต่อท้าย แล้วกด Enter
การเปลี่ยน Password ในกรณีที่ท่านใช้ LILO
1. ให้ทำการ Reboot เครื่อง
2. ถ้าอยู่ในรูปแบบ LILO boot Prompt ให้พิมพ์ "linux single"
แต่ถ้าอยู่ในรูปแบบ กราฟฟิค ให้ทำการกด Ctrl-x เพื่อออกจากรูปแบบกราฟฟิคก่อน แล้วพิมพ์ "linux single"
3. เมื่อ อยู่ ใน single mode ท่านอยู่ในสถานะของ root สามารถ แก้ไข password โดยการใช้คำสั่ง "passwd"
4. ทำการ reboot โดยใช้คำสั่ง "reboot" หรือ "shutdown -r now"
วันอังคารที่ 20 เมษายน พ.ศ. 2553
ความหมาย iptables
บทความจากคุณ upper แห่ง linuxthai.org/forum/
1:#iptables -A INPUT -s 192.168.1.0/24 -d 0/0 -p tcp --dport 21 --syn -j ACCEPT
2:#iptables -A INPUT -s 192.168.1.0/24 -d 0/0 -p tcp --dport 23 --syn -j ACCEPT
3:#iptables -A INPUT -s 0/0 -d 0/0 -t tcp --dport 25 --syn -j ACCEPT
4:#iptables -A INPUT -s 0/0 -d 0/0 -p tcp --dport 80 --syn -j ACCEPT
5:#iptables -A INPUT -s 192.168.1.0/24 -d 0/0 -p tcp --dport 110 --syn -j ACCEPT
6:#iptables -A INPUT -s 192.168.1.0/24 -d 0/0 -p tcp --dport 143 --syn -j ACCEPT
7:#iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -p tcp --dport 143 --syn -j ACCETP
8:#iptables -A INPUT -s 192.168.1.0/24 -d 0/0 -p tcp --dport 443 --syn -j ACCEPT
9:#iptables -A INPUT -s 0/0 -d 0/0 -p udp --dport 53 -j ACCEPT
10:#iptables -A INPUT -s 192.168.1.0/24 -d 0/0 -p udp --dport 4000 -j ACCEPT
11:#iptables -A INPUT -s 192.168.1.0/24 -d 0/0 -p tcp --dport 8080 --syn -j ACCEPT
12:#iptables -A INPUT -s 0/0 -d 0/0 -p tcp --dport 0:1023 --syn -j REJECT
13:#iptables -A INPUT -s 0/0 -d 0/0 -p tcp --dport 2049 --syn -j REJECT
14:#iptables -A INPUT -s 0/0 -d 0/0 -p udp --dport 0:1023 -j REJECT
15:#iptables -A INPUT -s 0/0 -d 0/0 -p udp --dport 2049 -j REJECT
16:#iptables -A INPUT -s 0/0 -d 0/0 -p tcp --dport 6000:6009 --syn -j REJECT
17:#iptables -A INPUT -s 0/0 -d 0/0 -p tcp --dport 7100 --syn -j REJECT
ความหมายแต่ละบรรทัด:
1.อนุญาตให้เครือข่ายภายใน ftp ไปยังปลายทางที่ไหนก็ได้
2.อนญาติให้เครือข่ายภายใน telnet ไปยังปลายทางที่ไหนก็ ได้
3.อนุญาตให้รับส่งเมล์ผ่าน smtp ได้ไม่ว่าจะเป็นต้นทางและปลายทางที่ไหน
4.อนุญาตให้ใช้เรียกใช้งาน เว็บได้ไม่ว่าจะเรียกจากที่ไหน และเรียกไปที่ไหนก็ได้
5.อนุญาตให้ mail client ของเครือข่ายภายในรับส่งเมล์ กับ mail server ที่ไหนก็ ได้ผ่าน POP3
6.อนุญาตให้ mail client ของเครือข่ายภายในรับส่งเมล์ กับ mail server ที่ไหนก็ ได้ผ่าน IMAP
7.อนุญาตให้ localhost สามารถใช้ imap ติดต่อกับ localhost ได้ เพื่อทำ webmail
8.อนุญาตให้เครือข่ายภายในใช้ https ได้
9.อนุญาตให้ใช้งาน DNS ได้ ไม่ว่าต้นทางและปลายทางอยู่ที่ไหน
10.อนุญาตให้เครือข่ายภายใน ใช้ ICQ ได้
11.ไม่ อนุญาตให้เครือข่ายที่นอกเหนือจากเครือข่ายภายในสามารถใช้งาน Proxy Server ได้
12.ไม่อนุญาตให้ใช้งาน tcp พอร์ต 0-1023 ไม่ว่าจะเป็นต้นทางและปลายทางที่ไหน
13.ไม่อนุญาตให้ใช้งาน tcp พอร์ต 2049 (NFS) ไม่ว่าจะเป็นต้นทางและปลายทาง ที่ไหน
14.ไม่อนุญาตให้ใช้งาน udp พอร์ต 0-1023 ไม่ว่าจะเป็นต้นทางและปลายทางที่ไหน
15.ไม่อนุญาตให้ใช้งาน udp พอร์ต 2049 (NFS) ไม่ว่าจะเป็นต้นทางและปลายทาง ที่ไหน
16.ไม่อนุญาตให้ใช้งาน tcp พอร์ต 6000-6009 (เป็น x11 สำหรับ X-windows) ไม่ว่าจะเป็นต้นทางและปลายทางที่ไหน
17.ไม่อนุญาตให้ใช้งาน tcp พอร์ต 7100 (X Font Service) ไม่ว่าจะเป็นต้นทางและปลายทางที่ไหน
1:#iptables -A INPUT -s 192.168.1.0/24 -d 0/0 -p tcp --dport 21 --syn -j ACCEPT
2:#iptables -A INPUT -s 192.168.1.0/24 -d 0/0 -p tcp --dport 23 --syn -j ACCEPT
3:#iptables -A INPUT -s 0/0 -d 0/0 -t tcp --dport 25 --syn -j ACCEPT
4:#iptables -A INPUT -s 0/0 -d 0/0 -p tcp --dport 80 --syn -j ACCEPT
5:#iptables -A INPUT -s 192.168.1.0/24 -d 0/0 -p tcp --dport 110 --syn -j ACCEPT
6:#iptables -A INPUT -s 192.168.1.0/24 -d 0/0 -p tcp --dport 143 --syn -j ACCEPT
7:#iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -p tcp --dport 143 --syn -j ACCETP
8:#iptables -A INPUT -s 192.168.1.0/24 -d 0/0 -p tcp --dport 443 --syn -j ACCEPT
9:#iptables -A INPUT -s 0/0 -d 0/0 -p udp --dport 53 -j ACCEPT
10:#iptables -A INPUT -s 192.168.1.0/24 -d 0/0 -p udp --dport 4000 -j ACCEPT
11:#iptables -A INPUT -s 192.168.1.0/24 -d 0/0 -p tcp --dport 8080 --syn -j ACCEPT
12:#iptables -A INPUT -s 0/0 -d 0/0 -p tcp --dport 0:1023 --syn -j REJECT
13:#iptables -A INPUT -s 0/0 -d 0/0 -p tcp --dport 2049 --syn -j REJECT
14:#iptables -A INPUT -s 0/0 -d 0/0 -p udp --dport 0:1023 -j REJECT
15:#iptables -A INPUT -s 0/0 -d 0/0 -p udp --dport 2049 -j REJECT
16:#iptables -A INPUT -s 0/0 -d 0/0 -p tcp --dport 6000:6009 --syn -j REJECT
17:#iptables -A INPUT -s 0/0 -d 0/0 -p tcp --dport 7100 --syn -j REJECT
ความหมายแต่ละบรรทัด:
1.อนุญาตให้เครือข่ายภายใน ftp ไปยังปลายทางที่ไหนก็ได้
2.อนญาติให้เครือข่ายภายใน telnet ไปยังปลายทางที่ไหนก็ ได้
3.อนุญาตให้รับส่งเมล์ผ่าน smtp ได้ไม่ว่าจะเป็นต้นทางและปลายทางที่ไหน
4.อนุญาตให้ใช้เรียกใช้งาน เว็บได้ไม่ว่าจะเรียกจากที่ไหน และเรียกไปที่ไหนก็ได้
5.อนุญาตให้ mail client ของเครือข่ายภายในรับส่งเมล์ กับ mail server ที่ไหนก็ ได้ผ่าน POP3
6.อนุญาตให้ mail client ของเครือข่ายภายในรับส่งเมล์ กับ mail server ที่ไหนก็ ได้ผ่าน IMAP
7.อนุญาตให้ localhost สามารถใช้ imap ติดต่อกับ localhost ได้ เพื่อทำ webmail
8.อนุญาตให้เครือข่ายภายในใช้ https ได้
9.อนุญาตให้ใช้งาน DNS ได้ ไม่ว่าต้นทางและปลายทางอยู่ที่ไหน
10.อนุญาตให้เครือข่ายภายใน ใช้ ICQ ได้
11.ไม่ อนุญาตให้เครือข่ายที่นอกเหนือจากเครือข่ายภายในสามารถใช้งาน Proxy Server ได้
12.ไม่อนุญาตให้ใช้งาน tcp พอร์ต 0-1023 ไม่ว่าจะเป็นต้นทางและปลายทางที่ไหน
13.ไม่อนุญาตให้ใช้งาน tcp พอร์ต 2049 (NFS) ไม่ว่าจะเป็นต้นทางและปลายทาง ที่ไหน
14.ไม่อนุญาตให้ใช้งาน udp พอร์ต 0-1023 ไม่ว่าจะเป็นต้นทางและปลายทางที่ไหน
15.ไม่อนุญาตให้ใช้งาน udp พอร์ต 2049 (NFS) ไม่ว่าจะเป็นต้นทางและปลายทาง ที่ไหน
16.ไม่อนุญาตให้ใช้งาน tcp พอร์ต 6000-6009 (เป็น x11 สำหรับ X-windows) ไม่ว่าจะเป็นต้นทางและปลายทางที่ไหน
17.ไม่อนุญาตให้ใช้งาน tcp พอร์ต 7100 (X Font Service) ไม่ว่าจะเป็นต้นทางและปลายทางที่ไหน
วันเสาร์ที่ 17 เมษายน พ.ศ. 2553
tip จากเวบ รวมพลคนรัก freebsd
tip จากเวบรวมพลคนรัก freebsd
Tips Tips เปิด Ports ที่เราต้องการใช้งานในระบบปฏิบัติการ FreeBSD
ตัวอย่าง ต้องการเปิดใช้งาน Ports 8443 ใช้คำสั่งดังนี้
# ipfw add 250 allow tcp from any to any dst-port 8443
หรือ
# ipfw add 250 allow udp from any to any dst-port 8443
--------------------------------------------------------------------------------
#/etc/rc.conf
firewall_enable="YES"
firewall_type="OPEN"
firewall_script="/etc/ipfw.rules"
firewall_quite="YES"
firewall_logging="YES"
++++++++++++++++++
#/etc/ipfw.rules
cmd="ipfw -q add"
ipfw -q -f flush
$cmd 05 allow all from any to any via lo0
$cmd 10 deny all from any to 127.0.0.0/8
$cmd 15 deny all from 127.0.0.0/8 to any
$cmd 20 deny tcp from any to any frag
$cmd 25 check-state
$cmd 30 allow tcp from any to any established
$cmd 35 allow all from any to any out keep-state
$cmd 40 allow icmp from any to any
$cmd 45 allow udp from any to any 21 in keep-state
$cmd 46 allow tcp from any to any 21 in setup keep-state
$cmd 50 allow tcp from any to any 22 in setup keep-state
$cmd 55 allow tcp from any to any 25 in setup keep-state
$cmd 60 allow udp from any to any 53 in keep-state
$cmd 61 allow tcp from any to any 53 in setup keep-state
$cmd 65 allow tcp from any to any 80 in setup keep-state
$cmd 70 allow tcp from any to any 443 in setup keep-state
$cmd 75 allow tcp from any to any 110 in setup keep-state
$cmd 80 allow tcp from any to any 143 in setup keep-state
$cmd 85 allow tcp from any to any 8080 in setup keep-state
$cmd 500 pass all from any to me limit src-addr 2
$cmd 999 deny log all from any to any
อีก tip
The following rules go into /etc/ipfw.rules.
################ Start of IPFW rules file ################################ Flush out the list before we begin.ipfw -q -f flush# Set rules command prefixcmd="ipfw -q add"pif="dc0" # public interface name of NIC # facing the public Internet################################################################## No restrictions on Inside LAN Interface for private network# Not needed unless you have LAN.# Change xl0 to your LAN NIC interface name##################################################################$cmd 00005 allow all from any to any via xl0################################################################## No restrictions on Loopback Interface#################################################################$cmd 00010 allow all from any to any via lo0################################################################## Allow the packet through if it has previous been added to the# the "dynamic" rules table by a allow keep-state statement.#################################################################$cmd 00015 check-state################################################################## Interface facing Public Internet (Outbound Section)# Interrogate session start requests originating from behind the# firewall on the private network or from this gateway server# destine for the public Internet.################################################################## Allow out access to my ISP's Domain name server.# x.x.x.x must be the IP address of your ISP.s DNS# Dup these lines if your ISP has more than one DNS server# Get the IP addresses from /etc/resolv.conf file$cmd 00110 allow tcp from any to x.x.x.x 53 out via $pif setup keep-state$cmd 00111 allow udp from any to x.x.x.x 53 out via $pif keep-state# Allow out access to my ISP's DHCP server for cable/DSL configurations.# This rule is not needed for .user ppp. connection to the public Internet.# so you can delete this whole group.# Use the following rule and check log for IP address.# Then put IP address in commented out rule & delete first rule$cmd 00120 allow log udp from any to any 67 out via $pif keep-state#$cmd 00120 allow udp from any to x.x.x.x 67 out via $pif keep-state# Allow out non-secure standard www function$cmd 00200 allow tcp from any to any 80 out via $pif setup keep-state# Allow out secure www function https over TLS SSL$cmd 00220 allow tcp from any to any 443 out via $pif setup keep-state# Allow out send & get email function$cmd 00230 allow tcp from any to any 25 out via $pif setup keep-state$cmd 00231 allow tcp from any to any 110 out via $pif setup keep-state# Allow out FBSD (make install & CVSUP) functions# Basically give user root "GOD" privileges.$cmd 00240 allow tcp from me to any out via $pif setup keep-state uid root# Allow out ping$cmd 00250 allow icmp from any to any out via $pif keep-state# Allow out Time$cmd 00260 allow tcp from any to any 37 out via $pif setup keep-state# Allow out nntp news (i.e. news groups)$cmd 00270 allow tcp from any to any 119 out via $pif setup keep-state# Allow out secure FTP, Telnet, and SCP# This function is using SSH (secure shell)$cmd 00280 allow tcp from any to any 22 out via $pif setup keep-state# Allow out whois$cmd 00290 allow tcp from any to any 43 out via $pif setup keep-state# deny and log everything else that.s trying to get out.# This rule enforces the block all by default logic.$cmd 00299 deny log all from any to any out via $pif################################################################## Interface facing Public Internet (Inbound Section)# Check packets originating from the public Internet# destined for this gateway server or the private network.################################################################## Deny all inbound traffic from non-routable reserved address spaces$cmd 00300 deny all from 192.168.0.0/16 to any in via $pif #RFC 1918 private IP$cmd 00301 deny all from 172.16.0.0/12 to any in via $pif #RFC 1918 private IP$cmd 00302 deny all from 10.0.0.0/8 to any in via $pif #RFC 1918 private IP$cmd 00303 deny all from 127.0.0.0/8 to any in via $pif #loopback$cmd 00304 deny all from 0.0.0.0/8 to any in via $pif #loopback$cmd 00305 deny all from 169.254.0.0/16 to any in via $pif #DHCP auto-config$cmd 00306 deny all from 192.0.2.0/24 to any in via $pif #reserved for docs$cmd 00307 deny all from 204.152.64.0/23 to any in via $pif #Sun cluster interconnect$cmd 00308 deny all from 224.0.0.0/3 to any in via $pif #Class D & E multicast# Deny public pings$cmd 00310 deny icmp from any to any in via $pif# Deny ident$cmd 00315 deny tcp from any to any 113 in via $pif# Deny all Netbios service. 137=name, 138=datagram, 139=session# Netbios is MS/Windows sharing services.# Block MS/Windows hosts2 name server requests 81$cmd 00320 deny tcp from any to any 137 in via $pif$cmd 00321 deny tcp from any to any 138 in via $pif$cmd 00322 deny tcp from any to any 139 in via $pif$cmd 00323 deny tcp from any to any 81 in via $pif# Deny any late arriving packets$cmd 00330 deny all from any to any frag in via $pif# Deny ACK packets that did not match the dynamic rule table$cmd 00332 deny tcp from any to any established in via $pif# Allow traffic in from ISP's DHCP server. This rule must contain# the IP address of your ISP.s DHCP server as it.s the only# authorized source to send this packet type.# Only necessary for cable or DSL configurations.# This rule is not needed for .user ppp. type connection to# the public Internet. This is the same IP address you captured# and used in the outbound section.#$cmd 00360 allow udp from any to x.x.x.x 67 in via $pif keep-state# Allow in standard www function because I have apache server$cmd 00400 allow tcp from any to me 80 in via $pif setup limit src-addr 2# Allow in secure FTP, Telnet, and SCP from public Internet$cmd 00410 allow tcp from any to me 22 in via $pif setup limit src-addr 2# Allow in non-secure Telnet session from public Internet# labeled non-secure because ID & PW are passed over public# Internet as clear text.# Delete this sample group if you do not have telnet server enabled.$cmd 00420 allow tcp from any to me 23 in via $pif setup limit src-addr 2# Reject & Log all incoming connections from the outside$cmd 00499 deny log all from any to any in via $pif# Everything else is denied by default# deny and log all packets that fell through to see what they are$cmd 00999 deny log all from any to any################ End of IPFW rules file ###############################--------------------------------------------------------------------------------ลอง netstat -an |grep LIST ดูนะครับว่ามี listen port ไหนอยู่บ้าง
netstat -na|grep tcp ดูเครื่องตัวเองว่าเปิด port อะไรไว้
sockstat -4
อีก tips
http://gotoknow.org/blog/patrickz/18859
msql ให้เป็นภาษาไทย
Tips Tips เปิด Ports ที่เราต้องการใช้งานในระบบปฏิบัติการ FreeBSD
ตัวอย่าง ต้องการเปิดใช้งาน Ports 8443 ใช้คำสั่งดังนี้
# ipfw add 250 allow tcp from any to any dst-port 8443
หรือ
# ipfw add 250 allow udp from any to any dst-port 8443
--------------------------------------------------------------------------------
#/etc/rc.conf
firewall_enable="YES"
firewall_type="OPEN"
firewall_script="/etc/ipfw.rules"
firewall_quite="YES"
firewall_logging="YES"
++++++++++++++++++
#/etc/ipfw.rules
cmd="ipfw -q add"
ipfw -q -f flush
$cmd 05 allow all from any to any via lo0
$cmd 10 deny all from any to 127.0.0.0/8
$cmd 15 deny all from 127.0.0.0/8 to any
$cmd 20 deny tcp from any to any frag
$cmd 25 check-state
$cmd 30 allow tcp from any to any established
$cmd 35 allow all from any to any out keep-state
$cmd 40 allow icmp from any to any
$cmd 45 allow udp from any to any 21 in keep-state
$cmd 46 allow tcp from any to any 21 in setup keep-state
$cmd 50 allow tcp from any to any 22 in setup keep-state
$cmd 55 allow tcp from any to any 25 in setup keep-state
$cmd 60 allow udp from any to any 53 in keep-state
$cmd 61 allow tcp from any to any 53 in setup keep-state
$cmd 65 allow tcp from any to any 80 in setup keep-state
$cmd 70 allow tcp from any to any 443 in setup keep-state
$cmd 75 allow tcp from any to any 110 in setup keep-state
$cmd 80 allow tcp from any to any 143 in setup keep-state
$cmd 85 allow tcp from any to any 8080 in setup keep-state
$cmd 500 pass all from any to me limit src-addr 2
$cmd 999 deny log all from any to any
อีก tip
The following rules go into /etc/ipfw.rules.
################ Start of IPFW rules file ################################ Flush out the list before we begin.ipfw -q -f flush# Set rules command prefixcmd="ipfw -q add"pif="dc0" # public interface name of NIC # facing the public Internet################################################################## No restrictions on Inside LAN Interface for private network# Not needed unless you have LAN.# Change xl0 to your LAN NIC interface name##################################################################$cmd 00005 allow all from any to any via xl0################################################################## No restrictions on Loopback Interface#################################################################$cmd 00010 allow all from any to any via lo0################################################################## Allow the packet through if it has previous been added to the# the "dynamic" rules table by a allow keep-state statement.#################################################################$cmd 00015 check-state################################################################## Interface facing Public Internet (Outbound Section)# Interrogate session start requests originating from behind the# firewall on the private network or from this gateway server# destine for the public Internet.################################################################## Allow out access to my ISP's Domain name server.# x.x.x.x must be the IP address of your ISP.s DNS# Dup these lines if your ISP has more than one DNS server# Get the IP addresses from /etc/resolv.conf file$cmd 00110 allow tcp from any to x.x.x.x 53 out via $pif setup keep-state$cmd 00111 allow udp from any to x.x.x.x 53 out via $pif keep-state# Allow out access to my ISP's DHCP server for cable/DSL configurations.# This rule is not needed for .user ppp. connection to the public Internet.# so you can delete this whole group.# Use the following rule and check log for IP address.# Then put IP address in commented out rule & delete first rule$cmd 00120 allow log udp from any to any 67 out via $pif keep-state#$cmd 00120 allow udp from any to x.x.x.x 67 out via $pif keep-state# Allow out non-secure standard www function$cmd 00200 allow tcp from any to any 80 out via $pif setup keep-state# Allow out secure www function https over TLS SSL$cmd 00220 allow tcp from any to any 443 out via $pif setup keep-state# Allow out send & get email function$cmd 00230 allow tcp from any to any 25 out via $pif setup keep-state$cmd 00231 allow tcp from any to any 110 out via $pif setup keep-state# Allow out FBSD (make install & CVSUP) functions# Basically give user root "GOD" privileges.$cmd 00240 allow tcp from me to any out via $pif setup keep-state uid root# Allow out ping$cmd 00250 allow icmp from any to any out via $pif keep-state# Allow out Time$cmd 00260 allow tcp from any to any 37 out via $pif setup keep-state# Allow out nntp news (i.e. news groups)$cmd 00270 allow tcp from any to any 119 out via $pif setup keep-state# Allow out secure FTP, Telnet, and SCP# This function is using SSH (secure shell)$cmd 00280 allow tcp from any to any 22 out via $pif setup keep-state# Allow out whois$cmd 00290 allow tcp from any to any 43 out via $pif setup keep-state# deny and log everything else that.s trying to get out.# This rule enforces the block all by default logic.$cmd 00299 deny log all from any to any out via $pif################################################################## Interface facing Public Internet (Inbound Section)# Check packets originating from the public Internet# destined for this gateway server or the private network.################################################################## Deny all inbound traffic from non-routable reserved address spaces$cmd 00300 deny all from 192.168.0.0/16 to any in via $pif #RFC 1918 private IP$cmd 00301 deny all from 172.16.0.0/12 to any in via $pif #RFC 1918 private IP$cmd 00302 deny all from 10.0.0.0/8 to any in via $pif #RFC 1918 private IP$cmd 00303 deny all from 127.0.0.0/8 to any in via $pif #loopback$cmd 00304 deny all from 0.0.0.0/8 to any in via $pif #loopback$cmd 00305 deny all from 169.254.0.0/16 to any in via $pif #DHCP auto-config$cmd 00306 deny all from 192.0.2.0/24 to any in via $pif #reserved for docs$cmd 00307 deny all from 204.152.64.0/23 to any in via $pif #Sun cluster interconnect$cmd 00308 deny all from 224.0.0.0/3 to any in via $pif #Class D & E multicast# Deny public pings$cmd 00310 deny icmp from any to any in via $pif# Deny ident$cmd 00315 deny tcp from any to any 113 in via $pif# Deny all Netbios service. 137=name, 138=datagram, 139=session# Netbios is MS/Windows sharing services.# Block MS/Windows hosts2 name server requests 81$cmd 00320 deny tcp from any to any 137 in via $pif$cmd 00321 deny tcp from any to any 138 in via $pif$cmd 00322 deny tcp from any to any 139 in via $pif$cmd 00323 deny tcp from any to any 81 in via $pif# Deny any late arriving packets$cmd 00330 deny all from any to any frag in via $pif# Deny ACK packets that did not match the dynamic rule table$cmd 00332 deny tcp from any to any established in via $pif# Allow traffic in from ISP's DHCP server. This rule must contain# the IP address of your ISP.s DHCP server as it.s the only# authorized source to send this packet type.# Only necessary for cable or DSL configurations.# This rule is not needed for .user ppp. type connection to# the public Internet. This is the same IP address you captured# and used in the outbound section.#$cmd 00360 allow udp from any to x.x.x.x 67 in via $pif keep-state# Allow in standard www function because I have apache server$cmd 00400 allow tcp from any to me 80 in via $pif setup limit src-addr 2# Allow in secure FTP, Telnet, and SCP from public Internet$cmd 00410 allow tcp from any to me 22 in via $pif setup limit src-addr 2# Allow in non-secure Telnet session from public Internet# labeled non-secure because ID & PW are passed over public# Internet as clear text.# Delete this sample group if you do not have telnet server enabled.$cmd 00420 allow tcp from any to me 23 in via $pif setup limit src-addr 2# Reject & Log all incoming connections from the outside$cmd 00499 deny log all from any to any in via $pif# Everything else is denied by default# deny and log all packets that fell through to see what they are$cmd 00999 deny log all from any to any################ End of IPFW rules file ###############################--------------------------------------------------------------------------------ลอง netstat -an |grep LIST ดูนะครับว่ามี listen port ไหนอยู่บ้าง
netstat -na|grep tcp ดูเครื่องตัวเองว่าเปิด port อะไรไว้
sockstat -4
อีก tips
http://gotoknow.org/blog/patrickz/18859
msql ให้เป็นภาษาไทย
วิธีแก้ให้เวบไม่ต้องมีตัวหนอนบน freebsd
บทความจากครูมานิส
แก้ไข httpd.conf ดังนี้
# pico /usr/local/etc/apache22/httpd.conf
กด Ctrl + w พิมพ์ DocumentRoot
เปลี่ยนเป็น
DocumentRoot "/home/"
ไปที่กลุ่มบรรทัด
AllowOverride None
Order deny,allow
Deny from all
แล้วเปลี่ยนใหม่เป็น
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
แทรกคำสั่ง
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
บันทึกไฟล์และออก
# /usr/local/sbin/apachectl restart
ลองเรียกเว็บ user ดูครับ เช่น
http://10.0.0.1/admin
ก็เรียกเว็บ user โดยไม่ต้องพิมพ์ http://10.0.0.1/~admin แล้วครับ และก็ไม่ต้องสร้างห้อง public_html ด้วย
ลองดูนะครับ สำหรับน้องใหม่ ที่กำลังหาคำตอบ
แก้ไข httpd.conf ดังนี้
# pico /usr/local/etc/apache22/httpd.conf
กด Ctrl + w พิมพ์ DocumentRoot
เปลี่ยนเป็น
DocumentRoot "/home/"
ไปที่กลุ่มบรรทัด
AllowOverride None
Order deny,allow
Deny from all
แล้วเปลี่ยนใหม่เป็น
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
แทรกคำสั่ง
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
บันทึกไฟล์และออก
# /usr/local/sbin/apachectl restart
ลองเรียกเว็บ user ดูครับ เช่น
http://10.0.0.1/admin
ก็เรียกเว็บ user โดยไม่ต้องพิมพ์ http://10.0.0.1/~admin แล้วครับ และก็ไม่ต้องสร้างห้อง public_html ด้วย
ลองดูนะครับ สำหรับน้องใหม่ ที่กำลังหาคำตอบ
วันพุธที่ 24 มีนาคม พ.ศ. 2553
ไฟล์วอลล์บน freebsd ตั้งแต่ 6.4 เป็นต้นไป
บทความจาก san แห่งเวบ thaibsd
#kldload ipfw.ko
ค่าดีฟอล์คจะบล๊อคหมดทุกพอร์ต
ตั้งแต่เวอร์ชั่น 6.4 ขึ้นไปสามารถ โหลดที่ kernel ได้เลยไม่ต้องคอมไล์เคอร์แนลก็ได้ ให้ไปใส่ค่า
firewall_enable="YES" ที่ rc.conf
#ee /etc/rc.conf
#### FIREWALL #####
firewall_enable="YES"
#firewall_type="/etc/myrules.conf" -->เขียนกฏไฟล์วอล์เพื่อควบคุม เปิดและปิดพอร์ตเฉพาะที่จะใช้งาน
firewall_type="OPEN"
firewall_quiet="YES"
firewall_logging="YES"
#### NAT #####
natd_enable="YES"
natd_flags="-s -u -m"
natd_interface="interface to nat"
#myrules.conf
ipfw add 100 divert 8668 ip4 from any to any via "nat interface" <--- เปิด NAT
ipfw add 200 allow ip from any to any via lo0
ipfw add 300 deny ip from any to 127.0.0.0/8
ipfw add 400 deny ip from 127.0.0.0/8 to any
ipfw add 500 allow me to any 80 <--WEB
ipfw add 500 allow any to me 22 <--SSH
#kldload ipfw.ko
ค่าดีฟอล์คจะบล๊อคหมดทุกพอร์ต
ตั้งแต่เวอร์ชั่น 6.4 ขึ้นไปสามารถ โหลดที่ kernel ได้เลยไม่ต้องคอมไล์เคอร์แนลก็ได้ ให้ไปใส่ค่า
firewall_enable="YES" ที่ rc.conf
#ee /etc/rc.conf
#### FIREWALL #####
firewall_enable="YES"
#firewall_type="/etc/myrules.conf" -->เขียนกฏไฟล์วอล์เพื่อควบคุม เปิดและปิดพอร์ตเฉพาะที่จะใช้งาน
firewall_type="OPEN"
firewall_quiet="YES"
firewall_logging="YES"
#### NAT #####
natd_enable="YES"
natd_flags="-s -u -m"
natd_interface="interface to nat"
#myrules.conf
ipfw add 100 divert 8668 ip4 from any to any via "nat interface" <--- เปิด NAT
ipfw add 200 allow ip from any to any via lo0
ipfw add 300 deny ip from any to 127.0.0.0/8
ipfw add 400 deny ip from 127.0.0.0/8 to any
ipfw add 500 allow me to any 80 <--WEB
ipfw add 500 allow any to me 22 <--SSH
แก้ไขปัญหา apache ล้มโดยใช้ squid ช่วย
บทความของท่าน yim แห่งเวบไทยบีเอสดี...เกี่ยวกับการทำsquid ช่วย apache ป้องกันเวบล้ม
กรณีทีเว็บมีโหลดมาก ๆ เรามีวิธีการง่าย ๆ ในการลดโหลด apapche ไม่ให้ทำงานหนักจนเกินไปจนเว็บล่ม
ขั้นแรกลง squid ตามปกติ ผมเลือกใช้ squid 2.6.STABLE23
ทำการคอมพาย
cd squid-2.6.STABLE23
--prefix=/usr --exec_prefix=/usr --bindir=/usr/sbin --sbindir=/usr/sbin --libexecdir=/usr/lib/squid --sysconfdir=/etc/squid --localstatedir=/var/spool/squid --datadir=/usr/share/squid --enable-async-io --with-pthreads --enable-storeio=ufs,aufs,diskd,null --enable-removal-policies=lru,heap --enable-snmp --enable-htcp --enable-cache-digests --enable-referer-log --enable-auth=basic,digest,ntlm --enable-carp --enable-follow-x-forwarded-for --with-large-files --enable-useragent-log --enable-ipf-transparent
make
make all
make install
เสร็จแล้ว squid.conf จะอยู่ที่ /etc/squid/squid.conf
แก้เป็น
offline_mode on
http_port 8888 transparent
icp_port 3130
#============================================================$
# LOGFILE PATHNAMES AND CACHE DIRECTORIES
#============================================================$
cache_dir diskd /data/cache 300 128 128 Q1=72 Q2=64
cache_mem 100 MB
cache_replacement_policy heap LFUDA
memory_replacement_policy heap GDSF
logformat TLOG %{%d-%m-%Y %H:%M:%S}tl %6tr %>a %Ss/%03Hs % cache_access_log /var/log/squid/access.log TLOG
cache_log /var/log/squid/cache.log
cache_store_log /var/log/squid/store.log
pid_filename /tmp/squid.pid
logfile_rotate 2
debug_options ALL,1
buffered_logs off
emulate_httpd_log off
#============================================================$
# FTP section
#============================================================$
ftp_user anonymous
ftp_list_width 32
ftp_passive on
ftp_sanitycheck on
#===================================================================$
#DEFAULT ACL
#===================================================================$
acl all src 0.0.0.0/0.0.0.0
#acl all src all
acl manager proto cache_object
acl localhost src 127.0.0.0/8
acl to_localhost dst 127.0.0.0/8
acl systemnetworkcare src 192.168.0.0/16 # RFC1918 possible internal network
acl reverse_tomcatapplication dst xxxxxx # แก้ xxx เป็น IPADDRESS SERVER
acl SSL_ports port 443 # https
acl SSL_ports port 563 # snews
acl SSL_ports port 873 # rsync
acl Safe_ports port 80 # http
acl Safe_ports port 81 # http
acl Safe_ports port 31 # http
acl Safe_ports port 32 # http
acl Safe_ports port 35 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl Safe_ports port 631 # cups
acl Safe_ports port 873 # rsync
acl Safe_ports port 901 # SWAT
acl SSL_ports port 8888 # https
acl CONNECT method CONNECT
acl SSL method CONNECT
miss_access allow all
http_access allow reverse_tomcatapplication
http_access allow all
miss_access allow reverse_tomcatapplication
http_reply_access allow all
never_direct allow SSL all
http_access allow all
http_access allow localhost
http_access allow to_localhost
http_access allow Safe_ports
http_access allow CONNECT SSL_ports
http_access allow systemnetworkcare
icp_access allow systemnetworkcare
icp_access allow all
acl QUERY urlpath_regex cgi-bin download files login member
cache deny QUERY
#============================================================$
# Parameter Administratif $
#============================================================$
cache_mgr admin@thaigqsoft.com
cache_effective_user nobody
cache_effective_group nobody
visible_hostname ICache
unique_hostname admin@thaigqsoft.com
#============================================================$
# SNMP
#============================================================$
quick_abort_min 0 KB
quick_abort_max 0 KB
quick_abort_pct 98
negative_ttl 3 minutes
positive_dns_ttl 53 seconds
negative_dns_ttl 29 seconds
forward_timeout 4 minutes
connect_timeout 2 minutes
peer_connect_timeout 1 minutes
pconn_timeout 120 seconds
shutdown_lifetime 10 seconds
read_timeout 15 minutes
client_lifetime 60 minutes
half_closed_clients off
อย่าลืมแก้ acl reverse_tomcatapplication dst xxxxxx เป็นไอพีเว็บ server
เสร็จแล้วใส่ ipfw
ipfw add 137 fwd 202.143.148.36,8888 tcp from any to 202.143.148.36 80 via fxp0
ipfw add 138 fwd 202.143.148.36,8888 tcp from 127.0.0.1 to any 80 via fxp0
ipfw add 139 fwd 202.143.148.36,80 tcp from any to 202.143.148.36 8888 via fxp0
fxp0 คือแลนที่แจกเว็บ
สามบรรทัดนี้จะกันไม่ให้คนอื่นมาแอบใช้ proxy เราโดยตรง
จบแล้วสั่งรัน squid
/usr/sbin/squid
ปล 202.143.148.36 คือไอพี เว็บ server
กรณีทีเว็บมีโหลดมาก ๆ เรามีวิธีการง่าย ๆ ในการลดโหลด apapche ไม่ให้ทำงานหนักจนเกินไปจนเว็บล่ม
ขั้นแรกลง squid ตามปกติ ผมเลือกใช้ squid 2.6.STABLE23
ทำการคอมพาย
cd squid-2.6.STABLE23
--prefix=/usr --exec_prefix=/usr --bindir=/usr/sbin --sbindir=/usr/sbin --libexecdir=/usr/lib/squid --sysconfdir=/etc/squid --localstatedir=/var/spool/squid --datadir=/usr/share/squid --enable-async-io --with-pthreads --enable-storeio=ufs,aufs,diskd,null --enable-removal-policies=lru,heap --enable-snmp --enable-htcp --enable-cache-digests --enable-referer-log --enable-auth=basic,digest,ntlm --enable-carp --enable-follow-x-forwarded-for --with-large-files --enable-useragent-log --enable-ipf-transparent
make
make all
make install
เสร็จแล้ว squid.conf จะอยู่ที่ /etc/squid/squid.conf
แก้เป็น
offline_mode on
http_port 8888 transparent
icp_port 3130
#============================================================$
# LOGFILE PATHNAMES AND CACHE DIRECTORIES
#============================================================$
cache_dir diskd /data/cache 300 128 128 Q1=72 Q2=64
cache_mem 100 MB
cache_replacement_policy heap LFUDA
memory_replacement_policy heap GDSF
logformat TLOG %{%d-%m-%Y %H:%M:%S}tl %6tr %>a %Ss/%03Hs %
cache_log /var/log/squid/cache.log
cache_store_log /var/log/squid/store.log
pid_filename /tmp/squid.pid
logfile_rotate 2
debug_options ALL,1
buffered_logs off
emulate_httpd_log off
#============================================================$
# FTP section
#============================================================$
ftp_user anonymous
ftp_list_width 32
ftp_passive on
ftp_sanitycheck on
#===================================================================$
#DEFAULT ACL
#===================================================================$
acl all src 0.0.0.0/0.0.0.0
#acl all src all
acl manager proto cache_object
acl localhost src 127.0.0.0/8
acl to_localhost dst 127.0.0.0/8
acl systemnetworkcare src 192.168.0.0/16 # RFC1918 possible internal network
acl reverse_tomcatapplication dst xxxxxx # แก้ xxx เป็น IPADDRESS SERVER
acl SSL_ports port 443 # https
acl SSL_ports port 563 # snews
acl SSL_ports port 873 # rsync
acl Safe_ports port 80 # http
acl Safe_ports port 81 # http
acl Safe_ports port 31 # http
acl Safe_ports port 32 # http
acl Safe_ports port 35 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl Safe_ports port 631 # cups
acl Safe_ports port 873 # rsync
acl Safe_ports port 901 # SWAT
acl SSL_ports port 8888 # https
acl CONNECT method CONNECT
acl SSL method CONNECT
miss_access allow all
http_access allow reverse_tomcatapplication
http_access allow all
miss_access allow reverse_tomcatapplication
http_reply_access allow all
never_direct allow SSL all
http_access allow all
http_access allow localhost
http_access allow to_localhost
http_access allow Safe_ports
http_access allow CONNECT SSL_ports
http_access allow systemnetworkcare
icp_access allow systemnetworkcare
icp_access allow all
acl QUERY urlpath_regex cgi-bin download files login member
cache deny QUERY
#============================================================$
# Parameter Administratif $
#============================================================$
cache_mgr admin@thaigqsoft.com
cache_effective_user nobody
cache_effective_group nobody
visible_hostname ICache
unique_hostname admin@thaigqsoft.com
#============================================================$
# SNMP
#============================================================$
quick_abort_min 0 KB
quick_abort_max 0 KB
quick_abort_pct 98
negative_ttl 3 minutes
positive_dns_ttl 53 seconds
negative_dns_ttl 29 seconds
forward_timeout 4 minutes
connect_timeout 2 minutes
peer_connect_timeout 1 minutes
pconn_timeout 120 seconds
shutdown_lifetime 10 seconds
read_timeout 15 minutes
client_lifetime 60 minutes
half_closed_clients off
อย่าลืมแก้ acl reverse_tomcatapplication dst xxxxxx เป็นไอพีเว็บ server
เสร็จแล้วใส่ ipfw
ipfw add 137 fwd 202.143.148.36,8888 tcp from any to 202.143.148.36 80 via fxp0
ipfw add 138 fwd 202.143.148.36,8888 tcp from 127.0.0.1 to any 80 via fxp0
ipfw add 139 fwd 202.143.148.36,80 tcp from any to 202.143.148.36 8888 via fxp0
fxp0 คือแลนที่แจกเว็บ
สามบรรทัดนี้จะกันไม่ให้คนอื่นมาแอบใช้ proxy เราโดยตรง
จบแล้วสั่งรัน squid
/usr/sbin/squid
ปล 202.143.148.36 คือไอพี เว็บ server
วันเสาร์ที่ 20 มีนาคม พ.ศ. 2553
ป้องกัน root ssh บน centos
บทความจากอินเตอร์เน็ตจำคนเขียนไม่ได้ขออภัยไม่ได้เอ่ยนามนะครับ..
วิธีการ Set SSH ไม่ให้ root login เข้ามา
วันนี้จะมาสอน security เบื้องต้นของ linux ฮับ
นั่นคือ การไม่ให้ Root Access เครื่องโดยตรง แต่ต้องผ่าน user คนอื่นก่อน
มาดูวิธีกันเลยดีกว่า
[root@valkyrie ~]# useradd
เพื่อสร้าง user ใหม่ครับ ใช้ในการที่เอาไว้ login ssh แทน root
[root@valkyrie ~]# passwd
ทีนี้ก็กำหนด Password ให้มันครับ (แนะนำให้คนละอันกับ root)
[root@valkyrie ~]# vi /etc/ssh/sshd_config
เข้าไปแก้ไข sshd_config ครับ
ตั้ง PermitRootLogin เป็น no
ซึ่งในตอนแรก มันจะปรับเป็น yes แล้ว comment ด้วย # ไว้ เอาออกด้วยนะครับ
แล้วเลื่อนลงมาล่างสุดครับ ให้พิมพ์บรรทัดนี้เพิ่มเข้าไป
AllowUsers
แล้ว save ไฟล์ ปิด ออกมานะครับ
ทีนี้ สั่ง service sshd restart เพื่อสั่งรี service sshd
ระหว่างนี้ ห้ามปิด SSH นี้ก่อนนะครับ เพราะเรายังไม่รู้ว่า config ที่เราใช้ มีปัญหาทำให้ login ไม่ได้หรือไม่
ถ้าไม่ทดสอบก่อน อาจจะต้องเดินไปแก้ไฟล์หน้าเครื่องได้นะครับ เพราะจะ ssh ไม่ได้อีกเลย
ดังนั้นให้เปิด terminal ssh เข้าไปยัง server อีกครั้งนะครับ แล้วลอง login ด้วย root ดู
จะพบว่า มัน login ไม่ได้
ให้ปิด terminal นั้นแล้วเปิด ssh ไปอีกหน้าหนึ่ง แล้วทดสอบ login ด้วย user ที่เราสร้างไปเมื่อตอนแรก
ถ้าได้ ก็ ok ครับ ฉลุย ผ่าน
ถ้าเราต้องการใช้สิทธิ Root
คือเนื่องจาก user ที่สร้างใหม่นั้น มันจะไม่มีสิทธิเทียบเท่า Root ดังนั้น วิธีการที่จะทำให้เราเข้าไปใน Root ได้ นั่นคือคำสั่ง
[newusers@valkyrie ~]$ su -
มันจะให้พิมพ์ password root เราก็พิมพ์ root
จบแล้วครับ ^^”
นี่ก็เป็น Security พื้นฐาน ในการทำ ssh นะครับ ลองๆเอาไปใช้ดูละกันครับ
วิธีการ Set SSH ไม่ให้ root login เข้ามา
วันนี้จะมาสอน security เบื้องต้นของ linux ฮับ
นั่นคือ การไม่ให้ Root Access เครื่องโดยตรง แต่ต้องผ่าน user คนอื่นก่อน
มาดูวิธีกันเลยดีกว่า
[root@valkyrie ~]# useradd
เพื่อสร้าง user ใหม่ครับ ใช้ในการที่เอาไว้ login ssh แทน root
[root@valkyrie ~]# passwd
ทีนี้ก็กำหนด Password ให้มันครับ (แนะนำให้คนละอันกับ root)
[root@valkyrie ~]# vi /etc/ssh/sshd_config
เข้าไปแก้ไข sshd_config ครับ
ตั้ง PermitRootLogin เป็น no
ซึ่งในตอนแรก มันจะปรับเป็น yes แล้ว comment ด้วย # ไว้ เอาออกด้วยนะครับ
แล้วเลื่อนลงมาล่างสุดครับ ให้พิมพ์บรรทัดนี้เพิ่มเข้าไป
AllowUsers
แล้ว save ไฟล์ ปิด ออกมานะครับ
ทีนี้ สั่ง service sshd restart เพื่อสั่งรี service sshd
ระหว่างนี้ ห้ามปิด SSH นี้ก่อนนะครับ เพราะเรายังไม่รู้ว่า config ที่เราใช้ มีปัญหาทำให้ login ไม่ได้หรือไม่
ถ้าไม่ทดสอบก่อน อาจจะต้องเดินไปแก้ไฟล์หน้าเครื่องได้นะครับ เพราะจะ ssh ไม่ได้อีกเลย
ดังนั้นให้เปิด terminal ssh เข้าไปยัง server อีกครั้งนะครับ แล้วลอง login ด้วย root ดู
จะพบว่า มัน login ไม่ได้
ให้ปิด terminal นั้นแล้วเปิด ssh ไปอีกหน้าหนึ่ง แล้วทดสอบ login ด้วย user ที่เราสร้างไปเมื่อตอนแรก
ถ้าได้ ก็ ok ครับ ฉลุย ผ่าน
ถ้าเราต้องการใช้สิทธิ Root
คือเนื่องจาก user ที่สร้างใหม่นั้น มันจะไม่มีสิทธิเทียบเท่า Root ดังนั้น วิธีการที่จะทำให้เราเข้าไปใน Root ได้ นั่นคือคำสั่ง
[newusers@valkyrie ~]$ su -
มันจะให้พิมพ์ password root เราก็พิมพ์ root
จบแล้วครับ ^^”
นี่ก็เป็น Security พื้นฐาน ในการทำ ssh นะครับ ลองๆเอาไปใช้ดูละกันครับ
วันศุกร์ที่ 19 มีนาคม พ.ศ. 2553
การแก้ไขระบบพังบน freebsd
บทความจาก mr.T แห่งเวบไทยบีเอสดี..ครับ
วันนี้เครื่อง server มีปัญหา ไม่สามารถใช้งานได้ เนื่องจากว่าไม่สามารถ Mount พาทิชั่นของระบบได้ ไปค้นหาวิธีแก้ ทำไปทำมาทำถูก เลยมาเขียนในกระทู้เพื่อเป็นแนวทางในการแก้ไขครับ
ระบบที่มีปัญหา
พอหลังจากที่รีบู๊ตแล้วจะเข้า single usr mode ซึ่งก็คือ
ระบบจะแจ้งประมาณดังนี้
Enter full pathname of shell or RETURN for /bin/sh:
พอเรากด Enter ระบบกดจะคืน Shell มาให้
#
เนื่องจากว่า / พาทิชั่นไม่สามารถ mount (/etc/fstab) ได้ จึงทำให้ไม่สามารถใช้คำสั่งใดๆ ได้ จากที่ค้นหาข้อมูลในเว็บบอร์ด มีเพียงคำแนะนำสั้นๆ
# mount -u / <---mount: not found
# mount -a <---mount: not found
#fsck -y
ระบบจะตอบกลับมาว่า mount: not found
จากในกรณีของผม
ที่ระบบตอบกลับมาว่าไม่เห็นคำสั่งนี้ เพราะ คำสั่ง mount อยู่ใน Path: /sbin/mount แต่เนื่องจากตอนนี้ระบบเราเสียหายไม่สามารถ mount พาทิชั่นใดๆได้ แม้แต่
Harddisk ที่ลงFreeBSDไว้ก็ถูกล๊อคเป็นแบบ Read Only
ls ดูจะเห็น เพียง / พาทิชั่น กับอีกพาทิชั่นนึง จำไม่ได้แล้ว จริงๆแล้ว / พาทิชั่นนี้ถูกโหลดจาก single user mode ซึ่งเป็นโหมดเอาไว้ Repair ระบบ มีคำสั่งที่จำเป็น
สำหรับใช้ Repair ระบบเท่านั้น ดังนั้น แนวทางแก้ไขคือ เราต้อง mount harddisk แบบแมนนวล
#cd /
#cd rescue <--ที่เก็บรวบรวมคำสั่งเอาไว้ Repair ระบบ
#/rescue/fsck -y /dev/ar0s1 <-- ให้ระบบมันซ่อมแซมตัวเองก่อน
#/rescue/mount /dev/ar0s1 <-- mount HDD ได้แล้ว
#/rescue/reboot
เสร็จแล้วครับ เราซ่อมแซมระบบเรียบร้อยแล้ว หลังจากรีบูต ระบบก็จะใช้งานได้ตามปรกติ
วันนี้เครื่อง server มีปัญหา ไม่สามารถใช้งานได้ เนื่องจากว่าไม่สามารถ Mount พาทิชั่นของระบบได้ ไปค้นหาวิธีแก้ ทำไปทำมาทำถูก เลยมาเขียนในกระทู้เพื่อเป็นแนวทางในการแก้ไขครับ
ระบบที่มีปัญหา
พอหลังจากที่รีบู๊ตแล้วจะเข้า single usr mode ซึ่งก็คือ
ระบบจะแจ้งประมาณดังนี้
Enter full pathname of shell or RETURN for /bin/sh:
พอเรากด Enter ระบบกดจะคืน Shell มาให้
#
เนื่องจากว่า / พาทิชั่นไม่สามารถ mount (/etc/fstab) ได้ จึงทำให้ไม่สามารถใช้คำสั่งใดๆ ได้ จากที่ค้นหาข้อมูลในเว็บบอร์ด มีเพียงคำแนะนำสั้นๆ
# mount -u / <---mount: not found
# mount -a <---mount: not found
#fsck -y
ระบบจะตอบกลับมาว่า mount: not found
จากในกรณีของผม
ที่ระบบตอบกลับมาว่าไม่เห็นคำสั่งนี้ เพราะ คำสั่ง mount อยู่ใน Path: /sbin/mount แต่เนื่องจากตอนนี้ระบบเราเสียหายไม่สามารถ mount พาทิชั่นใดๆได้ แม้แต่
Harddisk ที่ลงFreeBSDไว้ก็ถูกล๊อคเป็นแบบ Read Only
ls ดูจะเห็น เพียง / พาทิชั่น กับอีกพาทิชั่นนึง จำไม่ได้แล้ว จริงๆแล้ว / พาทิชั่นนี้ถูกโหลดจาก single user mode ซึ่งเป็นโหมดเอาไว้ Repair ระบบ มีคำสั่งที่จำเป็น
สำหรับใช้ Repair ระบบเท่านั้น ดังนั้น แนวทางแก้ไขคือ เราต้อง mount harddisk แบบแมนนวล
#cd /
#cd rescue <--ที่เก็บรวบรวมคำสั่งเอาไว้ Repair ระบบ
#/rescue/fsck -y /dev/ar0s1 <-- ให้ระบบมันซ่อมแซมตัวเองก่อน
#/rescue/mount /dev/ar0s1 <-- mount HDD ได้แล้ว
#/rescue/reboot
เสร็จแล้วครับ เราซ่อมแซมระบบเรียบร้อยแล้ว หลังจากรีบูต ระบบก็จะใช้งานได้ตามปรกติ
วันอังคารที่ 2 กุมภาพันธ์ พ.ศ. 2553
บทความอ.กิตติพงษ์ แห่ง www.thaibsd.com
โปรแกรม axel เป็นเครื่องมือที่ใช้ในการ download file จาก URL ที่เราต้องการซึ่งจะเป็นโปรแกรมที่มีความเร็วมากกว่า wget , fetch หลายเท่าตัว หากเปรียบกับ Win ก็ประมาณ flashget และมีจุดเด่นคือ สามารถ download ต่อจากจุดที่ทำงานเสร็จก่อนหน้านี้ได้
cd /usr/ports/ftp/axel
make install
rehash
การใช้งาน axel
axel
edit /etc/make.conf
insert
FETCH_CMD = /usr/local/bin/axel
มันจะใช้ axel แทน fetch ไวเร็วดุจนรก
โปรแกรม axel เป็นเครื่องมือที่ใช้ในการ download file จาก URL ที่เราต้องการซึ่งจะเป็นโปรแกรมที่มีความเร็วมากกว่า wget , fetch หลายเท่าตัว หากเปรียบกับ Win ก็ประมาณ flashget และมีจุดเด่นคือ สามารถ download ต่อจากจุดที่ทำงานเสร็จก่อนหน้านี้ได้
cd /usr/ports/ftp/axel
make install
rehash
การใช้งาน axel
axel
edit /etc/make.conf
insert
FETCH_CMD = /usr/local/bin/axel
มันจะใช้ axel แทน fetch ไวเร็วดุจนรก
วันศุกร์ที่ 6 พฤศจิกายน พ.ศ. 2552
คำสั่งติดตั้ง ntop
บทความ โดย itdekd แห่งเวบไซด์ freebsd
ntop คือ เครื่องมือที่ใช้ในการมอนิเตอร์และแก้ปัญหาระบบเครือข่าย สามารถวิเคราะห์ปัญหาของทราฟฟิกที่ช้าลงได้ ว่าเกิดจากสาเหตุใดโดยจะแสดงผลผ่านบราวเซอร์ ( ผมว่าคล้ายๆ MTRG แต่ผมว่าดีกว่าน่ะ ในความคิดเห็นของผมน่ะ )
วิธีการติดตั้ง ( ห้าม อัพเดท ports น่ะ ไม่งั้นมันจะ error ไม่รู้ว่าเป็นอ่ะไรเหมือนกัน แก้ไม่หายด้วยอ่ะ ถ้าใครรู้ว่าแก้ยังไงก็บอกด้วยล่ะกัน)
ขั้นแรกติดตั้ง GD ก่อน
# cd /usr/ports/graphics/gd
# make WITH_XPM=yes install clean
ขั้นที่สองติดตั้ง ntop
# cd /usr/ports/net/ntop && make install clean
รอประมาณ 1ชั่วโมง
คำสั้งรัน ntop
# chmod 555 /usr/local/etc/rc.d/ntop
ทำการเซตอัพ Admin password
# /usr/local/bin/ntop -u nobody -A
ทำการสั่งรัน ntop ผ่านเชล์สคริปต์
#/usr/local/etc/rc.d/ntop start
แก้ไขไฟล์ rc.conf
เพิ่มคำสั้ง ntop_enable="YES"
แล้ว reboot เครื่อง
การใช้งาน
http://xxx.xxx.xx.xx:3000(xxx.xxx.xx.xx คือไอพี หรือชื่อเว็บน่ะครับ ) ถ้าไม่ได้ยังไงถามได้น่ะครับ กว่าจะได้ 1 อาทิตย์ เต็มๆๆ
บน linux ก็ตามนี้ครับ
http://www.msit.mut.ac.th/newweb/phpfile/show.php?Qid=4936
ntop คือ เครื่องมือที่ใช้ในการมอนิเตอร์และแก้ปัญหาระบบเครือข่าย สามารถวิเคราะห์ปัญหาของทราฟฟิกที่ช้าลงได้ ว่าเกิดจากสาเหตุใดโดยจะแสดงผลผ่านบราวเซอร์ ( ผมว่าคล้ายๆ MTRG แต่ผมว่าดีกว่าน่ะ ในความคิดเห็นของผมน่ะ )
วิธีการติดตั้ง ( ห้าม อัพเดท ports น่ะ ไม่งั้นมันจะ error ไม่รู้ว่าเป็นอ่ะไรเหมือนกัน แก้ไม่หายด้วยอ่ะ ถ้าใครรู้ว่าแก้ยังไงก็บอกด้วยล่ะกัน)
ขั้นแรกติดตั้ง GD ก่อน
# cd /usr/ports/graphics/gd
# make WITH_XPM=yes install clean
ขั้นที่สองติดตั้ง ntop
# cd /usr/ports/net/ntop && make install clean
รอประมาณ 1ชั่วโมง
คำสั้งรัน ntop
# chmod 555 /usr/local/etc/rc.d/ntop
ทำการเซตอัพ Admin password
# /usr/local/bin/ntop -u nobody -A
ทำการสั่งรัน ntop ผ่านเชล์สคริปต์
#/usr/local/etc/rc.d/ntop start
แก้ไขไฟล์ rc.conf
เพิ่มคำสั้ง ntop_enable="YES"
แล้ว reboot เครื่อง
การใช้งาน
http://xxx.xxx.xx.xx:3000(xxx.xxx.xx.xx คือไอพี หรือชื่อเว็บน่ะครับ ) ถ้าไม่ได้ยังไงถามได้น่ะครับ กว่าจะได้ 1 อาทิตย์ เต็มๆๆ
บน linux ก็ตามนี้ครับ
http://www.msit.mut.ac.th/newweb/phpfile/show.php?Qid=4936
วันศุกร์ที่ 18 กันยายน พ.ศ. 2552
แก้ยูเซอร์ค้างในระบบอย่างถาวร..จากเวบ linuxthai.org
เครดิตท่าน koko2330 แห่งเวบ www.linuxthai.org
vi /usr/local/etc/radiusd.conf
บรรทัดที่ ~2003
#
# Accounting. Log the accounting data.
#
accounting {
#
# Create a 'detail'ed log of the packets.
# Note that accounting requests which are proxied
# are also logged in the detail file.
detail
# daily
# Update the wtmp file
#
# If you don't use "radlast", you can delete this line.
# unix
#
# For Simultaneous-Use tracking.
#
# Due to packet losses in the network, the data here
# may be incorrect. There is little we can do about it.
# radutmp
# sradutmp
# Return an address to the IP Pool when we see a stop record.
# main_pool
# sqlippool
#
# Log traffic to an SQL database.
#
# See "Accounting queries" in sql.conf
sql
#
# Instead of sending the query to the SQL server,
# write it into a log file.
#
# sql_log
# Cisco VoIP specific bulk accounting
# pgsql-voip
}
แค่นี้ ข้อมูล User ก็จะไม่เก็บไว้ใน Text File แต่จะเก็บไว้ใน Mysql ที่ เวลา = 0000-00-00 00:00:00 หมายถึงเวลของคนที่ออนไลน์
แล้วสร้างไฟล์ xxx.php ให้มีเนื้อหาตามนี้
โค๊ด:
ob_start();
include("include/class.mysqldb.php");
include("include/config.inc.php");
$uday = date("Y-m-d");
$sql2 = "SELECT * from radacct where AcctStopTime = '0000-00-00 00:00:00'";
$result2 = mysql_query($sql2);
while($data = mysql_fetch_object($result2)) {
$user = $data->UserName;
passthru("/bin/echo 'User-Name = $user' | /usr/local/bin/radclient -x localhost:3799 disconnect testing123");
$sql = "UPDATE radacct SET AcctStopTime='$uday 00:00:00' where ((AcctStopTime = '0000-00-00 00:00:00') and (UserName='$usus'))";
$result = mysql_query($sql);
}
$sql3 = "DELETE from radacct where AcctStopTime = '0000-00-00 00:00:00'";
$result3 = mysql_query($sql3);
exit();
?>
vi /usr/local/etc/radiusd.conf
บรรทัดที่ ~2003
#
# Accounting. Log the accounting data.
#
accounting {
#
# Create a 'detail'ed log of the packets.
# Note that accounting requests which are proxied
# are also logged in the detail file.
detail
# daily
# Update the wtmp file
#
# If you don't use "radlast", you can delete this line.
# unix
#
# For Simultaneous-Use tracking.
#
# Due to packet losses in the network, the data here
# may be incorrect. There is little we can do about it.
# radutmp
# sradutmp
# Return an address to the IP Pool when we see a stop record.
# main_pool
# sqlippool
#
# Log traffic to an SQL database.
#
# See "Accounting queries" in sql.conf
sql
#
# Instead of sending the query to the SQL server,
# write it into a log file.
#
# sql_log
# Cisco VoIP specific bulk accounting
# pgsql-voip
}
แค่นี้ ข้อมูล User ก็จะไม่เก็บไว้ใน Text File แต่จะเก็บไว้ใน Mysql ที่ เวลา = 0000-00-00 00:00:00 หมายถึงเวลของคนที่ออนไลน์
แล้วสร้างไฟล์ xxx.php ให้มีเนื้อหาตามนี้
โค๊ด:
ob_start();
include("include/class.mysqldb.php");
include("include/config.inc.php");
$uday = date("Y-m-d");
$sql2 = "SELECT * from radacct where AcctStopTime = '0000-00-00 00:00:00'";
$result2 = mysql_query($sql2);
while($data = mysql_fetch_object($result2)) {
$user = $data->UserName;
passthru("/bin/echo 'User-Name = $user' | /usr/local/bin/radclient -x localhost:3799 disconnect testing123");
$sql = "UPDATE radacct SET AcctStopTime='$uday 00:00:00' where ((AcctStopTime = '0000-00-00 00:00:00') and (UserName='$usus'))";
$result = mysql_query($sql);
}
$sql3 = "DELETE from radacct where AcctStopTime = '0000-00-00 00:00:00'";
$result3 = mysql_query($sql3);
exit();
?>
ปรับแก้ม.บูรพาเพื่อคุม upload/download
Bandwidth ทะลุของม.บูรพาปรับให้สามารถคุมอัพโหลดดาว์นโหลดได้ จากเวบ linuxthai.org
ใน file manage_group.php มันมีบางที่ *1024*8 จริง ๆ แค่ *1024 ก็พอ (รึเปล่า ฮืม)
if($newdown != 0) {
$down = $newdown * 1024 * 8;
$sql = "insert into radgroupreply values ('', 'group".$_REQUEST['newgname']."', 'WISPr-Bandwidth-Max-Down', ':=', '$down')";
มันมี *8 มาด้วย
ทำให้เวลาบันทึกลง Database ค่ามันเลยสูงครับ
เช่น กำหนด Download 512 = 512*1024*8 = 4,194,304
512 = 512*1024 = 524,288 (ค่าที่ถูกต้อง)
ลองแล้ว Bandwidth Download ไม่ทะลุแล้วครับ
แต่ upload ทะลุอยู่ครั
ใน file manage_group.php มันมีบางที่ *1024*8 จริง ๆ แค่ *1024 ก็พอ (รึเปล่า ฮืม)
if($newdown != 0) {
$down = $newdown * 1024 * 8;
$sql = "insert into radgroupreply values ('', 'group".$_REQUEST['newgname']."', 'WISPr-Bandwidth-Max-Down', ':=', '$down')";
มันมี *8 มาด้วย
ทำให้เวลาบันทึกลง Database ค่ามันเลยสูงครับ
เช่น กำหนด Download 512 = 512*1024*8 = 4,194,304
512 = 512*1024 = 524,288 (ค่าที่ถูกต้อง)
ลองแล้ว Bandwidth Download ไม่ทะลุแล้วครับ
แต่ upload ทะลุอยู่ครั
วันจันทร์ที่ 10 สิงหาคม พ.ศ. 2552
squid block เป็นเวลา
ทิปจากท่าน yim และครูมานิสแห่ง thaibsd.com
แก้ไขไฟล์
# nano /usr/local/etc/squid/squid.conf ค้นหาบรรทัด bsex
แล้วแก้ไขคำสั่งการ Blockweb ใหม่ ดังนี้
#blockweb จันทร์-ศุกร์ ช่วงเวลา 08.00 - 17.00 น.
acl time_block time M T W H F 08:00-17:00
#blockweb เสาร์-อาทิตย์ ช่วงเวลา 08.00 - 14.00 น.
acl time_block time A S 08:00-14:00
#blockweb ต่ออีก วันเสาร์-อาทิตย์ ช่วงเวลา 18.10 - 21.10 น.
acl time_block time A S 18:10-21:10
acl bsex url_regex "/usr/local/etc/squid/bsex.txt"
http_access deny bsex time_block
deny_infohttp://www.google.co.thbsex time_block
คงเป็นประโยชน์ สำหรับร้านอินเตอร์เน็ต ที่มีจรรยาบรรณ ให้เล่นเกมส์ออนไลน์ เป็นช่วงเวลา จะได้ไม่มอมเมาเยาวชน ร่วมด้วยช่วยกันครับ
แก้ไขไฟล์
# nano /usr/local/etc/squid/squid.conf ค้นหาบรรทัด bsex
แล้วแก้ไขคำสั่งการ Blockweb ใหม่ ดังนี้
#blockweb จันทร์-ศุกร์ ช่วงเวลา 08.00 - 17.00 น.
acl time_block time M T W H F 08:00-17:00
#blockweb เสาร์-อาทิตย์ ช่วงเวลา 08.00 - 14.00 น.
acl time_block time A S 08:00-14:00
#blockweb ต่ออีก วันเสาร์-อาทิตย์ ช่วงเวลา 18.10 - 21.10 น.
acl time_block time A S 18:10-21:10
acl bsex url_regex "/usr/local/etc/squid/bsex.txt"
http_access deny bsex time_block
deny_infohttp://www.google.co.thbsex time_block
คงเป็นประโยชน์ สำหรับร้านอินเตอร์เน็ต ที่มีจรรยาบรรณ ให้เล่นเกมส์ออนไลน์ เป็นช่วงเวลา จะได้ไม่มอมเมาเยาวชน ร่วมด้วยช่วยกันครับ
วันอังคารที่ 30 มิถุนายน พ.ศ. 2552
การทำ by pass authen สำหรับเจ้านายขี้หงุดหงิด
กรณีที่เราจัดทำ server เพื่อทำ authentification แล้วเกิดเจ้านาย..ไม่อยาก authen ก็สามารถ bypass ได้โดยแก้ไขไฟล์
chilli.conf
# MAC authentication
macauth
# TAG: macpasswd
macpasswd password
จากนั้น เพิ่ม User ในฐานข้อมูล โดย User Name : MacAddress ของเครื่องที่ต้องการ
โดยรูปแบบต้องเป็นแบบนี้นะครับ 00-1D-E0-9B-78-81
ส่วน PassWord ก็ใส่เป็น password
จากนั้นพอเครื่องที่กำหนดเปิดปุ๊บ ได้รับ IP ก็ใช้เน็ตได้เลยครับ
tip จากท่าน starcrafe แห่ง www.thaibsd.com
chilli.conf
# MAC authentication
macauth
# TAG: macpasswd
macpasswd password
จากนั้น เพิ่ม User ในฐานข้อมูล โดย User Name : MacAddress ของเครื่องที่ต้องการ
โดยรูปแบบต้องเป็นแบบนี้นะครับ 00-1D-E0-9B-78-81
ส่วน PassWord ก็ใส่เป็น password
จากนั้นพอเครื่องที่กำหนดเปิดปุ๊บ ได้รับ IP ก็ใช้เน็ตได้เลยครับ
tip จากท่าน starcrafe แห่ง www.thaibsd.com
วันอาทิตย์ที่ 21 มิถุนายน พ.ศ. 2552
อบรม web conference ที่นนทบุรี
วันที่ 18-19 มิถุนายน 2552 ได้ไปอบรม web conference ที่โรงแรมโกล์เด้น ดราก้อน นนทบุรี..
ทดลองประชุมผ่าน web conference และผ่านอุปกรณ์ mcu และหลาย ๆ ช่องทางเพื่อเตรียมประชุมผ่านระบบ conference
ถึงแม้ที่ทำงานของเรา (ขาดอีก 67 เขตที่ยังไม่มีกล้อง conference ราคาเกือบสามแสน คงใช้ webcam หรือ กล้องวีดีโอไปก่อน)
ก็ผ่านการอบรมไม่ประสบผลสำเร็จมากนักเนื่องจาก แบนวิธอินเตอร์เน็ตของโรงแรมมีปัญหาเข้าระบบได้ช้ามาก ได้ไม่กี่ site เอง
วันเสาร์ที่ 13 มิถุนายน พ.ศ. 2552
popup มีรูปโชว์
กรณีไม่โชว์รูป..มีสองกรณีคือ..หากไม่ใช้ cert ต้องเอา setcookie ไฟล์
hotspotlogin.php กับ hotspotlogin_popup.php
ให้เหลือแค่ setcookie('username', $name, $expire);
กรณีต้องการโชว์รูปให้ตั้งชื่อรูปเป็นขื่อ login ของ ยูเซอร์ นามสกุล .jpg ครับ.
กรณี httpd.conf ของ server ตั้ง AddDefaultChaset utf-8,tis-620 จะขึ้น error ให้เอา tis-620 ออกก่อนจะสามารถใช้ได้ครับ..
วันศุกร์ที่ 29 พฤษภาคม พ.ศ. 2552
iftop เช็ค แบนวิธ
จอมยุทธ์น้อย
Sex :
Post : 444
สมาชิกลำดับที่ : 278
วันนี้ ผมมานำเสนอโปรแกรม traffic mornitor สำหรับ terminal ตามคำสัญญาที่ให้ไว้กับ อ.กิตติพงษ์ นะครับ
โปรแกรมนั้นมีชื่อว่า iftop
วิธีการติดตั้งนั้นก็แสนง่าย
#cd /usr/ports/net-mgmt/iftop
#make install clean
#rehash
เสร็แล้วสั่ง
#iftop -P -B <ย้ำว่าต้องเป็น root เท่านั้นจึงจะดูได้>
ส่วนการทำงานของมันนั้นมันจะรายงานว่า ขณะนี้ เครื่อง ip ใด ติดต่อกับ เครื่องเราอยู่
และport อะไรจะดีมาก ๆ สำหรับเครื่องที่เป็น gateway และสำนักงานใหญ่ ๆ ที่มีเครื่องติดไวรัสแต่
ไม่สามารถทำอะไรได้อย่างผม
จะไปฆ่าให้ก็ไม่เอา บอกให้ไป ลง windows ใหม่บอกไม่มีเงิน
- -" เอาน่า เราก็ จัดการ block ip นั้นเป็นการสั่งสอนไปพลาง ๆ ถ้าเค้าใช้ internet ไม่ได้นาน ๆ
ก็ จะยอมเองแหละ อิอิ
ประการสำคัญ
โปรแกรมเนี้ย มันดูได้ อีกว่า ใครทำอะไร กับ อะไรอยู่ นะ คงไม่ต้องอธิบายมาก
ส่วน option ต่าง ๆ ก็มีดังนี้
Host display: General:
n - toggle DNS host resolution P - pause display
s - toggle show source host h - toggle this help display
d - toggle show destination host b - toggle bar graph display
t - cycle line display mode B - cycle bar graph average
T - toggle cummulative line totals
Port display: j/k - scroll display
N - toggle service resolution f - edit filter code
S - toggle show source port l - set screen filter
D - toggle show destination port L - lin/log scales
p - toggle port display ! - shell command
q - quit
Sorting:
1/2/3 - sort by 1st/2nd/3rd column
< - sort by source name
> - sort by dest name
o - freeze current order
ถ้าเครื่องมี cardlan 2 ตัว
ในกรณีที่เราสั่ง #iftop -P -B มันจะแสดงค่าของ CardLan ตัวแรก
อย่างของผมคือ bge0
แล้วทีนี้ถามว่าถ้าอยากดูของ bge1 ล่ะ ?
เราก็ สั่งว่า
#iftop -P -B -i bge1
แค่นั้นแหละฮะ เอามาฝาก เผื่อใครปวดหัวกะ virus รึ การไล่ block web
Sex :
Post : 444
สมาชิกลำดับที่ : 278
วันนี้ ผมมานำเสนอโปรแกรม traffic mornitor สำหรับ terminal ตามคำสัญญาที่ให้ไว้กับ อ.กิตติพงษ์ นะครับ
โปรแกรมนั้นมีชื่อว่า iftop
วิธีการติดตั้งนั้นก็แสนง่าย
#cd /usr/ports/net-mgmt/iftop
#make install clean
#rehash
เสร็แล้วสั่ง
#iftop -P -B <ย้ำว่าต้องเป็น root เท่านั้นจึงจะดูได้>
ส่วนการทำงานของมันนั้นมันจะรายงานว่า ขณะนี้ เครื่อง ip ใด ติดต่อกับ เครื่องเราอยู่
และport อะไรจะดีมาก ๆ สำหรับเครื่องที่เป็น gateway และสำนักงานใหญ่ ๆ ที่มีเครื่องติดไวรัสแต่
ไม่สามารถทำอะไรได้อย่างผม
จะไปฆ่าให้ก็ไม่เอา บอกให้ไป ลง windows ใหม่บอกไม่มีเงิน
- -" เอาน่า เราก็ จัดการ block ip นั้นเป็นการสั่งสอนไปพลาง ๆ ถ้าเค้าใช้ internet ไม่ได้นาน ๆ
ก็ จะยอมเองแหละ อิอิ
ประการสำคัญ
โปรแกรมเนี้ย มันดูได้ อีกว่า ใครทำอะไร กับ อะไรอยู่ นะ คงไม่ต้องอธิบายมาก
ส่วน option ต่าง ๆ ก็มีดังนี้
Host display: General:
n - toggle DNS host resolution P - pause display
s - toggle show source host h - toggle this help display
d - toggle show destination host b - toggle bar graph display
t - cycle line display mode B - cycle bar graph average
T - toggle cummulative line totals
Port display: j/k - scroll display
N - toggle service resolution f - edit filter code
S - toggle show source port l - set screen filter
D - toggle show destination port L - lin/log scales
p - toggle port display ! - shell command
q - quit
Sorting:
1/2/3 - sort by 1st/2nd/3rd column
< - sort by source name
> - sort by dest name
o - freeze current order
ถ้าเครื่องมี cardlan 2 ตัว
ในกรณีที่เราสั่ง #iftop -P -B มันจะแสดงค่าของ CardLan ตัวแรก
อย่างของผมคือ bge0
แล้วทีนี้ถามว่าถ้าอยากดูของ bge1 ล่ะ ?
เราก็ สั่งว่า
#iftop -P -B -i bge1
แค่นั้นแหละฮะ เอามาฝาก เผื่อใครปวดหัวกะ virus รึ การไล่ block web
วันอังคารที่ 5 พฤษภาคม พ.ศ. 2552
ดีดยูเซอร์ออกทันที
# echo User-Name=user1 | radclient -x 127.0.0.1:3779 disconnect wifi
อธิบาย user1 คือ user ที่ต้องการถีบออกให้หลุดเลย
wifi คือ radiussecret
chmod 777 ไฟล์ radclient ด้วย
อธิบาย user1 คือ user ที่ต้องการถีบออกให้หลุดเลย
wifi คือ radiussecret
chmod 777 ไฟล์ radclient ด้วย
วันพฤหัสบดีที่ 9 เมษายน พ.ศ. 2552
ลบยูเซอร์ในม.บูรพาโดยลบในฐานข้อมูลไปด้วย
manage_user.php
หาบรรทัด " case 'delete' " ลองอ่านดูล่างมานิดจะเห็นว่าเวลาลบ user แล้วมันไม่ไปลบใน table account ให้คุณเพิ่มลงไปเองนะครับ
(สีแดงคือบรรทัดที่คุณต้องเพิ่มนะครับ) รอบหน้าคุณจะได้ไม่ต้องไปลบเองใน db
case 'delete' :
$sql = "DELETE FROM radcheck where UserName = '".$_REQUEST['user']."'";
mysql_query($sql);
$sql = "DELETE FROM usergroup where UserName = '".$_REQUEST['user']."'";
mysql_query($sql);
เพิ่มสองบรรทัดนี้แทรกเข้าไป....................
$sql = "DELETE FROM account where UserName = '".$_REQUEST['user']."'";
mysql_query($sql);
$sql = "update account set status = '-1' where username = '".$_REQUEST['user']."'";
mysql_query($sql);
$message = "ลบผู้ใช้ที่ต้องการออกจากระบบเรียบร้อยแล้ว";
break;
หาบรรทัด " case 'delete' " ลองอ่านดูล่างมานิดจะเห็นว่าเวลาลบ user แล้วมันไม่ไปลบใน table account ให้คุณเพิ่มลงไปเองนะครับ
(สีแดงคือบรรทัดที่คุณต้องเพิ่มนะครับ) รอบหน้าคุณจะได้ไม่ต้องไปลบเองใน db
case 'delete' :
$sql = "DELETE FROM radcheck where UserName = '".$_REQUEST['user']."'";
mysql_query($sql);
$sql = "DELETE FROM usergroup where UserName = '".$_REQUEST['user']."'";
mysql_query($sql);
เพิ่มสองบรรทัดนี้แทรกเข้าไป....................
$sql = "DELETE FROM account where UserName = '".$_REQUEST['user']."'";
mysql_query($sql);
$sql = "update account set status = '-1' where username = '".$_REQUEST['user']."'";
mysql_query($sql);
$message = "ลบผู้ใช้ที่ต้องการออกจากระบบเรียบร้อยแล้ว";
break;
วันอังคารที่ 31 มีนาคม พ.ศ. 2552
อบรม freebsd Server ให้กับโรงเรียน
วันเสาร์ที่ 28 มีนาคม พ.ศ. 2552
squid error
squid -N -X สำหรับดูว่าในไฟล์ squid.conf มี error ตรงไหนบ้างครับ
ปัญหาส่วนใหญ่ที่ access.log สั่ง tail -f แล้วไม่เห็นอะไรขึ้นมักเิกิดจากไม่ได้สั่ง chmod 755 หรือสั่งไม่ถูกไฟล์ครับ..
ปัญหาส่วนใหญ่ที่ access.log สั่ง tail -f แล้วไม่เห็นอะไรขึ้นมักเิกิดจากไม่ได้สั่ง chmod 755 หรือสั่งไม่ถูกไฟล์ครับ..
วันพุธที่ 4 มีนาคม พ.ศ. 2552
netcut กับ chilli
max0405
ค้นๆ เจอในพี่ google ในระบบ chillispot ให้แก้ไขดังนี้
# MAC authentication
# TAG: macauth
# If this flag is given users will be authenticated only on their MAC
# address.
# Normally you do not need to uncomment this tag.
#macauth
macauth เอา # ออก
# TAG: macallowed
# List of MAC addresses.
# The MAC addresses specified in this list will be authenticated only on
# their MAC address.
# This tag is ignored if the macauth tag is given.
# It is possible to specify this tag multiple times.
# Normally you do not need to uncomment this tag.
#macallowed 00-0A-5E-AC-BE-51,00-30-1B-3C-32-E9
macallowed 00-0C-29-66-D4-47 ค่าของ eth1
# TAG: macpasswd
# Password to use for MAC authentication.
# Normally you do not need to uncomment this tag.
#macpasswd password
macpasswd test ตั้ง password
# TAG: macsuffix
# Suffix to add to MAC address in order to form the username.
# Normally you do not need to uncomment this tag.
#macsuffix suffix
macsuffix test เอา # ออกและ password
ทดสอบ โดยการใช้ netcut cut off ตัว gateway ทีนี้ออกอินเตอร์เน็ตได้ ตามปกติ แต่ถ้าไม่แก้ไขดังกล่าว ใช้ netcut cut off gateway เดี้ยงครับ
ค้นๆ เจอในพี่ google ในระบบ chillispot ให้แก้ไขดังนี้
# MAC authentication
# TAG: macauth
# If this flag is given users will be authenticated only on their MAC
# address.
# Normally you do not need to uncomment this tag.
#macauth
macauth เอา # ออก
# TAG: macallowed
# List of MAC addresses.
# The MAC addresses specified in this list will be authenticated only on
# their MAC address.
# This tag is ignored if the macauth tag is given.
# It is possible to specify this tag multiple times.
# Normally you do not need to uncomment this tag.
#macallowed 00-0A-5E-AC-BE-51,00-30-1B-3C-32-E9
macallowed 00-0C-29-66-D4-47 ค่าของ eth1
# TAG: macpasswd
# Password to use for MAC authentication.
# Normally you do not need to uncomment this tag.
#macpasswd password
macpasswd test ตั้ง password
# TAG: macsuffix
# Suffix to add to MAC address in order to form the username.
# Normally you do not need to uncomment this tag.
#macsuffix suffix
macsuffix test เอา # ออกและ password
ทดสอบ โดยการใช้ netcut cut off ตัว gateway ทีนี้ออกอินเตอร์เน็ตได้ ตามปกติ แต่ถ้าไม่แก้ไขดังกล่าว ใช้ netcut cut off gateway เดี้ยงครับ
สร้าง script ลบ squid 90 วันอัตโนมัติ...
บทความ aminta แห่ง www.thaibsd.com
ได้เวลาว่าง ๆ มาตอบซะที ผมเขียนแบบกำปั้นทุบดินนะครับ
อีกอย่างผมยังไม่ได้ลองนะนี่ (5555+ แต่น่าจะได้ละ)
อันดับแรกเลยนะครับ สร้าง sh shell script ใช้ editer ที่ถนัด save เป็น dot sh (ex. squid90day.sh)
ระบุ path ตามต้องกรของผมสมมุติที่อยู่ File อยู่ที่ /usr/local/ นะครับ ชื่อไฟล์ squid90day.sh
รายละเอียดตามด้านล่าง
----------------------- squid90day.sh -------------------------
#!/bin/sh
catdate=`cat /tmp/squid90days.tmp`
echo $catdate
if [ $catdate -gt 90 ];then
#ใส่คำสั่งที่คุณต้องการลงไปได้หรือเปลี่ยน Path ของ Squid Cache ข้างล่างบรรทัดนี้ครับ
rm -d /usr/local/squid/cache
mkdir /usr/local/squid/cache
squid -zD
else
catdate=$(($catdate +1))
echo $catdate > /tmp/squid90days.tmp
fi
---------------------------- EOF ------------------------------------
สังเกตุบรรทัดที่ 2 -> catdate=`cat /tmp/squid90days.tmp`
ให้เราไป สร้าง File หรือFolder ที่เห็นคือ /tmp/squid90days.tmp
หรือใช้คำสั่ง
---------------------------- Command ----------------------------
#mkdir /tmp
#echo 0 > /tmp/squid90days.tmp
---------------------------- EO CMD ----------------------------
ต่อมา crontab มีความหมายดังนี้
* * * * * command/script do you want
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)
หรือเพิ่มลงไปที่บรรทัดสุดท้ายของ File "/etc/crontab" ตามนี้
-----------------------
1 0 * * * /usr/local/squid90day.sh
-----------------------
หมายถึงทำทุก เที่ยงคืนหนึ่งนาที ของทุกๆวัน
หากต้องการ Test script นี้ให้แก้ไขที่บรรทัดที่ 4 ของ File squid90day.sh ให้เป็น 1 ครับ
เพื่อทดสอบเก็บ log 1 วัน (อันนี้แล้วแต่ๆ)
หวังว่าคงไม่ขาดตกส่วนไหนไปนะครับ ท่านอื่นช่วยวิจารด้วยนะครับ
ผมยัง ยังไม่ได้สร้างส่วนของการสร้าง File และ Folder ของ Temp File ต้องสร้างเองด้วยมือ ท่านใดช่วยเขียนต่อด้วยนะครับ ขอขอบพระคุณ ผิดพลาดประการใดขออภัยมา ณ ที่นี้ (aminta)
ได้เวลาว่าง ๆ มาตอบซะที ผมเขียนแบบกำปั้นทุบดินนะครับ
อีกอย่างผมยังไม่ได้ลองนะนี่ (5555+ แต่น่าจะได้ละ)
อันดับแรกเลยนะครับ สร้าง sh shell script ใช้ editer ที่ถนัด save เป็น dot sh (ex. squid90day.sh)
ระบุ path ตามต้องกรของผมสมมุติที่อยู่ File อยู่ที่ /usr/local/ นะครับ ชื่อไฟล์ squid90day.sh
รายละเอียดตามด้านล่าง
----------------------- squid90day.sh -------------------------
#!/bin/sh
catdate=`cat /tmp/squid90days.tmp`
echo $catdate
if [ $catdate -gt 90 ];then
#ใส่คำสั่งที่คุณต้องการลงไปได้หรือเปลี่ยน Path ของ Squid Cache ข้างล่างบรรทัดนี้ครับ
rm -d /usr/local/squid/cache
mkdir /usr/local/squid/cache
squid -zD
else
catdate=$(($catdate +1))
echo $catdate > /tmp/squid90days.tmp
fi
---------------------------- EOF ------------------------------------
สังเกตุบรรทัดที่ 2 -> catdate=`cat /tmp/squid90days.tmp`
ให้เราไป สร้าง File หรือFolder ที่เห็นคือ /tmp/squid90days.tmp
หรือใช้คำสั่ง
---------------------------- Command ----------------------------
#mkdir /tmp
#echo 0 > /tmp/squid90days.tmp
---------------------------- EO CMD ----------------------------
ต่อมา crontab มีความหมายดังนี้
* * * * * command/script do you want
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)
หรือเพิ่มลงไปที่บรรทัดสุดท้ายของ File "/etc/crontab" ตามนี้
-----------------------
1 0 * * * /usr/local/squid90day.sh
-----------------------
หมายถึงทำทุก เที่ยงคืนหนึ่งนาที ของทุกๆวัน
หากต้องการ Test script นี้ให้แก้ไขที่บรรทัดที่ 4 ของ File squid90day.sh ให้เป็น 1 ครับ
เพื่อทดสอบเก็บ log 1 วัน (อันนี้แล้วแต่ๆ)
หวังว่าคงไม่ขาดตกส่วนไหนไปนะครับ ท่านอื่นช่วยวิจารด้วยนะครับ
ผมยัง ยังไม่ได้สร้างส่วนของการสร้าง File และ Folder ของ Temp File ต้องสร้างเองด้วยมือ ท่านใดช่วยเขียนต่อด้วยนะครับ ขอขอบพระคุณ ผิดพลาดประการใดขออภัยมา ณ ที่นี้ (aminta)
วันเสาร์ที่ 28 กุมภาพันธ์ พ.ศ. 2552
freebsd on vmware ครับ
บทความจากท่าน vb thaibsd.com
เห็นว่าสมาชิกบางท่านอยากลองเล่น FreeBSD แต่ไม่มีเครื่องให้ลองเล่น ก็เล่นเอาวิธีการใช้งาน VMware workstation 6 มาให้ลองเล่นกันสนุกๆ เพราะลองใช้แล้วใช้งานได้ไม่ว่าจะเป็น Webserver หรือ Chillispot ก็ใช้ได้ครับ
วิธีการตั้งค่า VMware (version 6 workstation)
1. ทำการ Setup Network ก่อน โดยเรียกโปรแกรม Manage Virtual Networks ก่อน
เมื่อเปิดหน้าต่าง Virual Network Editor แล้วให้ไปที่
1.1 Host Virtual Adapters ให้ทำการ Remove Network Adapter ออกทั้งหมด
1.2 แล้วไปที่ Host Virtual Network Mapping ให้ทำการ Map Lancard ที่เรา
ติดตั้งบนเครื่อง PC ไม่ว่าจะกี่ใบก็ตาม ในที่นี้สมติให้ติดตั้ง 3 ใบ ก็ให้ทำการ
Map โดยเลือก Lancard ใบที่ 1 = VMnet0 ใบที่ 2 = VMnet2 ใบที่3=VMnet4
หรือจะ Map เป็นอย่างอื่นก็ได้
1.3 จากนั้นให้ไปยกเลิกการทำ NAT ที่หน้าต่าง NAT แล้วเลือก Disable เพราะในที่
นี้เราจะตั้งค่า LAN card ทุกตัวเป็น Bridged
เป็นอันจบขั้นตอนการตั้งค่า Virtual Networks
2. จากนั้นให้ไปที่โปรแกรม VMware Workstation ทำการสร้าง Virtual Machine โดยทำการ New
แล้วตั้งค่าต่างๆ ก่อนทำการติดตั้ง เช่น set memory จะใช้เท่าไร lancard จนครบ แต่อย่างเพิ่งสั่ง
Run เพื่อกลับมาดูว่าเราต้องการใช้ Lan card กี่ใบ ในที่นี้เราสมติให้ใช้ 3 ใบ ก็ให้ทำการ Add
Lancard เข้าไป แต่การตั้งค่าของ Lancard นั้น ให้ทำแบบ Custom แล้วเลือก VMnet ที่เราทำ
Map ไว้แล้วตามข้างต้นให้กับ Lancard แต่ละใบจนครบ 3 ใบ
3. จากนั้นให้ทำการ Run เพื่อทำการติดตั้ง Program เช่น FreeBSD7 หรืออะไรก็ตาม Lancard ที่ชื่อ
lnc0 คือ lancard ใบที่ 1 lnc1= lancard ใบที่2 lnc2=lancard ใบที่ 3 เท่านี้ก็เป็นอันใช้ได้
ท่าน new hand
เอามาจากหนังสือ คอมพิวเตอร์ Virtual Machine ภาคปฏิบัติ ของ อ.บัณฑิต
บทที่ 4 หน้า 106 ครับ
ให้ล็อกอินเข้าระบบด้วย root แล้วกดคีย์ เพื่อสลับโหมด ออกมา ให้เลือกคำสั่ง VM/Install VMware Tools.. จะแสดงกรอบข่าวสาร ให้คลิ๊ก install
ให้ทำการเมาส์ cd rom (ไม่ใช่ actual CD-ROM แต่เป็น image CD-ROM)
mount /cdrom
cd /tmp
tar zxf /cdrom/vmware-freebsd-tools.tar.gz
umount /cdrom
แล้ว สั่งรัน VMware Tools installer ด้วยการพิมพ์คำสั่ง
cd vmware-tools-distrib
./vmware-install.pl
ให้กดคีย์ และ ตอบ Yes ไปจนเลื่อย ๆ จนมาถึงการเลือก Display sizes ซึ่งมีค่า 1-9 ให้ เลือกตามค่า
Default ที่โปรแกรมกำหนดมา ในที่นี้คือ 5 แล้วกดคีย์ จนเสร็จขั้นตอน
โดยจะแนะนำให้รีสตาร์ต X Session จากนั้นให้พิมพ์คำสั่ง init 6 เพื่อรีสตาร์ต
หลังจากล็อกอินเข้ามาด้วย root แล้ว ให้พิมพ์คำสั่ง echo “exec startkde” >~/.xinitrc เสร็จแล้ว ให้พิมพ์คำสั่ง startx เพื่อเข้าสู่เดสก์ท็อป KDE พร้อมทั้งการเซตอัพ 4 step
ลองทำดูครับ ผมเซตได้แล้ว เลยเอามาฝากเพื่อน ๆ
มือใหม่เหมือนกัน
เห็นว่าสมาชิกบางท่านอยากลองเล่น FreeBSD แต่ไม่มีเครื่องให้ลองเล่น ก็เล่นเอาวิธีการใช้งาน VMware workstation 6 มาให้ลองเล่นกันสนุกๆ เพราะลองใช้แล้วใช้งานได้ไม่ว่าจะเป็น Webserver หรือ Chillispot ก็ใช้ได้ครับ
วิธีการตั้งค่า VMware (version 6 workstation)
1. ทำการ Setup Network ก่อน โดยเรียกโปรแกรม Manage Virtual Networks ก่อน
เมื่อเปิดหน้าต่าง Virual Network Editor แล้วให้ไปที่
1.1 Host Virtual Adapters ให้ทำการ Remove Network Adapter ออกทั้งหมด
1.2 แล้วไปที่ Host Virtual Network Mapping ให้ทำการ Map Lancard ที่เรา
ติดตั้งบนเครื่อง PC ไม่ว่าจะกี่ใบก็ตาม ในที่นี้สมติให้ติดตั้ง 3 ใบ ก็ให้ทำการ
Map โดยเลือก Lancard ใบที่ 1 = VMnet0 ใบที่ 2 = VMnet2 ใบที่3=VMnet4
หรือจะ Map เป็นอย่างอื่นก็ได้
1.3 จากนั้นให้ไปยกเลิกการทำ NAT ที่หน้าต่าง NAT แล้วเลือก Disable เพราะในที่
นี้เราจะตั้งค่า LAN card ทุกตัวเป็น Bridged
เป็นอันจบขั้นตอนการตั้งค่า Virtual Networks
2. จากนั้นให้ไปที่โปรแกรม VMware Workstation ทำการสร้าง Virtual Machine โดยทำการ New
แล้วตั้งค่าต่างๆ ก่อนทำการติดตั้ง เช่น set memory จะใช้เท่าไร lancard จนครบ แต่อย่างเพิ่งสั่ง
Run เพื่อกลับมาดูว่าเราต้องการใช้ Lan card กี่ใบ ในที่นี้เราสมติให้ใช้ 3 ใบ ก็ให้ทำการ Add
Lancard เข้าไป แต่การตั้งค่าของ Lancard นั้น ให้ทำแบบ Custom แล้วเลือก VMnet ที่เราทำ
Map ไว้แล้วตามข้างต้นให้กับ Lancard แต่ละใบจนครบ 3 ใบ
3. จากนั้นให้ทำการ Run เพื่อทำการติดตั้ง Program เช่น FreeBSD7 หรืออะไรก็ตาม Lancard ที่ชื่อ
lnc0 คือ lancard ใบที่ 1 lnc1= lancard ใบที่2 lnc2=lancard ใบที่ 3 เท่านี้ก็เป็นอันใช้ได้
ท่าน new hand
เอามาจากหนังสือ คอมพิวเตอร์ Virtual Machine ภาคปฏิบัติ ของ อ.บัณฑิต
บทที่ 4 หน้า 106 ครับ
ให้ล็อกอินเข้าระบบด้วย root แล้วกดคีย์
ให้ทำการเมาส์ cd rom (ไม่ใช่ actual CD-ROM แต่เป็น image CD-ROM)
mount /cdrom
cd /tmp
tar zxf /cdrom/vmware-freebsd-tools.tar.gz
umount /cdrom
แล้ว สั่งรัน VMware Tools installer ด้วยการพิมพ์คำสั่ง
cd vmware-tools-distrib
./vmware-install.pl
ให้กดคีย์
Default ที่โปรแกรมกำหนดมา ในที่นี้คือ 5 แล้วกดคีย์
โดยจะแนะนำให้รีสตาร์ต X Session จากนั้นให้พิมพ์คำสั่ง init 6 เพื่อรีสตาร์ต
หลังจากล็อกอินเข้ามาด้วย root แล้ว ให้พิมพ์คำสั่ง echo “exec startkde” >~/.xinitrc เสร็จแล้ว ให้พิมพ์คำสั่ง startx เพื่อเข้าสู่เดสก์ท็อป KDE พร้อมทั้งการเซตอัพ 4 step
ลองทำดูครับ ผมเซตได้แล้ว เลยเอามาฝากเพื่อน ๆ
มือใหม่เหมือนกัน
สมัครสมาชิก:
บทความ (Atom)





