cat /var/spool/mail/root
check daily log
Posted in Linux command
How to enable second-level quota on VZ VPS
# vzctl set <veid> --quotaugidlimit 500 --save # vzctl restart <veid>
Comments Off
Posted in OpenVZ
Physical server to OpenVZ container
Comments Off
Posted in OpenVZ
How to get the Dell Service Tag Remotely
dmidecode -s system-serial-number
Comments Off
Posted in Linux command
Install Crontab
yum install crontabs vixie-cron
service crond restart
Comments Off
Posted in Linux command
SolusVM On Cent OS 6 error could not find the unix user
login to slave node
echo “6″ > /usr/local/solusvm/data/osversion.dat
upcp
Comments Off
Posted in SolusVM
CentOS Linux install and configure NTP to synchronize the system clock
Login as the root user
Type the following command to install ntp
# yum install ntp
Turn on service
# chkconfig ntpd on
Synchronize the system clock with 0.pool.ntp.org server:
# ntpdate pool.ntp.org
Start the NTP:
# /etc/init.d/ntpd start
To remain updated, you should put a cron entry to sync with time server every midnight:
# crontab -e 0 4 * * * /usr/sbin/ntpdate pool.ntp.org
This will update/correct your time in server at 04:00 am every morning.
Posted in Linux command
ตรวจสอบว่าเครื่องโดนยิง ip
การตรวจสอบว่าเราถูกยิงหรือไม่ผ่านคำสั่ง netstat
หลายๆ คนคงรู้วิธีใช้งาน netstat กันบ้างแล้ว คราวนี้จะมาดูวิธีการใช้งาน netstat อย่างประยุคๆ หน่อย
— การใช้ netstat ตรวจสอบการถูกยิงด้วย syn
คำสั่ง
netstat -ntu | grep SYN_RECV | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -nr
อันนี้จะบอกว่า ณ ขณะเวลานั้นๆ มีคนส่ง syn เข้ามาเพื่อขอเชื่อมกับ server ของเรา โดยปกติไม่ควรเกิน 10 ครั้งต่อ 1 IP หากเกินกว่านั้นท่าน Block ได้เลย
– การใช้ netstat นับจำนวน connetion ของแต่ละ IP
คำสั่ง
netstat -ntu | grep ESTABLISHED | awk ‘{print $5}’ | cut -d: -f1 | sort | uniq -c | sort -nr
อันนี้จะบอกว่า ณ ขณะเวลานั้นๆ แต่ละ IP มีการเชื่อมต่อกับเรากี่ connetion โดยปกติไม่ควรเกิน 10-20 ครั้งต่อ 1 IP หากเกินกว่านั้นท่าน Block ได้เลย
การใช้ netstat ตรวจสอบได้กับ tcp จะง่าย แต่ถ้าเป็น udp icmp ผมจะใช้โปรแกรม iptraf ช่วยอีกแรง ดูง่ายหน่อย
ติดตั้ง yum -y install iptraf
วิธีใช้พิมพ์คำสั่ง iptraf จากนั้นดูว่ามี packet udp icmp วิงผิดปกติหรือเปล่า ถ้ามีก็ดู ip นั้นๆ แล้วนำมา block
ตัวอย่าง การ Block ก็ง่ายๆ ไม่ยากด้วย iptables
iptables -A INPUT -s xxx.xxx.xxx.xxx -j DROP ความหมาย -A = เพิ่ม (add), -s = IP ต้นทาง, -j DROP = Block IP นั้นซ่ะ
Block เป็น class
iptables -A INPUT -s xxx.xxx.xxx.xxx/xx -j DROP
Block เป็น Protocal
iptables -A INPUT -p udp –dport 80 -j DROP ความหมาย -p = เลือก Protocal ที่ต้องการ (udp,tcp) , –dpoprt = Port ปลายทาง, –spoprt = Port ต้นทางทาง
แล้ว ก็ฝากเตือนทุกๆ คนที่ server โดยยิง ไม่ว่าจะอย่างไรห้ามยิงกลับเป็นอันขาดนะครับ ต้องป้องกันให้ดีที่สุด เก็บ log แล้วก็แจ้งความเท่านั้นนะครับ เพราะถ้าเรายิงกลับเราจะเป็นฝ่ายที่โดนจับเสียเอง
Posted in Linux command
Openvz Enable TUN/TAP OpenVPN
Make sure the module “tun” is loaded on the host.
vzctl exec 2000 mkdir -p /dev/net
vzctl exec 2000 mknod /dev/net/tun c 10 200
vzctl exec 2000chmod 600 /dev/net/tun
On the container test the device:
when Something is wrong:
cat /dev/net/tun
cat: /dev/net/tun: Permission denied
It’s right and ready to use:
cat /dev/net/tun
cat: /dev/net/tun: File descriptor in bad state
Posted in OpenVPN
Check Current IP on server
wget -q -O - checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
Comments Off
Posted in Linux command