วิธี Block spam ด้วย Iptables

rm -rf /root/spamhaus.sh
nano /root/spamhaus.sh
chmod 777 /root/spamhaus.sh
./root/spamhaus.sh

crontab -e

0 3 * * * /root/spamhaus.sh

 

service iptables stop
rm -rf /mnt/iptables
wget –no-check-certificate https://myip.ms/files/blacklist/csf/latest_blacklist.txt -O /mnt/iptables
IPT=/sbin/iptables
SPAMLIST=”spamlist”
SPAMDROPMSG=”SPAM LIST DROP”
BADIPS=$(egrep -v -E “^#|^$” /mnt/iptables)
# create a new iptables list
$IPT -N $SPAMLIST
for ipblock in $BADIPS
do
$IPT -A $SPAMLIST -s $ipblock -j LOG –log-prefix “$SPAMDROPMSG”
$IPT -A $SPAMLIST -s $ipblock -j DROP
done
$IPT -I INPUT -j $SPAMLIST
$IPT -I OUTPUT -j $SPAMLIST
$IPT -I FORWARD -j $SPAMLIST

วิธีติดตั้ง Zabbix Server และ Zabbix agents

วิธีติดตั้ง Zabbix-server

yum -y update
yum -y install httpd httpd-devel
yum -y install mariadb-server mariadb
yum -y install php php-cli php-common php-devel php-pear php-gd php-mbstring php-mysql php-xml

#systemctl start httpd
#systemctl start mariadb.service
#systemctl enable mariadb.service

mysqladmin -u root password 123456
## 123456 ใส่พาสของ dbที่ต้องการ

ติดตั้ง repo zabbix เลือกเอาตาม version centos

CentOS/RHEL 7:
# rpm -Uvh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm

CentOS/RHEL 6:
# rpm -Uvh http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-release-3.2-1.el6.noarch.rpm

CentOS/RHEL 5:
# rpm -Uvh http://repo.zabbix.com/zabbix/3.2/rhel/5/x86_64/zabbix-release-3.2-1.el5.noarch.rpm

 

yum install -y zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-java-gateway

 

#mysql -u root -p
mysql> CREATE DATABASE zabbixdb CHARACTER SET UTF8;
mysql> GRANT ALL PRIVILEGES on zabbixdb.* to zabbix@localhost IDENTIFIED BY ‘zabbix123456’;
mysql> FLUSH PRIVILEGES;
mysql> quit

nano /etc/zabbix/zabbix_server.conf

แก้ config db
DBName=zabbixdb
DBUser=zabbix
DBPassword=Your.Password.Here

cd /usr/share/doc/zabbix-server-mysql-3.2.3
zcat create.sql.gz | mysql -u zabbix -p zabbixdb

 

systemctl start zabbix-server.service
systemctl start zabbix-agent.service
systemctl restart httpd.service
systemctl restart mariadb.service
systemctl enable zabbix-server.service
systemctl enable zabbix-agent.service

แก้ php config
nano /etc/httpd/conf.d/zabbix.conf

php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value date.timezone Asia/Bangkok

systemctl restart httpd

 

Start Zabbix Web Installer

http://localhost/zabbix/
http://127.0.0.1/zabbix/
http://domainname.com/zabbix/

 

วิธีติดตั้งฝั่ง Agent Centos

ติดตั้ง rpm
CentOS/RHEL 7:
# rpm -Uvh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm

CentOS/RHEL 6:
# rpm -Uvh http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-release-3.2-1.el6.noarch.rpm

CentOS/RHEL 5:
# rpm -Uvh http://repo.zabbix.com/zabbix/3.2/rhel/5/x86_64/zabbix-release-3.2-1.el5.noarch.rpm

yum -y install zabbix-agent

nano /etc/zabbix/zabbix_agentd.conf

แก้ Server= เป็นไอพีเครื่อง zabbix server

 

/etc/init.d/zabbix-agent restart

 

วิธีติดคั้ง Agent debian กรณี debian 7 ขึ้นไปเท่านั้น กรณี debian อื่นต้องไปหา repo ใหม่ ใช้ร่วมกับ proxmox ที่ debian 7 ได้
cat /etc/debian_version
wget http://repo.zabbix.com/zabbix/2.0/debian/pool/main/z/zabbix-release/zabbix-release_2.0-1wheezy_all.deb
dpkg -i zabbix-release_2.0-1wheezy_all.deb
apt-get update
apt-get install zabbix-agent
service zabbix-agent restart

 

 

 

เช็คสถานะว่า zabbix เชื่อมต่อได้ไหม ทำจาก zabbix server ไปยัง zabbix agent
yum -y install zabbix-get
/usr/bin/zabbix_get -s ไอพี -p10050 -kagent.version