บทความจากคุณ 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) ไม่ว่าจะเป็นต้นทางและปลายทางที่ไหน
วันอังคารที่ 20 เมษายน พ.ศ. 2553
วันเสาร์ที่ 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
ลองทำดูครับ ผมเซตได้แล้ว เลยเอามาฝากเพื่อน ๆ
มือใหม่เหมือนกัน
วันศุกร์ที่ 27 กุมภาพันธ์ พ.ศ. 2552
ทำ freebsd ให้ stable
ตลอดทั้งขบวนการจะต้อง login เป็น root แม้จะต้อง shutdown แล้วเปิดเครื่องซ้ำอีกหน ก็ตาม ยังคงต้องเป็น root อยู่นั่นเอง
ขั้นตอนต่างๆ ขอให้ทำไปทีละขั้น ทีล่ะตอน อย่าข้าม และเมื่อจบทั้งขบวนการแล้ว ท่านมี ระบบใหม่ ทั้ง kernel และ systems แน่นอน รับประกันได้
ติดตั้ง cvsup ก่อน (ถ้าเคยติดตั้งไปก่อนหน้านี้แล้วก็ไม่ต้องทำ)
#pkg_add -r cvsup-without-gui
#rehash
หรือแบบนี้ก็ได้เช่นกัน
#cd /usr/ports/net/cvsup-without-gui
#make install && make clean
#rehash
จากนั้น cvsup เอา src ใหม่มา
#cvsup -g -L 2 -h cvsup5.freebsd.org /usr/share/examples/cvsup/stable-supfile (server cvsup.freebsd.org มีตั้งแต่ 1 - 18 เลือกเอาเอง)
ลบข้อมูลใน /usr/obj ทิ้งก่อน
# cd /usr/obj
# chflags -R noschg *
# rm -rf *
ถ้าจะแก้ไข kernel configuration ก่อน ก็ให้ไปแก้ที่ไฟล์ /usr/src/sys/i386/conf/GENERIC หรือจะสำเนาออกมาไว้อีกชุดก็ได้ เช่นชื่อ MYKERN
#cp /usr/src/sys/i386/conf/GENERIC /usr/src/sys/i386/conf/MYKERN
#vi /usr/src/sys/i386/conf/MYKERN
แก้ไขค่าต่างๆตามความเหมาะสม เซฟไฟล์ แล้วออกจาก vi
#cd /usr/src
#make buildworld
#make buildkernel KERNCONF=MYKERN
#make installkernel KERNCONF=MYKERN
#mergemaster -p
#shutdown -r now
พอ boot เข้าไปที่หน้าเมนู (เวลานับเวลาถอยหลัง 10 วินาที)
ให้เลือกเมนู 4 เพื่อเข้าสู่ single user mode แล้วสั่ง mount partition ตามคำสั่งดังนี้
#fsck -p
#mount -uw /
#mount -a -t ufs
#swapon -a
#adjkerntz -i
#cd /usr/src
#make installworld
#mergemaster -cv
How should I deal with this? [Use the existing /var/tmp/temproot] ตรงนี้ให้ตอบ d เพื่อลบข้อมูลเก่าทิ้ง
*** Press the [Enter] or [Return] key to continue เคาะ Enter ไปเลย
ขั้นตอนนี้กด i เพื่อ install ได้เลยมันจะโชว์ไฟล์ระบบที่ได้มาใหม่ กับของเก่าที่มีอยู่อ่านให้ดี ๆ
พึงใช้สามัญสำนึกให้มากๆไว้ตรงนี้ด้วยว่า อย่างพวก /etc/group, /etc/passwd.master หรือถ้าจัด named.conf ไว้แล้ว ก็อย่าไปรับของใหม่มา
จากนั้นรีบูตเครื่องอีกครั้ง
#shutdown -r now
เมื่อทุกอย่างเรียบร้อย พอบูตเข้าระบบท่านก็จะมี system = 6.0-STABLE และ MYKERN kernel ทันที !
ลองใช้คำสั่ง umane -a
ก็จะเห็นเป็น FreeBSD 6.0-STABLE และ MYKERNEL สมใจแล้วละครับ
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/cvsup.html
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html
ท่านใดที่เข้าไปใน single user mode แล้ว make installworld ไม่ได้แจ้ง Error ดังนี้
ERROR: Required audit group is misssing, see /usr/src/UPDATING.
*** Error code 1
ให้ไปเพิ่มข้อความด่านล่างนี้ลงใน /etc/group ด้วยนะครับ จากนั้นลองใหม่ครับ
%grep audit /etc/passwd
%grep audit /etc/group
audit:*:77:
%
ขั้นตอนต่างๆ ขอให้ทำไปทีละขั้น ทีล่ะตอน อย่าข้าม และเมื่อจบทั้งขบวนการแล้ว ท่านมี ระบบใหม่ ทั้ง kernel และ systems แน่นอน รับประกันได้
ติดตั้ง cvsup ก่อน (ถ้าเคยติดตั้งไปก่อนหน้านี้แล้วก็ไม่ต้องทำ)
#pkg_add -r cvsup-without-gui
#rehash
หรือแบบนี้ก็ได้เช่นกัน
#cd /usr/ports/net/cvsup-without-gui
#make install && make clean
#rehash
จากนั้น cvsup เอา src ใหม่มา
#cvsup -g -L 2 -h cvsup5.freebsd.org /usr/share/examples/cvsup/stable-supfile (server cvsup.freebsd.org มีตั้งแต่ 1 - 18 เลือกเอาเอง)
ลบข้อมูลใน /usr/obj ทิ้งก่อน
# cd /usr/obj
# chflags -R noschg *
# rm -rf *
ถ้าจะแก้ไข kernel configuration ก่อน ก็ให้ไปแก้ที่ไฟล์ /usr/src/sys/i386/conf/GENERIC หรือจะสำเนาออกมาไว้อีกชุดก็ได้ เช่นชื่อ MYKERN
#cp /usr/src/sys/i386/conf/GENERIC /usr/src/sys/i386/conf/MYKERN
#vi /usr/src/sys/i386/conf/MYKERN
แก้ไขค่าต่างๆตามความเหมาะสม เซฟไฟล์ แล้วออกจาก vi
#cd /usr/src
#make buildworld
#make buildkernel KERNCONF=MYKERN
#make installkernel KERNCONF=MYKERN
#mergemaster -p
#shutdown -r now
พอ boot เข้าไปที่หน้าเมนู (เวลานับเวลาถอยหลัง 10 วินาที)
ให้เลือกเมนู 4 เพื่อเข้าสู่ single user mode แล้วสั่ง mount partition ตามคำสั่งดังนี้
#fsck -p
#mount -uw /
#mount -a -t ufs
#swapon -a
#adjkerntz -i
#cd /usr/src
#make installworld
#mergemaster -cv
How should I deal with this? [Use the existing /var/tmp/temproot] ตรงนี้ให้ตอบ d เพื่อลบข้อมูลเก่าทิ้ง
*** Press the [Enter] or [Return] key to continue เคาะ Enter ไปเลย
ขั้นตอนนี้กด i เพื่อ install ได้เลยมันจะโชว์ไฟล์ระบบที่ได้มาใหม่ กับของเก่าที่มีอยู่อ่านให้ดี ๆ
พึงใช้สามัญสำนึกให้มากๆไว้ตรงนี้ด้วยว่า อย่างพวก /etc/group, /etc/passwd.master หรือถ้าจัด named.conf ไว้แล้ว ก็อย่าไปรับของใหม่มา
จากนั้นรีบูตเครื่องอีกครั้ง
#shutdown -r now
เมื่อทุกอย่างเรียบร้อย พอบูตเข้าระบบท่านก็จะมี system = 6.0-STABLE และ MYKERN kernel ทันที !
ลองใช้คำสั่ง umane -a
ก็จะเห็นเป็น FreeBSD 6.0-STABLE และ MYKERNEL สมใจแล้วละครับ
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/cvsup.html
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html
ท่านใดที่เข้าไปใน single user mode แล้ว make installworld ไม่ได้แจ้ง Error ดังนี้
ERROR: Required audit group is misssing, see /usr/src/UPDATING.
*** Error code 1
ให้ไปเพิ่มข้อความด่านล่างนี้ลงใน /etc/group ด้วยนะครับ จากนั้นลองใหม่ครับ
%grep audit /etc/passwd
%grep audit /etc/group
audit:*:77:
%
ทำ freebsd ให้ stable
ตลอดทั้งขบวนการจะต้อง login เป็น root แม้จะต้อง shutdown แล้วเปิดเครื่องซ้ำอีกหน ก็ตาม ยังคงต้องเป็น root อยู่นั่นเอง
ขั้นตอนต่างๆ ขอให้ทำไปทีละขั้น ทีล่ะตอน อย่าข้าม และเมื่อจบทั้งขบวนการแล้ว ท่านมี ระบบใหม่ ทั้ง kernel และ systems แน่นอน รับประกันได้
ติดตั้ง cvsup ก่อน (ถ้าเคยติดตั้งไปก่อนหน้านี้แล้วก็ไม่ต้องทำ)
#pkg_add -r cvsup-without-gui
#rehash
หรือแบบนี้ก็ได้เช่นกัน
#cd /usr/ports/net/cvsup-without-gui
#make install && make clean
#rehash
จากนั้น cvsup เอา src ใหม่มา
#cvsup -g -L 2 -h cvsup5.freebsd.org /usr/share/examples/cvsup/stable-supfile (server cvsup.freebsd.org มีตั้งแต่ 1 - 18 เลือกเอาเอง)
ลบข้อมูลใน /usr/obj ทิ้งก่อน
# cd /usr/obj
# chflags -R noschg *
# rm -rf *
ถ้าจะแก้ไข kernel configuration ก่อน ก็ให้ไปแก้ที่ไฟล์ /usr/src/sys/i386/conf/GENERIC หรือจะสำเนาออกมาไว้อีกชุดก็ได้ เช่นชื่อ MYKERN
#cp /usr/src/sys/i386/conf/GENERIC /usr/src/sys/i386/conf/MYKERN
#vi /usr/src/sys/i386/conf/MYKERN
แก้ไขค่าต่างๆตามความเหมาะสม เซฟไฟล์ แล้วออกจาก vi
#cd /usr/src
#make buildworld
#make buildkernel KERNCONF=MYKERN
#make installkernel KERNCONF=MYKERN
#mergemaster -p
#shutdown -r now
พอ boot เข้าไปที่หน้าเมนู (เวลานับเวลาถอยหลัง 10 วินาที)
ให้เลือกเมนู 4 เพื่อเข้าสู่ single user mode แล้วสั่ง mount partition ตามคำสั่งดังนี้
#fsck -p
#mount -uw /
#mount -a -t ufs
#swapon -a
#adjkerntz -i
#cd /usr/src
#make installworld
#mergemaster -cv
How should I deal with this? [Use the existing /var/tmp/temproot] ตรงนี้ให้ตอบ d เพื่อลบข้อมูลเก่าทิ้ง
*** Press the [Enter] or [Return] key to continue เคาะ Enter ไปเลย
ขั้นตอนนี้กด i เพื่อ install ได้เลยมันจะโชว์ไฟล์ระบบที่ได้มาใหม่ กับของเก่าที่มีอยู่อ่านให้ดี ๆ
พึงใช้สามัญสำนึกให้มากๆไว้ตรงนี้ด้วยว่า อย่างพวก /etc/group, /etc/passwd.master หรือถ้าจัด named.conf ไว้แล้ว ก็อย่าไปรับของใหม่มา
จากนั้นรีบูตเครื่องอีกครั้ง
#shutdown -r now
เมื่อทุกอย่างเรียบร้อย พอบูตเข้าระบบท่านก็จะมี system = 6.0-STABLE และ MYKERN kernel ทันที !
ลองใช้คำสั่ง umane -a
ก็จะเห็นเป็น FreeBSD 6.0-STABLE และ MYKERNEL สมใจแล้วละครับ
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/cvsup.html
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html
ท่านใดที่เข้าไปใน single user mode แล้ว make installworld ไม่ได้แจ้ง Error ดังนี้
ERROR: Required audit group is misssing, see /usr/src/UPDATING.
*** Error code 1
ให้ไปเพิ่มข้อความด่านล่างนี้ลงใน /etc/group ด้วยนะครับ จากนั้นลองใหม่ครับ
%grep audit /etc/passwd
%grep audit /etc/group
audit:*:77:
%
ขั้นตอนต่างๆ ขอให้ทำไปทีละขั้น ทีล่ะตอน อย่าข้าม และเมื่อจบทั้งขบวนการแล้ว ท่านมี ระบบใหม่ ทั้ง kernel และ systems แน่นอน รับประกันได้
ติดตั้ง cvsup ก่อน (ถ้าเคยติดตั้งไปก่อนหน้านี้แล้วก็ไม่ต้องทำ)
#pkg_add -r cvsup-without-gui
#rehash
หรือแบบนี้ก็ได้เช่นกัน
#cd /usr/ports/net/cvsup-without-gui
#make install && make clean
#rehash
จากนั้น cvsup เอา src ใหม่มา
#cvsup -g -L 2 -h cvsup5.freebsd.org /usr/share/examples/cvsup/stable-supfile (server cvsup.freebsd.org มีตั้งแต่ 1 - 18 เลือกเอาเอง)
ลบข้อมูลใน /usr/obj ทิ้งก่อน
# cd /usr/obj
# chflags -R noschg *
# rm -rf *
ถ้าจะแก้ไข kernel configuration ก่อน ก็ให้ไปแก้ที่ไฟล์ /usr/src/sys/i386/conf/GENERIC หรือจะสำเนาออกมาไว้อีกชุดก็ได้ เช่นชื่อ MYKERN
#cp /usr/src/sys/i386/conf/GENERIC /usr/src/sys/i386/conf/MYKERN
#vi /usr/src/sys/i386/conf/MYKERN
แก้ไขค่าต่างๆตามความเหมาะสม เซฟไฟล์ แล้วออกจาก vi
#cd /usr/src
#make buildworld
#make buildkernel KERNCONF=MYKERN
#make installkernel KERNCONF=MYKERN
#mergemaster -p
#shutdown -r now
พอ boot เข้าไปที่หน้าเมนู (เวลานับเวลาถอยหลัง 10 วินาที)
ให้เลือกเมนู 4 เพื่อเข้าสู่ single user mode แล้วสั่ง mount partition ตามคำสั่งดังนี้
#fsck -p
#mount -uw /
#mount -a -t ufs
#swapon -a
#adjkerntz -i
#cd /usr/src
#make installworld
#mergemaster -cv
How should I deal with this? [Use the existing /var/tmp/temproot] ตรงนี้ให้ตอบ d เพื่อลบข้อมูลเก่าทิ้ง
*** Press the [Enter] or [Return] key to continue เคาะ Enter ไปเลย
ขั้นตอนนี้กด i เพื่อ install ได้เลยมันจะโชว์ไฟล์ระบบที่ได้มาใหม่ กับของเก่าที่มีอยู่อ่านให้ดี ๆ
พึงใช้สามัญสำนึกให้มากๆไว้ตรงนี้ด้วยว่า อย่างพวก /etc/group, /etc/passwd.master หรือถ้าจัด named.conf ไว้แล้ว ก็อย่าไปรับของใหม่มา
จากนั้นรีบูตเครื่องอีกครั้ง
#shutdown -r now
เมื่อทุกอย่างเรียบร้อย พอบูตเข้าระบบท่านก็จะมี system = 6.0-STABLE และ MYKERN kernel ทันที !
ลองใช้คำสั่ง umane -a
ก็จะเห็นเป็น FreeBSD 6.0-STABLE และ MYKERNEL สมใจแล้วละครับ
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/cvsup.html
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html
ท่านใดที่เข้าไปใน single user mode แล้ว make installworld ไม่ได้แจ้ง Error ดังนี้
ERROR: Required audit group is misssing, see /usr/src/UPDATING.
*** Error code 1
ให้ไปเพิ่มข้อความด่านล่างนี้ลงใน /etc/group ด้วยนะครับ จากนั้นลองใหม่ครับ
%grep audit /etc/passwd
%grep audit /etc/group
audit:*:77:
%
วันจันทร์ที่ 23 กุมภาพันธ์ พ.ศ. 2552
block ทุำกอย่างเปิดเท่าีที่เปิดไว้ใน allo_port
allow_port="2401,8888,8080,80,21,3128,22,20,23,1201"
ipfw add 4600 allow 192.168.1.0/24 from 192.168.182.0/24 to any $allow_port
ipfw add 7000 deny 192.168.1.0/24 from 192.168.1.0/24 to any
tip จาก supakorn
ipfw add 4600 allow 192.168.1.0/24 from 192.168.182.0/24 to any $allow_port
ipfw add 7000 deny 192.168.1.0/24 from 192.168.1.0/24 to any
tip จาก supakorn
block ทุำกอย่างเปิดเท่าีที่เปิดไว้ใน allo_port
allow_port="2401,8888,8080,80,21,3128,22,20,23,1201"
ipfw add 4600 allow 192.168.1.0/24 from 192.168.182.0/24 to any $allow_port
ipfw add 7000 deny 192.168.1.0/24 from 192.168.1.0/24 to any
tip จาก supakorn
ipfw add 4600 allow 192.168.1.0/24 from 192.168.182.0/24 to any $allow_port
ipfw add 7000 deny 192.168.1.0/24 from 192.168.1.0/24 to any
tip จาก supakorn
radius error ไม่ทำงานวิธีแก้ไข
ได้แล้วคครับตามนี้ครับ
authen# pico /usr/local/etc/raddb/dictionary
# The filename given here should be an absolute path.
#
$INCLUDE /usr/local/share/freeradius/dictionary //ตรงนี้ไว้คงเดิมนะครับ
$INCLUDE /usr/local/etc/raddb/dictionary.chillispot // ตรงนี้เพิ่มไปอีกหนึ่งบรรทัดครับ
แล้ว reboot หนึ่งรอบ
และวลองใช้คำสั่ง top ดูครับจะเห็น service radius ทำงาน
ขอบคุณครูมนิสสำหรับคู่มือครับ
ขอบคุณ Phiphop ในบอร์ดนี้ที่นะนำด้านบนครับ
authen# pico /usr/local/etc/raddb/dictionary
# The filename given here should be an absolute path.
#
$INCLUDE /usr/local/share/freeradius/dictionary //ตรงนี้ไว้คงเดิมนะครับ
$INCLUDE /usr/local/etc/raddb/dictionary.chillispot // ตรงนี้เพิ่มไปอีกหนึ่งบรรทัดครับ
แล้ว reboot หนึ่งรอบ
และวลองใช้คำสั่ง top ดูครับจะเห็น service radius ทำงาน
ขอบคุณครูมนิสสำหรับคู่มือครับ
ขอบคุณ Phiphop ในบอร์ดนี้ที่นะนำด้านบนครับ
วันอังคารที่ 17 กุมภาพันธ์ พ.ศ. 2552
วันอาทิตย์ที่ 15 กุมภาพันธ์ พ.ศ. 2552
กำหนด user login show ใน freebsd
ทิปจากท่าน ccd แห่ง thaibsd.com
แก้ไข .cshrc ใน /root/
#ee .cshrc
ที่บรรทัดต่อำปนี้
set prompt = "`/bin/hostname -s`# "
แก้เป็น
set prompt = "[%n@%m][%~]# "
บีบอัด ทำ famp
tar -cvWjf filenam.tar.bz2 /usr/ports/distfies
tip จากท่าน cache แห่ง thaibsd.com
แก้ไข .cshrc ใน /root/
#ee .cshrc
ที่บรรทัดต่อำปนี้
set prompt = "`/bin/hostname -s`# "
แก้เป็น
set prompt = "[%n@%m][%~]# "
บีบอัด ทำ famp
tar -cvWjf filenam.tar.bz2 /usr/ports/distfies
tip จากท่าน cache แห่ง thaibsd.com
วันศุกร์ที่ 6 กุมภาพันธ์ พ.ศ. 2552
ลบฐานข้อมูล mysql
หากใครใช้ฐานข้อมูล mysql ที่เป็นแบบ inno
ที่มีขนาดโตมาก ๆ มักจะเจอปัญหาว่า
mysql-bin มันมีขนาดใหญ่มาก
เราสามารถลบทิ้งได้โดยสั่ง
With your mysql client :
mysql -u root -p
then
mysql> flush logs;
will create a brand new mysql-bin.0000xy
mysql> purge binary logs to 'mysql-bin.0000xy';
will purge all your logs files before the last.
เพราะเราไป delete ธรรมดาไม่ได้ ต้องจากคอมมานไลน์ครับ
บทความจากท่าน yim แห่งไทยจิซอฟฟ์
ที่มีขนาดโตมาก ๆ มักจะเจอปัญหาว่า
mysql-bin มันมีขนาดใหญ่มาก
เราสามารถลบทิ้งได้โดยสั่ง
With your mysql client :
mysql -u root -p
then
mysql> flush logs;
will create a brand new mysql-bin.0000xy
mysql> purge binary logs to 'mysql-bin.0000xy';
will purge all your logs files before the last.
เพราะเราไป delete ธรรมดาไม่ได้ ต้องจากคอมมานไลน์ครับ
บทความจากท่าน yim แห่งไทยจิซอฟฟ์
วันพุธที่ 4 กุมภาพันธ์ พ.ศ. 2552
วันเสาร์ที่ 31 มกราคม พ.ศ. 2552
มาทำการแก้ไข NTLDR is missing
มาทำแฟลชไดร์ฟหรือซีดีรอมบูตได้เพื่อแก้อาการ NTLDR is missing กันครับ
อย่างไรแล้วก็ขอบอกไว้ก่อนนะครับ ว่าโปรแกรมทั้งหลายผมไม่ได้เขียนเอง เพียงแค่เอาโปรแกรมหลัก ๆ ของเขามา แล้วใช้แบตช์ไฟล์ไปเรียกมาใช้งานเท่านั้นเอง
ฉะนั้นเครดิตต่าง ๆ ขอยกให้เจ้าของโปรแกรมเขาครับ
การแก้ปัญหานี้จะช่วยได้เฉพาะไฟล์ของระบบบูตเสียหายเท่านั้นนะครับ ถ้าฮาร์ดแวร์หรือซอฟต์แวร์ของวินโดวส์เสียหายมากจะแก้ไม่ได้นะครับขอบอก
มาดูวิธีทำกันเลยครับ
ชุดที่ 1
ทำแฟลชไดร์ฟบูตได้ใช้สำหรับแก้อาการ
NTLDR is missing
Prass Ctrl + Alt + Del to restart
................................................
วิธีทำแฟลชไดร์ฟบูตได้
1. เอาแฟลชไดร์ฟเสียบคาไว้
2. แตกซิบ AMD.zip ออก
3. ดับเบิ้ลคลิกไฟล์ usb_format.exe ที่อยู่ในโฟลเดอร์ AMD
4. คลิกใส่เครื่องหมายถูกในช่อง Create a DOS Bootable Disk
5. คลิกที่ Brose เลือกคลิกที่โฟลเดอร์ AMD แล้วคลิก OK
6. คลิก Start -> Yes รอจนเสร็จแล้วคลิก OK -> Close
7. ก็อบปี้ไฟล์ในโฟลเดอร์ AMD ทั้งหมดไปใส่ในแฟลชไดร์ฟ ถ้าเครื่องบอกว่ามีไฟล์อยู่แล้วให้คลิก Yes to All
................................................................
เสร็จการทำแฟลชไดร์ฟบูตได้ ต่อ่ไปซ่อมอาการ
NTLDR is missing
Prass Ctrl + Alt + Del to restart
1. เข้าไปปรับไบออสให้บูตด้วยแฟลชไดร์ฟ (เมนบอร์ดต้องซัพพอร์ตบูตแฟลชไดร์ฟได้ด้วย)
2. เมื่อออกจากไบออสเครื่องจะรีสตาร์ทใหม่ ปล่อยให้เข้าไปที่ C:> พิมพ์ AMD แล้วกด Enter
3. ปิดเครื่องถอดแฟลชไดร์ฟออก แล้วเปิดใหม่เครื่องตามปกติจะเข้าวินโดวส์ได้
ดาวน์โหลดโปรแกรมที่นี่ครับ http://www.free4up.com/show.php?img=12875_AMD.zip.html
.................................................................
ชุดที่ 2
ทำ CD-ROM บูตได้ใช้สำหรับแก้อาการ
NTLDR is missing
Prass Ctrl + Alt + Del to restart
..................................................................
วิธีทำ CD-ROM บูตได้
1. เอาแผ่น CD-ROM เปล่าใส่ไว้ในเครื่องเขียน
2. แตกซิบ CD_Repair.zip ออก
3. ดับเบิ้ลคลิกไฟล์ CD Repair.nrg
4. คลิกเลือก Write Speed
5. คลิกเลือกวิธีเขียนเป็น Disk-at-once
6. คลิก Burn
7. รอจนเครื่องเขียนเสร็จ คลิก ตกลง แล้วปิดหน้าต่างทั้งหมด
..................................................................
เสร็จการทำ CD-ROM บูตได้แล้ว ต่อ่ไปซ่อมอาการ
NTLDR is missing
Prass Ctrl + Alt + Del to restart
1. เข้าไปปรับไบออสให้บูตด้วย CD-ROM
2. เมื่อออกจากไบออสเครื่องจะรีสตาร์ทใหม่ ปล่อยให้เข้าไปที่ A:> พิมพ์ AMD แล้วกด Enter
3. เอาแผ่น CD-ROM ออกจากเครื่องอ่าน แล้วรีสตร์ทเครื่องตามปกติจะเข้าวินโดวส์ได้
ดาวน์โหลดที่นี่ครับ http://www.free4up.com/show.php?img=12876_CDRepair.zip.html
..................................................................
แนะนำสำหรับเครื่องรุ่นเก่าที่ไม่สามารถบูตด้วยแฟลชไดร์ฟได้ ให้ใช้แบบ CD-ROM จะใช้ได้ทุกเครื่องครับผม
ลองแล้วได้ผลประการใดช่วยแจ้งให้ทราบด้วยเพื่อจะหาแนวทางแก้ไขปรับปรุงต่อไป จักขอบพระคุณเป็นอย่างสูงครับผม.
จากคุณ : AMD (ไม่นิยมอินเทล) -[ 27 ม.ค. 52 - 18:47:52 A:118.174.46.74 X: ]
อย่างไรแล้วก็ขอบอกไว้ก่อนนะครับ ว่าโปรแกรมทั้งหลายผมไม่ได้เขียนเอง เพียงแค่เอาโปรแกรมหลัก ๆ ของเขามา แล้วใช้แบตช์ไฟล์ไปเรียกมาใช้งานเท่านั้นเอง
ฉะนั้นเครดิตต่าง ๆ ขอยกให้เจ้าของโปรแกรมเขาครับ
การแก้ปัญหานี้จะช่วยได้เฉพาะไฟล์ของระบบบูตเสียหายเท่านั้นนะครับ ถ้าฮาร์ดแวร์หรือซอฟต์แวร์ของวินโดวส์เสียหายมากจะแก้ไม่ได้นะครับขอบอก
มาดูวิธีทำกันเลยครับ
ชุดที่ 1
ทำแฟลชไดร์ฟบูตได้ใช้สำหรับแก้อาการ
NTLDR is missing
Prass Ctrl + Alt + Del to restart
................................................
วิธีทำแฟลชไดร์ฟบูตได้
1. เอาแฟลชไดร์ฟเสียบคาไว้
2. แตกซิบ AMD.zip ออก
3. ดับเบิ้ลคลิกไฟล์ usb_format.exe ที่อยู่ในโฟลเดอร์ AMD
4. คลิกใส่เครื่องหมายถูกในช่อง Create a DOS Bootable Disk
5. คลิกที่ Brose เลือกคลิกที่โฟลเดอร์ AMD แล้วคลิก OK
6. คลิก Start -> Yes รอจนเสร็จแล้วคลิก OK -> Close
7. ก็อบปี้ไฟล์ในโฟลเดอร์ AMD ทั้งหมดไปใส่ในแฟลชไดร์ฟ ถ้าเครื่องบอกว่ามีไฟล์อยู่แล้วให้คลิก Yes to All
................................................................
เสร็จการทำแฟลชไดร์ฟบูตได้ ต่อ่ไปซ่อมอาการ
NTLDR is missing
Prass Ctrl + Alt + Del to restart
1. เข้าไปปรับไบออสให้บูตด้วยแฟลชไดร์ฟ (เมนบอร์ดต้องซัพพอร์ตบูตแฟลชไดร์ฟได้ด้วย)
2. เมื่อออกจากไบออสเครื่องจะรีสตาร์ทใหม่ ปล่อยให้เข้าไปที่ C:> พิมพ์ AMD แล้วกด Enter
3. ปิดเครื่องถอดแฟลชไดร์ฟออก แล้วเปิดใหม่เครื่องตามปกติจะเข้าวินโดวส์ได้
ดาวน์โหลดโปรแกรมที่นี่ครับ http://www.free4up.com/show.php?img=12875_AMD.zip.html
.................................................................
ชุดที่ 2
ทำ CD-ROM บูตได้ใช้สำหรับแก้อาการ
NTLDR is missing
Prass Ctrl + Alt + Del to restart
..................................................................
วิธีทำ CD-ROM บูตได้
1. เอาแผ่น CD-ROM เปล่าใส่ไว้ในเครื่องเขียน
2. แตกซิบ CD_Repair.zip ออก
3. ดับเบิ้ลคลิกไฟล์ CD Repair.nrg
4. คลิกเลือก Write Speed
5. คลิกเลือกวิธีเขียนเป็น Disk-at-once
6. คลิก Burn
7. รอจนเครื่องเขียนเสร็จ คลิก ตกลง แล้วปิดหน้าต่างทั้งหมด
..................................................................
เสร็จการทำ CD-ROM บูตได้แล้ว ต่อ่ไปซ่อมอาการ
NTLDR is missing
Prass Ctrl + Alt + Del to restart
1. เข้าไปปรับไบออสให้บูตด้วย CD-ROM
2. เมื่อออกจากไบออสเครื่องจะรีสตาร์ทใหม่ ปล่อยให้เข้าไปที่ A:> พิมพ์ AMD แล้วกด Enter
3. เอาแผ่น CD-ROM ออกจากเครื่องอ่าน แล้วรีสตร์ทเครื่องตามปกติจะเข้าวินโดวส์ได้
ดาวน์โหลดที่นี่ครับ http://www.free4up.com/show.php?img=12876_CDRepair.zip.html
..................................................................
แนะนำสำหรับเครื่องรุ่นเก่าที่ไม่สามารถบูตด้วยแฟลชไดร์ฟได้ ให้ใช้แบบ CD-ROM จะใช้ได้ทุกเครื่องครับผม
ลองแล้วได้ผลประการใดช่วยแจ้งให้ทราบด้วยเพื่อจะหาแนวทางแก้ไขปรับปรุงต่อไป จักขอบพระคุณเป็นอย่างสูงครับผม.
จากคุณ : AMD (ไม่นิยมอินเทล) -[ 27 ม.ค. 52 - 18:47:52 A:118.174.46.74 X: ]
วันพุธที่ 28 มกราคม พ.ศ. 2552
compile kernel freebsd 7 ให้รองรับ adsl
# cd /usr/local/src/sys/i386/conf // เข้าไปยังห้อง /usr/src/sys/i386/conf
# cp GENERIC WIFI // คัดลอกไฟล์ GENERIC เป็นไฟล์ใหม่คือ WIFI
# pico WIFI แล้วพิมพ์คำสั่ง options ต่าง ๆ ดังนี้ * ห้ามพิมพ์ผิดนะครับ ผมเตือนแล้วนะ *
ident WIFI
options IPFIREWALL
options IPFIREWALL_FORWARD
options IPFIREWALL_DEFAULT_TO_ACCEPT
options IPFIREWALL_VERBOSE
options IPFIREWALL_VERBOSE_LIMIT=100
options IPDIVERT
options ALTQ
options ALTQ_CBQ
options ALTQ_RED
options ALTQ_RIO
options ALTQ_HFSC
options ALTQ_PRIQ
options ALTQ_NOPCC
device pf
device pflog
device pfsync
#สำหรับอินเตอร์เน็ตระบบ ADSL ต้องเพิ่มคำสั่ง options เพิ่มเติมคือ
options NETGRAPH
options NETGRAPH_ASYNC
options NETGRAPH_BPF
options NETGRAPH_ECHO
options NETGRAPH_CISCO
options NETGRAPH_FRAME_RELAY
options NETGRAPH_HOLE
options NETGRAPH_IFACE
options NETGRAPH_LMI
options NETGRAPH_MPPC_ENCRYPTION
options NETGRAPH_PPP
options NETGRAPH_PPTPGRE
options NETGRAPH_RFC1490
options NETGRAPH_KSOCKET
options NETGRAPH_TEE
options NETGRAPH_TTY
options NETGRAPH_UI
options NETGRAPH_VJC
options NETGRAPH_ETHER
options NETGRAPH_SOCKET
options NETGRAPH_PPPOE
options IPFIREWALL
options IPFIREWALL_FORWARD
options IPFIREWALL_DEFAULT_TO_ACCEPT
options IPFIREWALL_VERBOSE
options IPFIREWALL_VERBOSE_LIMIT=100
options IPDIVERT
options BRIDGE
#options DUMMYNET // FreeBSD7 ไม่รู้จัก options นี้
#options NMBCLUSTERS // FreeBSD7 ไม่รู้จัก options นี้
options HZ=1000
บันทึกไฟล์ กดปุ่ม Ctrl + o ตามด้วยปุ่ม Enter และออกจากการแก้ไขกดปุ่ม Ctrl + x
# config WIFI
# cd ../compile/WIFI
# make cleandepend;make depend;make;make install
# cp GENERIC WIFI // คัดลอกไฟล์ GENERIC เป็นไฟล์ใหม่คือ WIFI
# pico WIFI แล้วพิมพ์คำสั่ง options ต่าง ๆ ดังนี้ * ห้ามพิมพ์ผิดนะครับ ผมเตือนแล้วนะ *
ident WIFI
options IPFIREWALL
options IPFIREWALL_FORWARD
options IPFIREWALL_DEFAULT_TO_ACCEPT
options IPFIREWALL_VERBOSE
options IPFIREWALL_VERBOSE_LIMIT=100
options IPDIVERT
options ALTQ
options ALTQ_CBQ
options ALTQ_RED
options ALTQ_RIO
options ALTQ_HFSC
options ALTQ_PRIQ
options ALTQ_NOPCC
device pf
device pflog
device pfsync
#สำหรับอินเตอร์เน็ตระบบ ADSL ต้องเพิ่มคำสั่ง options เพิ่มเติมคือ
options NETGRAPH
options NETGRAPH_ASYNC
options NETGRAPH_BPF
options NETGRAPH_ECHO
options NETGRAPH_CISCO
options NETGRAPH_FRAME_RELAY
options NETGRAPH_HOLE
options NETGRAPH_IFACE
options NETGRAPH_LMI
options NETGRAPH_MPPC_ENCRYPTION
options NETGRAPH_PPP
options NETGRAPH_PPTPGRE
options NETGRAPH_RFC1490
options NETGRAPH_KSOCKET
options NETGRAPH_TEE
options NETGRAPH_TTY
options NETGRAPH_UI
options NETGRAPH_VJC
options NETGRAPH_ETHER
options NETGRAPH_SOCKET
options NETGRAPH_PPPOE
options IPFIREWALL
options IPFIREWALL_FORWARD
options IPFIREWALL_DEFAULT_TO_ACCEPT
options IPFIREWALL_VERBOSE
options IPFIREWALL_VERBOSE_LIMIT=100
options IPDIVERT
options BRIDGE
#options DUMMYNET // FreeBSD7 ไม่รู้จัก options นี้
#options NMBCLUSTERS // FreeBSD7 ไม่รู้จัก options นี้
options HZ=1000
บันทึกไฟล์ กดปุ่ม Ctrl + o ตามด้วยปุ่ม Enter และออกจากการแก้ไขกดปุ่ม Ctrl + x
# config WIFI
# cd ../compile/WIFI
# make cleandepend;make depend;make;make install
syslog-ng ส่งไฟล์ http กับ ssh ด้วย
ว่าด้วย เรื่องของ Syslog-ng กับ ports ต่างๆ ครับ
https ==> 443
smtp ==> 25
ssh ==> 22
squid ก็จะมาจาก access.log ของ squid
---------------------------------------------------------
#tcpdump -n -e port 25
#tcpdump -n -e port 443
#tcpdump -n -e port 22
เท่านี้ก็สามารถ จับ การจาราจร มาลลง syslog-ng ได้แล้วครับ
ใน rc.local นะครับ ต้องการให้ start ตอน boot
-----------------------------------------------------------
เพิ่ม
#สำหรับ เก็บ log ลง squid ครับ
tail -F /usr/local/squid/logs/access.log | logger -t squid -p user.info &
#ssh
tcpdump -n -e port 22 | logger -t ssh -p user.info &
#smtp
tcpdump -n -e port 25 | logger -t smtp -p user.info &
#https
tcpdump -n -e port 443 | logger -t https -p user.info &
เพิ่อ ให้ ตัว syslog ทำการเห้บ log ครับ
syslog-ng.conf
-----------------------------------------------------------
source src { unix-dgram("/var/run/log"); # ตรงนี้มีอย่แล้วนะครับ แก้ไขเพิ่มเติมครับ
unix-dgram("/var/run/logpriv" perm(0600));
udp();
tcp();
internal();
file("/dev/klog");
file("/var/log/auth.log");
# file("/var/log/messages");
};
# เพิ่มเข้าไป ครับ
destination d_squid {
file("/var/log/CentralizeLog-$HOST/$YEAR/$MONTH/squid.$YEAR-$MONTH-$DAY"
owner(root) group(adm) perm(665)
create_dirs(yes)
dir_perm(0775));
};
destination d_ssh {
file("/var/log/CentralizeLog-$HOST/$YEAR/$MONTH/ssh.$YEAR-$MONTH-$DAY"
owner(root) group(adm) perm(665)
create_dirs(yes)
dir_perm(0775));
};
destination d_smtp {
file("/var/log/CentralizeLog-$HOST/$YEAR/$MONTH/smtp.$YEAR-$MONTH-$DAY"
owner(root) group(adm) perm(665)
create_dirs(yes)
dir_perm(0775));
};
destination d_https {
file("/var/log/CentralizeLog-$HOST/$YEAR/$MONTH/https.$YEAR-$MONTH-$DAY"
owner(root) group(adm) perm(665)
create_dirs(yes)
dir_perm(0775));
};
#เพิ่มครับ
filter f_squid { program("squid") and facility(user); };
log { source(src); filter(f_squid); destination(d_squid); };
filter f_ssh { program("ssh") and facility(user); };
log { source(src); filter(f_ssh); destination(d_ssh); };
filter f_smtp { program("smtp") and facility(user); };
log { source(src); filter(f_smtp); destination(d_smtp); };
filter f_https { program("https") and facility(user); };
log { source(src); filter(f_https); destination(d_https); };
** /var/log/CentralizeLog-$HOST/$YEAR/$MONTH/https.$YEAR-$MONTH-$DAY <--- ตรงนี้คือที่อยู่ไฟล์ log นะครับ สามารถเปลี่ยนแปลงได้
https ==> 443
smtp ==> 25
ssh ==> 22
squid ก็จะมาจาก access.log ของ squid
---------------------------------------------------------
#tcpdump -n -e port 25
#tcpdump -n -e port 443
#tcpdump -n -e port 22
เท่านี้ก็สามารถ จับ การจาราจร มาลลง syslog-ng ได้แล้วครับ
ใน rc.local นะครับ ต้องการให้ start ตอน boot
-----------------------------------------------------------
เพิ่ม
#สำหรับ เก็บ log ลง squid ครับ
tail -F /usr/local/squid/logs/access.log | logger -t squid -p user.info &
#ssh
tcpdump -n -e port 22 | logger -t ssh -p user.info &
#smtp
tcpdump -n -e port 25 | logger -t smtp -p user.info &
#https
tcpdump -n -e port 443 | logger -t https -p user.info &
เพิ่อ ให้ ตัว syslog ทำการเห้บ log ครับ
syslog-ng.conf
-----------------------------------------------------------
source src { unix-dgram("/var/run/log"); # ตรงนี้มีอย่แล้วนะครับ แก้ไขเพิ่มเติมครับ
unix-dgram("/var/run/logpriv" perm(0600));
udp();
tcp();
internal();
file("/dev/klog");
file("/var/log/auth.log");
# file("/var/log/messages");
};
# เพิ่มเข้าไป ครับ
destination d_squid {
file("/var/log/CentralizeLog-$HOST/$YEAR/$MONTH/squid.$YEAR-$MONTH-$DAY"
owner(root) group(adm) perm(665)
create_dirs(yes)
dir_perm(0775));
};
destination d_ssh {
file("/var/log/CentralizeLog-$HOST/$YEAR/$MONTH/ssh.$YEAR-$MONTH-$DAY"
owner(root) group(adm) perm(665)
create_dirs(yes)
dir_perm(0775));
};
destination d_smtp {
file("/var/log/CentralizeLog-$HOST/$YEAR/$MONTH/smtp.$YEAR-$MONTH-$DAY"
owner(root) group(adm) perm(665)
create_dirs(yes)
dir_perm(0775));
};
destination d_https {
file("/var/log/CentralizeLog-$HOST/$YEAR/$MONTH/https.$YEAR-$MONTH-$DAY"
owner(root) group(adm) perm(665)
create_dirs(yes)
dir_perm(0775));
};
#เพิ่มครับ
filter f_squid { program("squid") and facility(user); };
log { source(src); filter(f_squid); destination(d_squid); };
filter f_ssh { program("ssh") and facility(user); };
log { source(src); filter(f_ssh); destination(d_ssh); };
filter f_smtp { program("smtp") and facility(user); };
log { source(src); filter(f_smtp); destination(d_smtp); };
filter f_https { program("https") and facility(user); };
log { source(src); filter(f_https); destination(d_https); };
** /var/log/CentralizeLog-$HOST/$YEAR/$MONTH/https.$YEAR-$MONTH-$DAY <--- ตรงนี้คือที่อยู่ไฟล์ log นะครับ สามารถเปลี่ยนแปลงได้
วันอาทิตย์ที่ 25 มกราคม พ.ศ. 2552
syslog -ng สู่ mysql ของครูมานิสและท่านยิม
ยกเครดิตให้ คุณยิมครับ ที่ช่วยผมทำจนสำเร็จ ดังนี้
ตั้งค่าให้ FreeBSD 7.0 ส่ง log files
log# cd /usr/ports/sysutils/syslog-ng
log# make & make install
แก้ไขไฟล์ /etc/rc.conf ดังนี้
log# pico /etc/rc.conf
แล้วพิมพ์คำสั่งดังนี้
syslogd_enable="NO"
syslog_ng_enable="YES"
log# kill ‘cat /var/run/syslog.pid’
คัดลอกไฟล์ syslog-ng.conf.sample เป็นไฟล์ syslog-ng.conf ดังนี้
log# cp /usr/local/etc/syslog-ng/syslog-ng.conf.sample /usr/local/etc/syslog-ng/syslogng.conf
สั่งให้ syslog-ng ทำงาน ด้วยคําสั่ง
log# /usr/local/etc/rc.d/syslog-ng start
สร้างฐานข้อมูลชื่อว่า syslog และนำเข้าตาราง log ดังนี้
log # mysql –u root -p’พิมพ์รหัส root mysql’
Mysql> create database syslog;
Mysql> use syslog;
Mysql> แล้วพิมพ์คำสั่งสร้างตารางต่อไปนี้
CREATE TABLE `log` (
`host` varchar(32) collate tis620_bin default NULL,
`facility` varchar(10) collate tis620_bin default NULL,
`priority` varchar(10) collate tis620_bin default NULL,
`level` varchar(10) collate tis620_bin default NULL,
`tag` varchar(10) collate tis620_bin default NULL,
`datetime` datetime default NULL,
`program` varchar(15) collate tis620_bin default NULL,
`msg` text collate tis620_bin,
`seq` bigint(20) unsigned NOT NULL auto_increment,
PRIMARY KEY (`seq`),
KEY `host` (`host`),
KEY `program` (`program`),
KEY `datetime` (`datetime`),
KEY `priority` (`priority`),
KEY `facility` (`facility`)
) ENGINE=InnoDB DEFAULT CHARSET=tis620 COLLATE=tis620_bin;
วิธีการทำให้ syslog-ng เก็บ log ลง mysql
ตามพระราชบัญญัติว่าด้วยการกระทำความผิดทางคอมพิวเตอร์ พ.ศ. 2550 ได้ให้ทุกองค์กร ทุกหน่วยงาน ทั้งภาครัฐและเอกชน ได้ จัดเก็บ log files การใช้งานต่าง ๆ ของผู้ใช้งานอินเตอร์เน็ตอย่างน้อย 90 วัน และจัดทำระบบแสดงตัวตนผู้ใช้งานอินเตอร์เน็ต
คุณธนกร (yim) ได้เขียนบทความนี้เผยแพร่ที่เว็บบร์ด ThaiBSD ว่าหลังจากติดตั้ง syslog-ng แล้ว ให้แก้ไขไฟล์ config ต่าง ๆ ของ syslog-ng ดังต่อไปนี้
log# pico /usr/local/etc/syslog-ng/syslog-ng.conf แล้วเพิ่มคำสั่งต่อไปนี้ เข้าไปนำไฟล์ /usr/local/etc/syslog-ng/syslog-ng.conf ตรงบรรทัด # sources
source src { unix-dgram("/var/run/log");
unix-dgram("/var/run/logpriv" perm(0600));
#udp();
internal();
file("/dev/klog"); };
#
# destinations
#
##################################################
destination ipfw { file("/var/log/ipfw/ipfw.log"); };
filter f_ipfw { program("ipfw"); };
log { source(src); destination(d_mysql); };
destination d_mysql {
pipe("/var/log/mysql.pipe"
template("INSERT INTO log
(host, facility, priority, level, tag, datetime, program, msg,seq)
VALUES ( '$HOST', '$FACILITY', '$PRIORITY',
'$LEVEL', '$TAG','$YEAR-$MONTH-$DAY
$HOUR:$MIN:$SEC','$PROGRAM', '$MSG',null );\n\n") template-escape(yes));
};
###############################################################
log# pico /etc/syslog.conf พิมพ์คำสั่งต่อไปนี้ เพิ่มเข้าไปท้ายไฟล์
!ipfw
*.* /var/log/ipfw/ipfw.log
log# pico /usr/local/etc/syslog-ng/syslog2mysql.sh แล้วพิมพ์คำสั่งต่อไปนี้
#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin
if [ ! -e /var/log/mysql.pipe ]
then
mkfifo /var/log/mysql.pipe
fi
while [ -e /var/log/mysql.pipe ]
do
/usr/local/bin/mysql -uroot -pพิมพ์รหัส rootmysql syslog < /var/log/mysql.pipe > /var/log/sql.log
done
log# pico /etc/rc.local พิมพ์คำสั่งเพิ่มเข้าไป ดังนี้
/usr/local/sbin/chilli &
ipfw add 65200 allow log all from any to any // พิมพ์คำสั่งเพิ่มบรรทัดนี้
/bin/sh /usr/local/etc/syslog-ng/syslog2mysql.sh & // พิมพ์คำสั่งเพิ่มบรรทัดนี้
ipfw add pass tcp from any to any 3990 via setup
/usr/local/sbin/RunCache &
ipfw add 1700 fwd 10.0.0.1 tcp from any to 10.0.0.0/24 80
ipfw add 1800 fwd 10.0.0.1,8080 tcp from 10.0.0.0/24 to any 80
ขั้นต่อไปดาวโหลดโปรแกรมแสดง syslog ที่เว็บไซต์ http://www.kroonis.org/log.rar
หลังจากดาวโหลดไฟล์โปรแกรมแสดง log ได้แล้ว ให้แตกไฟล์จะได้โพลเดอร์ syslog ให้อับโหลดโพลเดอร์ syslog ไปไว้ที่ห้อง /usr/local/www/apache22/data/ จากนั้นแก้ไขการติดต่อกับฐานข้อมูล ดังนี้
log# pico /usr/local/www/apache22/data/syslog/Connections/dbconnect.php
แล้วแก้ไขการเชื่อมต่อกับฐานข้อมูล syslog ดังนี้
$hostname_syslog = "127.0.0.1";
$database_syslog = "syslog";
$username_syslog = "root";
$password_syslog= "พิมพ์รหัส rootmysql"; // แก้ไขรหัสของ rootmysql
log# shutdown -r now สั่ง reboot server เพื่อให้โปรแกรม syslog-ng ทำงาน
ตรวจสอบ syslong-ng ส่ง log files ไปเก็บไว้ที่ฐานข้อมูล syslog ได้หรือยัง ให้เรียกโปรแกรม phpMyAdmin ขึ้นมาใช้งาน
เปิดดู log files ผ่านเว็บ Admin โดยพิมพ์ที่ช่อง Address ว่า
10.0.0.1/syslog แล้วกดปุ่ม Enter ก็จะพบรายการ log ที่ syslog-ng ส่งไปเก็บไว้ที่ mysql
พ.ร.บ. ว่าด้วยการกระทำความผิดทางคอมพิวเตอร์ พ.ศ. ระบุว่าให้จัดเก็บ Log File ให้ครบ 90 วัน และบอกให้ได้ว่า ใคร ทำอะไร ที่ไหน อย่างไร ใช้ port ไหน
ถ้าทำได้ตามนี้ ก็รองรับ พ.ร.บ. แล้วครับ
-------------------------------------------------------------
ถ้าท่านใด ทำได้แล้ว นำมาแบ่งปันด้วยนะครับ .... อยากให้ syslog-ng เก็บข้อมูลจาก squid ไปยัง mysql ด้วยครับ ถ้าทำได้แล้ว บอกต่อด้วยนะครั ขอบคุณมากครับ
ตั้งค่าให้ FreeBSD 7.0 ส่ง log files
log# cd /usr/ports/sysutils/syslog-ng
log# make & make install
แก้ไขไฟล์ /etc/rc.conf ดังนี้
log# pico /etc/rc.conf
แล้วพิมพ์คำสั่งดังนี้
syslogd_enable="NO"
syslog_ng_enable="YES"
log# kill ‘cat /var/run/syslog.pid’
คัดลอกไฟล์ syslog-ng.conf.sample เป็นไฟล์ syslog-ng.conf ดังนี้
log# cp /usr/local/etc/syslog-ng/syslog-ng.conf.sample /usr/local/etc/syslog-ng/syslogng.conf
สั่งให้ syslog-ng ทำงาน ด้วยคําสั่ง
log# /usr/local/etc/rc.d/syslog-ng start
สร้างฐานข้อมูลชื่อว่า syslog และนำเข้าตาราง log ดังนี้
log # mysql –u root -p’พิมพ์รหัส root mysql’
Mysql> create database syslog;
Mysql> use syslog;
Mysql> แล้วพิมพ์คำสั่งสร้างตารางต่อไปนี้
CREATE TABLE `log` (
`host` varchar(32) collate tis620_bin default NULL,
`facility` varchar(10) collate tis620_bin default NULL,
`priority` varchar(10) collate tis620_bin default NULL,
`level` varchar(10) collate tis620_bin default NULL,
`tag` varchar(10) collate tis620_bin default NULL,
`datetime` datetime default NULL,
`program` varchar(15) collate tis620_bin default NULL,
`msg` text collate tis620_bin,
`seq` bigint(20) unsigned NOT NULL auto_increment,
PRIMARY KEY (`seq`),
KEY `host` (`host`),
KEY `program` (`program`),
KEY `datetime` (`datetime`),
KEY `priority` (`priority`),
KEY `facility` (`facility`)
) ENGINE=InnoDB DEFAULT CHARSET=tis620 COLLATE=tis620_bin;
วิธีการทำให้ syslog-ng เก็บ log ลง mysql
ตามพระราชบัญญัติว่าด้วยการกระทำความผิดทางคอมพิวเตอร์ พ.ศ. 2550 ได้ให้ทุกองค์กร ทุกหน่วยงาน ทั้งภาครัฐและเอกชน ได้ จัดเก็บ log files การใช้งานต่าง ๆ ของผู้ใช้งานอินเตอร์เน็ตอย่างน้อย 90 วัน และจัดทำระบบแสดงตัวตนผู้ใช้งานอินเตอร์เน็ต
คุณธนกร (yim) ได้เขียนบทความนี้เผยแพร่ที่เว็บบร์ด ThaiBSD ว่าหลังจากติดตั้ง syslog-ng แล้ว ให้แก้ไขไฟล์ config ต่าง ๆ ของ syslog-ng ดังต่อไปนี้
log# pico /usr/local/etc/syslog-ng/syslog-ng.conf แล้วเพิ่มคำสั่งต่อไปนี้ เข้าไปนำไฟล์ /usr/local/etc/syslog-ng/syslog-ng.conf ตรงบรรทัด # sources
source src { unix-dgram("/var/run/log");
unix-dgram("/var/run/logpriv" perm(0600));
#udp();
internal();
file("/dev/klog"); };
#
# destinations
#
##################################################
destination ipfw { file("/var/log/ipfw/ipfw.log"); };
filter f_ipfw { program("ipfw"); };
log { source(src); destination(d_mysql); };
destination d_mysql {
pipe("/var/log/mysql.pipe"
template("INSERT INTO log
(host, facility, priority, level, tag, datetime, program, msg,seq)
VALUES ( '$HOST', '$FACILITY', '$PRIORITY',
'$LEVEL', '$TAG','$YEAR-$MONTH-$DAY
$HOUR:$MIN:$SEC','$PROGRAM', '$MSG',null );\n\n") template-escape(yes));
};
###############################################################
log# pico /etc/syslog.conf พิมพ์คำสั่งต่อไปนี้ เพิ่มเข้าไปท้ายไฟล์
!ipfw
*.* /var/log/ipfw/ipfw.log
log# pico /usr/local/etc/syslog-ng/syslog2mysql.sh แล้วพิมพ์คำสั่งต่อไปนี้
#!/bin/sh
export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin
if [ ! -e /var/log/mysql.pipe ]
then
mkfifo /var/log/mysql.pipe
fi
while [ -e /var/log/mysql.pipe ]
do
/usr/local/bin/mysql -uroot -pพิมพ์รหัส rootmysql syslog < /var/log/mysql.pipe > /var/log/sql.log
done
log# pico /etc/rc.local พิมพ์คำสั่งเพิ่มเข้าไป ดังนี้
/usr/local/sbin/chilli &
ipfw add 65200 allow log all from any to any // พิมพ์คำสั่งเพิ่มบรรทัดนี้
/bin/sh /usr/local/etc/syslog-ng/syslog2mysql.sh & // พิมพ์คำสั่งเพิ่มบรรทัดนี้
ipfw add pass tcp from any to any 3990 via setup
/usr/local/sbin/RunCache &
ipfw add 1700 fwd 10.0.0.1 tcp from any to 10.0.0.0/24 80
ipfw add 1800 fwd 10.0.0.1,8080 tcp from 10.0.0.0/24 to any 80
ขั้นต่อไปดาวโหลดโปรแกรมแสดง syslog ที่เว็บไซต์ http://www.kroonis.org/log.rar
หลังจากดาวโหลดไฟล์โปรแกรมแสดง log ได้แล้ว ให้แตกไฟล์จะได้โพลเดอร์ syslog ให้อับโหลดโพลเดอร์ syslog ไปไว้ที่ห้อง /usr/local/www/apache22/data/ จากนั้นแก้ไขการติดต่อกับฐานข้อมูล ดังนี้
log# pico /usr/local/www/apache22/data/syslog/Connections/dbconnect.php
แล้วแก้ไขการเชื่อมต่อกับฐานข้อมูล syslog ดังนี้
$hostname_syslog = "127.0.0.1";
$database_syslog = "syslog";
$username_syslog = "root";
$password_syslog= "พิมพ์รหัส rootmysql"; // แก้ไขรหัสของ rootmysql
log# shutdown -r now สั่ง reboot server เพื่อให้โปรแกรม syslog-ng ทำงาน
ตรวจสอบ syslong-ng ส่ง log files ไปเก็บไว้ที่ฐานข้อมูล syslog ได้หรือยัง ให้เรียกโปรแกรม phpMyAdmin ขึ้นมาใช้งาน
เปิดดู log files ผ่านเว็บ Admin โดยพิมพ์ที่ช่อง Address ว่า
10.0.0.1/syslog แล้วกดปุ่ม Enter ก็จะพบรายการ log ที่ syslog-ng ส่งไปเก็บไว้ที่ mysql
พ.ร.บ. ว่าด้วยการกระทำความผิดทางคอมพิวเตอร์ พ.ศ. ระบุว่าให้จัดเก็บ Log File ให้ครบ 90 วัน และบอกให้ได้ว่า ใคร ทำอะไร ที่ไหน อย่างไร ใช้ port ไหน
ถ้าทำได้ตามนี้ ก็รองรับ พ.ร.บ. แล้วครับ
-------------------------------------------------------------
ถ้าท่านใด ทำได้แล้ว นำมาแบ่งปันด้วยนะครับ .... อยากให้ syslog-ng เก็บข้อมูลจาก squid ไปยัง mysql ด้วยครับ ถ้าทำได้แล้ว บอกต่อด้วยนะครั ขอบคุณมากครับ
วันศุกร์ที่ 23 มกราคม พ.ศ. 2552
TIP เครื่องพิมพ์ HP ชอบ TEST วิธีการไม่ให้ TEST
หลาย ๆ คนประสบปัญหาเครื่องพิมพ์ยี่ห้อ HP INKJET มันชอบ TEST พิมพ์หลังจากเปิดเครื่องใหม่...
วันนี้มีวิธีแก้ไขไม่ให้เครื่องพิมพ์ยี่ห้อ HP TEST PRINT อีก โดยนำกระดาษที่เครื่องพิมพ์ HP พิมพ์ TEST
ออกมา มาวางเพื่อ scan แล้วกด scan ต่อไปเครื่องพิมพ์ HP จะไม่มีการ TEST PRINTING หลังเปิดเครื่องอีกต่อไป
วันนี้มีวิธีแก้ไขไม่ให้เครื่องพิมพ์ยี่ห้อ HP TEST PRINT อีก โดยนำกระดาษที่เครื่องพิมพ์ HP พิมพ์ TEST
ออกมา มาวางเพื่อ scan แล้วกด scan ต่อไปเครื่องพิมพ์ HP จะไม่มีการ TEST PRINTING หลังเปิดเครื่องอีกต่อไป
วันพฤหัสบดีที่ 22 มกราคม พ.ศ. 2552
ไม่ให้ https: ถาม continue อีก
ทิป..แก้ไข https: บน IE ไม่ต้องถาม continue อีก
tools----internet options----advance----เลื่อนมาล่างสุด ตรง Warn about certificate address mismath* จัดการซะ..
จะไ้ด้ไม่ถามอีก
tip จากสมาชิก thaibsd
tools----internet options----advance----เลื่อนมาล่างสุด ตรง Warn about certificate address mismath* จัดการซะ..
จะไ้ด้ไม่ถามอีก
tip จากสมาชิก thaibsd
วันศุกร์ที่ 16 มกราคม พ.ศ. 2552
tip set apache ให้รองรับ utf-8
httpd.conf:
=============
AddCharset UTF-8 .utf8
AddDefaultCharset UTF-8
php.ini
===============
default_charset = "utf-8"
my.cnf
================
character-set-server=utf8
default-collation=utf8_unicode_ci
ทิป อ.กิตติพงษ์ สุวรรณราช แห่ง thaibsd
=============
AddCharset UTF-8 .utf8
AddDefaultCharset UTF-8
php.ini
===============
default_charset = "utf-8"
my.cnf
================
character-set-server=utf8
default-collation=utf8_unicode_ci
ทิป อ.กิตติพงษ์ สุวรรณราช แห่ง thaibsd
ลบกฎใน ipfw
การเขียนกฎ
ipfw add 19 skipto 50 all from 192.168.182.10 to any
ipfw add 19 skipto 50 all from 192.168.182.11 to any
ipfw add 19 skipto 50 all from 192.168.182.12 to any
ipfw add 19 skipto 50 all from 192.168.182.13 to any
วิธีลบกฎต้อง #ipfw list ก่อน
แล้วสั่ง #ipfw del กฎที่ต้องการลบ
ipfw add 19 skipto 50 all from 192.168.182.10 to any
ipfw add 19 skipto 50 all from 192.168.182.11 to any
ipfw add 19 skipto 50 all from 192.168.182.12 to any
ipfw add 19 skipto 50 all from 192.168.182.13 to any
วิธีลบกฎต้อง #ipfw list ก่อน
แล้วสั่ง #ipfw del กฎที่ต้องการลบ
การ kick user ใน radius
การ kick user ที่ค้าง ในระบบ freeradius + chillispot
1.ตรวจสอบ user ว่า ใคร ได้ ip เบอร์อะไร เช่น
john# radwho
Login Name What TTY When From Location
mypun11859 mypun11859 shell S0 Thu 16:24 127.0.0.1 192.168.9.25
tongki28 tongki28 shell S1 Thu 16:05 127.0.0.1 192.168.9.24
gapsf11 gapsf11 shell S2 Thu 16:27 127.0.0.1 192.168.9.26
tjhirjhr tjhirjhr shell S4 Thu 15:59 127.0.0.1 192.168.9.9
ben ben shell S3 Thu 16:49 127.0.0.1 192.168.9.23
Arnon Arnon shell S5 Thu 15:05 127.0.0.1 192.168.9.11
kung kung shell S8 Thu 12:33 127.0.0.1 192.168.9.16
jam jam shell S9 Thu 16:30 127.0.0.1 192.168.9.17
water water shell S10 Thu 16:56 127.0.0.1 192.168.9.18
2.ใช้คำสั่งดังต่อไปนี้ ในการ kick user
Usage: radzap [options] server[:port] secret
-d raddb_directory: directory where radiusd.conf is located
-N nas_ip_address: IP address of the NAS to zap.
-P nas_port: NAS port that the user is logged into.
-u username: Name of user to zap (case insensitive).
-U username: like -u, but case-sensitive.
-x : more debugging output
เช่น
john# radzap -u tataza localhost testing123 ใช้ kick user ที่ชื่อ tataza ที่ค้างในระบบ
john# radzap -P 192.168.9.19 localhost testing123 ใช้ kick user ที่ IP 192.168.9.1 ที่ค้างในระบบ
ซึ่งบางครั้ง สั่ง kick ด้วย username ไม่ออก ก็ให้ kick ด้วย IP ตาม option ด้าบน
1.ตรวจสอบ user ว่า ใคร ได้ ip เบอร์อะไร เช่น
john# radwho
Login Name What TTY When From Location
mypun11859 mypun11859 shell S0 Thu 16:24 127.0.0.1 192.168.9.25
tongki28 tongki28 shell S1 Thu 16:05 127.0.0.1 192.168.9.24
gapsf11 gapsf11 shell S2 Thu 16:27 127.0.0.1 192.168.9.26
tjhirjhr tjhirjhr shell S4 Thu 15:59 127.0.0.1 192.168.9.9
ben ben shell S3 Thu 16:49 127.0.0.1 192.168.9.23
Arnon Arnon shell S5 Thu 15:05 127.0.0.1 192.168.9.11
kung kung shell S8 Thu 12:33 127.0.0.1 192.168.9.16
jam jam shell S9 Thu 16:30 127.0.0.1 192.168.9.17
water water shell S10 Thu 16:56 127.0.0.1 192.168.9.18
2.ใช้คำสั่งดังต่อไปนี้ ในการ kick user
Usage: radzap [options] server[:port] secret
-d raddb_directory: directory where radiusd.conf is located
-N nas_ip_address: IP address of the NAS to zap.
-P nas_port: NAS port that the user is logged into.
-u username: Name of user to zap (case insensitive).
-U username: like -u, but case-sensitive.
-x : more debugging output
เช่น
john# radzap -u tataza localhost testing123 ใช้ kick user ที่ชื่อ tataza ที่ค้างในระบบ
john# radzap -P 192.168.9.19 localhost testing123 ใช้ kick user ที่ IP 192.168.9.1 ที่ค้างในระบบ
ซึ่งบางครั้ง สั่ง kick ด้วย username ไม่ออก ก็ให้ kick ด้วย IP ตาม option ด้าบน
วันศุกร์ที่ 9 มกราคม พ.ศ. 2552
ป้องกัน login ซ้ำใน chilli
บทความ FreeBSD
แนะนำเทคนิคป้องกันการ Login ซ้ำ ด้วยชื่อ Login อักษรตัวใหญ่
พุธ ที่ 7 เดือน มกราคม พ.ศ.2552
ตัวอย่าง
user: test , pass :1234 ระบบแจ้งว่า กำลัง login
เปิดมาอีกเครื่อง user : TEST ,pass :1234 login ได้เฉยเลย
วิธีแก้
# pico /usr/local/etc/raddb/radiusd.conf
ค้นหาคำว่า case_sensitive
ให้เราเปลี่ยนจาก case_sensitive =yes เป็น case_sensitive = no
บันทึกไฟล์และออกจากการแก้ไข แล้วสั่งให้ radiusd ทำงานใหม่ด้วยคำสั่ง
# /usr/local/etc/rc.d/radiusd restart
ที่มา : http://www.linuxthai.org/forum/index.php?topic=2364.0
แนะนำเทคนิคป้องกันการ Login ซ้ำ ด้วยชื่อ Login อักษรตัวใหญ่
พุธ ที่ 7 เดือน มกราคม พ.ศ.2552
ตัวอย่าง
user: test , pass :1234 ระบบแจ้งว่า กำลัง login
เปิดมาอีกเครื่อง user : TEST ,pass :1234 login ได้เฉยเลย
วิธีแก้
# pico /usr/local/etc/raddb/radiusd.conf
ค้นหาคำว่า case_sensitive
ให้เราเปลี่ยนจาก case_sensitive =yes เป็น case_sensitive = no
บันทึกไฟล์และออกจากการแก้ไข แล้วสั่งให้ radiusd ทำงานใหม่ด้วยคำสั่ง
# /usr/local/etc/rc.d/radiusd restart
ที่มา : http://www.linuxthai.org/forum/index.php?topic=2364.0
วันอังคารที่ 6 มกราคม พ.ศ. 2552
ปรับ access log ให้อ่านได้
สำหรับ squid 2.5 นะครับ...2.6 อีกวิธีหนึ่ง
ส่วน 2.5
# emulate_httpd_log on
เอาเครื่องหมาย # หน้า emulate_httpd_log on ออก
ส่วน 2.5
# emulate_httpd_log on
เอาเครื่องหมาย # หน้า emulate_httpd_log on ออก
การติดตั้ง phpmyadmin
การติดตั้ง phpmyadmin
ติดตั้งผ่าน port ได้เลย...
copy floder : phpMyAdmin : ไปไว้ห้อง /usr/local/www/apache22/data/phpMyAdmin/
โดย สร้างห้อง phpMyAdmin ไว้ีที่ห้อง data ก่อน จากนั้นหาห้อง phpMyAdmin เข้าไปในห้อง
สั่ง cp -rf * /usr/local/www/apache22/data/phpMyAdmin/
จากนั้น เข้าห้อง phpMyAdmin เข้าห้อง libraries
copy ไฟล์ config.default.php มาไว้ห้อง phpMyAdmin
ทำการ mv ให้เป็นไฟล์ config.inc.php แล้วใช้ pico แก้ไขไฟล์ดังนี้
$cfg['PmaAbsoluteUri'] = 'http://10.0.0.1/phpMyAdmin/';
$cfg['blowfish_secret'] = 'faikwang';
$cfg['Servers'][$i]['auth_type'] = 'http'; // Authenticationmethod (conf$
$cfg['Servers'][$i]['user'] = 'root'; // MySQL user
$cfg['Servers'][$i]['password'] = 'faikwang'; // MySQL password (onl$
แล้วบันทึกไฟล์..ให้เรียบร้อย....
สั่ง chmod 644 ไฟล์ config.inc.php ด้วย
ติดตั้งผ่าน port ได้เลย...
copy floder : phpMyAdmin : ไปไว้ห้อง /usr/local/www/apache22/data/phpMyAdmin/
โดย สร้างห้อง phpMyAdmin ไว้ีที่ห้อง data ก่อน จากนั้นหาห้อง phpMyAdmin เข้าไปในห้อง
สั่ง cp -rf * /usr/local/www/apache22/data/phpMyAdmin/
จากนั้น เข้าห้อง phpMyAdmin เข้าห้อง libraries
copy ไฟล์ config.default.php มาไว้ห้อง phpMyAdmin
ทำการ mv ให้เป็นไฟล์ config.inc.php แล้วใช้ pico แก้ไขไฟล์ดังนี้
$cfg['PmaAbsoluteUri'] = 'http://10.0.0.1/phpMyAdmin/';
$cfg['blowfish_secret'] = 'faikwang';
$cfg['Servers'][$i]['auth_type'] = 'http'; // Authenticationmethod (conf$
$cfg['Servers'][$i]['user'] = 'root'; // MySQL user
$cfg['Servers'][$i]['password'] = 'faikwang'; // MySQL password (onl$
แล้วบันทึกไฟล์..ให้เรียบร้อย....
สั่ง chmod 644 ไฟล์ config.inc.php ด้วย
วันจันทร์ที่ 5 มกราคม พ.ศ. 2552
ezradius เพิ่มเติม
chmod -R 777 /usr/local/www/apache22/data/ezradius
ต้อง changemode ด้วยใน ezradius ถึงจะทำเขียนไฟล์ได้
ต้อง changemode ด้วยใน ezradius ถึงจะทำเขียนไฟล์ได้
วันอาทิตย์ที่ 4 มกราคม พ.ศ. 2552
TIP ช่วยจำแก้ไขไฟล์ register ของม.บูรพาใส่รหัสผ่านตามต้องการ
แก้ไขไฟล์ /admin/register.php ดังนี้
แก้ไขบรรทัด 50 ใหม่เป็น if(strlen($password) < 5) { // เลข 5 คือ จำนวนอักษร รหัสผ่านตั้งแต่ 5 ตัวขึ้นไป
แก้ไขบรรทัด 59 ใหม่เป็น if(strlen($password2) < 5) {
ค้นหาและแทนที่ ข้อความ 8 อักขระครับ เป็น 5 อักขระครับ
TIP จากครูมานิส
แก้ไขบรรทัด 50 ใหม่เป็น if(strlen($password) < 5) { // เลข 5 คือ จำนวนอักษร รหัสผ่านตั้งแต่ 5 ตัวขึ้นไป
แก้ไขบรรทัด 59 ใหม่เป็น if(strlen($password2) < 5) {
ค้นหาและแทนที่ ข้อความ 8 อักขระครับ เป็น 5 อักขระครับ
TIP จากครูมานิส
วันพฤหัสบดีที่ 18 ธันวาคม พ.ศ. 2551
ประชุมกรรมการเขตพื้นที่การศึกษา
วันจันทร์ที่ 3 พฤศจิกายน พ.ศ. 2551
ไปประชุมเชิงปฏิบัติการการจัดทำแผนฯปี 52 - 55
สมัครสมาชิก:
บทความ (Atom)
