Ban:
iptables -I INPUT -s 25.55.55.55 -j DROP
IP位置
Unban:
iptables -D INPUT -s 25.55.55.55 -j DROP
IP位置
iptables -D fail2ban-dovecot -s 192.168.1.XX -j DROP
哪個規則 IP位置
service iptables save
查看目前規則
iptables -L
以log查詢IP登入次數
tail -10000 /var/log/httpd/access_log | awk '{print $1}' | sort | uniq -c | sort -n | tail
最後10000次 哪個log
實際執行結果如下
2012-11-28
2012-11-27 Mail Server異常處理
Mail Server環境為Linux CentOS 6.3
有安裝之服務為postfix+dovecot+MailScanner+clamav+SpamAssassin+MailWatch+monitorix+fail2ban+OpenWebMail
16:30左右 user反應15:00寄出之信件對方遲遲未收到
下指令mailq,queue內有2000多封信件,其中包含多封垃圾信
看起來所有信件都卡在/var/spool/postfix/hold/內
下指令指定內容包含MAILER-DAEMON則由mail queue內刪除
mailq | tail -n +2 | awk 'BEGIN { RS = "" } / MAILER-DAEMON/ { print $1 }' | tr -d '*!' | postsuper -d -
把所有附加服務關閉無效
vi /etc/MailScanner/MailScanner.conf
Use SpamAssassin = no
Virus Scanning = no
Virus Scanners = none
vi /etc/postfix/main.cf
註解header_checks = regexp:/etc/postfix/header_checks
信是可以正常寄,但先前卡在queue內的信不會重寄
之後init 6重開Server後又可以正常收發,問題無解
期間有使用yum update,反而收信時有錯誤訊息
ERR [IN-USE] Internal error occurred. Refer to server log for more information
檢查原因為dovecot update後新設定值不會蓋掉舊設定值,反而產生dovecot.conf.rpmnew檔案
手動覆蓋更改設定後就恢復正常
隔天看/var/log/maillog
有多次錯誤訊息為
localhost MailScanner[3966]: Failed to read configuration file /etc/MailScanner/MailScanner.conf
有安裝之服務為postfix+dovecot+MailScanner+clamav+SpamAssassin+MailWatch+monitorix+fail2ban+OpenWebMail
mailq | tail -n +2 | awk 'BEGIN { RS = "" } / MAILER-DAEMON/ { print $1 }' | tr -d '*!' | postsuper -d -
vi /etc/MailScanner/MailScanner.conf
Use SpamAssassin = no
Virus Scanning = no
Virus Scanners = none
之後init 6重開Server後又可以正常收發,問題無解
期間有使用yum update,反而收信時有錯誤訊息
ERR [IN-USE] Internal error occurred. Refer to server log for more information
檢查原因為dovecot update後新設定值不會蓋掉舊設定值,反而產生dovecot.conf.rpmnew檔案
手動覆蓋更改設定後就恢復正常
隔天看/var/log/maillog
有多次錯誤訊息為
localhost MailScanner[3966]: Failed to read configuration file /etc/MailScanner/MailScanner.conf
是否有可能為MailScanner.conf壞掉或權限問題?
2012-11-26
vsftpd設定
[root@CentOS /]# vi /etc/vsftpd/vsftpd.conf
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=002
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
chroot_local_user=YES
chroot_list_enable=YES
#可離開家目錄的帳號列表
chroot_list_file=/etc/vsftpd/chroot_list
listen=YES
pam_service_name=vsftpd
userlist_enable=YES
userlist_deny=NO
#允許連線的帳號列表
userlist_file=/etc/vsftpd/user_list
tcp_wrappers=YES
#Custom
local_max_rate=307200
use_localtime=YES
banner_file=/etc/vsftpd/welcome.txt
max_clients=3
max_per_ip=2
#指定帳號登陸後之目錄
user_config_dir=/etc/vsftpd/userconf
[root@CentOS /]# mkdir /etc/vsftpd/userconf/
[root@CentOS /]# vi /etc/vsftpd/userconf/帳號
內容為指定目錄
例如local_root=/var/www/html
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=002
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
chroot_local_user=YES
chroot_list_enable=YES
#可離開家目錄的帳號列表
chroot_list_file=/etc/vsftpd/chroot_list
listen=YES
pam_service_name=vsftpd
userlist_enable=YES
userlist_deny=NO
#允許連線的帳號列表
userlist_file=/etc/vsftpd/user_list
tcp_wrappers=YES
#Custom
local_max_rate=307200
use_localtime=YES
banner_file=/etc/vsftpd/welcome.txt
max_clients=3
max_per_ip=2
#指定帳號登陸後之目錄
user_config_dir=/etc/vsftpd/userconf
[root@CentOS /]# mkdir /etc/vsftpd/userconf/
[root@CentOS /]# vi /etc/vsftpd/userconf/帳號
內容為指定目錄
例如local_root=/var/www/html
VirtualBox CentOS中安裝Guest Additions步驟
Step1:
開啟安裝於VirtualBox上的 CentOS ,然後點選虛擬機器的裝置選項,
並且點擊 安裝Guest Additions 選項。點擊後,桌面上應該會出現光碟機掛載虛擬光碟
VBOXADDITIONS 的顯示。
Step2:安裝kernel-devel 與 gcc 套件
開啟終端機,輸入以下指令:
[root@localhost ~]# yum install kernel-devel -y
[root@localhost ~]# yum install kernel sources -y
[root@localhost ~]# yum install gcc -y
Step3:
[root@localhost ~]# export MAKE='/usr/bin/gmake -i'
[root@localhost ~]# cd /media/VBOXADDITIONS_4.0.4_70112/
[root@localhost VBOXADDITIONS_4.0.4_70112]# sh VBoxLinuxAdditions.run
完成後,重新啟動 CentOS
就可以調整解析度到1024x768的解析度了。
******若無export MAKE='/usr/bin/gmake -i'將導致Building the OpenGL support module時出現錯誤。******
參考:
http://home.gamer.com.tw/creationDetail.php?sn=1281316
http://victe.blogspot.com/2012/01/centos-62-x8664-minimalsudovboxguestadd.html
開啟安裝於VirtualBox上的 CentOS ,然後點選虛擬機器的裝置選項,
並且點擊 安裝Guest Additions 選項。點擊後,桌面上應該會出現光碟機掛載虛擬光碟
VBOXADDITIONS 的顯示。
Step2:安裝kernel-devel 與 gcc 套件
開啟終端機,輸入以下指令:
[root@localhost ~]# yum install kernel-devel -y
[root@localhost ~]# yum install kernel sources -y
[root@localhost ~]# yum install gcc -y
Step3:
[root@localhost ~]# export MAKE='/usr/bin/gmake -i'
[root@localhost ~]# cd /media/VBOXADDITIONS_4.0.4_70112/
[root@localhost VBOXADDITIONS_4.0.4_70112]# sh VBoxLinuxAdditions.run
完成後,重新啟動 CentOS
就可以調整解析度到1024x768的解析度了。
******若無export MAKE='/usr/bin/gmake -i'將導致Building the OpenGL support module時出現錯誤。******
參考:
http://home.gamer.com.tw/creationDetail.php?sn=1281316
http://victe.blogspot.com/2012/01/centos-62-x8664-minimalsudovboxguestadd.html
Roundcube無法登入
修改/etc/dovecot/conf.d/10-auth.conf
auth_username_format = %n
參考http://webcache.googleusercontent.com/search?q=cache:LivXu84v2C8J:www.extmail.org/forum/viewthread.php%3Ftid%3D8425+roundcube+%E7%99%BB%E5%85%A5+%3D%25n&cd=1&hl=zh-TW&ct=clnk&gl=tw
auth_username_format = %n
參考http://webcache.googleusercontent.com/search?q=cache:LivXu84v2C8J:www.extmail.org/forum/viewthread.php%3Ftid%3D8425+roundcube+%E7%99%BB%E5%85%A5+%3D%25n&cd=1&hl=zh-TW&ct=clnk&gl=tw
Linux使用rsync同步資料
主機端:
[root@localhost]# vi /etc/rsyncd.conf
[mail]
path = /var/spool/mail
auth users =root
uid =root
gid =root
secrets file = /etc/rsyncd.secrets
read only = yes
[home]
path = /home
auth users = root #代表授權的帳號(設在rsyncd.secrets的帳號)
uid = root #以uid root來啟動rsync server
gid = root #以gid wheel來啟動rsync server
secrets file = /etc/rsyncd.secrets
read only = yes
[root@localhost etc]# vi rsyncd.secrets
root:password
備份server端:
[root@backupserver]# vi /etc/rsyncd.secrets
password
[root@backupserver]# chmod 600 /etc/rsyncd.secrets
[root@backupserver]# crontab -e
30 6 * * * /usr/bin/rsync -avrHS --password-file=/etc/rsyncd.secrets root@192.168.X.X::mail /var/spool/mail
30 7 * * * /usr/bin/rsync -avrHS --password-file=/etc/rsyncd.secrets root@192.168.X.X::home /home
[root@localhost]# vi /etc/rsyncd.conf
[mail]
path = /var/spool/mail
auth users =root
uid =root
gid =root
secrets file = /etc/rsyncd.secrets
read only = yes
[home]
path = /home
auth users = root #代表授權的帳號(設在rsyncd.secrets的帳號)
uid = root #以uid root來啟動rsync server
gid = root #以gid wheel來啟動rsync server
secrets file = /etc/rsyncd.secrets
read only = yes
[root@localhost etc]# vi rsyncd.secrets
root:password
備份server端:
[root@backupserver]# vi /etc/rsyncd.secrets
password
[root@backupserver]# chmod 600 /etc/rsyncd.secrets
[root@backupserver]# crontab -e
30 6 * * * /usr/bin/rsync -avrHS --password-file=/etc/rsyncd.secrets root@192.168.X.X::mail /var/spool/mail
30 7 * * * /usr/bin/rsync -avrHS --password-file=/etc/rsyncd.secrets root@192.168.X.X::home /home
【參考資料】
http://contest.ks.edu.tw/syshtml/freebsd-rsync.html
2012-11-22
samba伺服器
[global]
display charset = UTF8
dos charset = CP950
unix charset = UTF8
workgroup = MYGROUP
netbios name = MY_SAMBA# ← 可以把名字改成自己喜歡的名字
server string = Samba Server Version %v
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536
hosts allow = 192.168. # 預設內網才能用
security = USER
log file = /var/log/samba/log.%m
max log size = 50
load printers = No
printing = bsd
create mask = 0644
directory mask = 0755
dead time = 15
getwd cache = yes
# 想要存取哪個目錄,就加上底下 5 行,更改 [名稱] 跟目錄 (path=)
[SOMEWHERE]
path = /some/where
valid users =# ←允許存取的帳號寫在這裡,多個以逗點隔開
force user = root
read only = No
2.接著利用指令「smbpasswd」,一一設定 SAMBA 伺服器中每個帳號的密碼:
e.g.,
在 Linux 主機掛載 Windows 檔案系統
[root@CentOS ~]# vi /etc/fstab
加入
\\192.168.1.x\Shared /Shared cifs user,uid=500,rw,suid,username=username,password=password 0 0
完成後可用mount -a看看有無錯誤訊息
display charset = UTF8
dos charset = CP950
unix charset = UTF8
workgroup = MYGROUP
netbios name = MY_SAMBA# ← 可以把名字改成自己喜歡的名字
server string = Samba Server Version %v
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536
hosts allow = 192.168. # 預設內網才能用
security = USER
log file = /var/log/samba/log.%m
max log size = 50
load printers = No
printing = bsd
create mask = 0644
directory mask = 0755
dead time = 15
getwd cache = yes
# 想要存取哪個目錄,就加上底下 5 行,更改 [名稱] 跟目錄 (path=)
[SOMEWHERE]
path = /some/where
valid users =# ←允許存取的帳號寫在這裡,多個以逗點隔開
force user = root
read only = No
2.接著利用指令「smbpasswd」,一一設定 SAMBA 伺服器中每個帳號的密碼:
e.g.,
# smbpasswd -a guest | 新增 SAMBA 使用者 guest |
在 Linux 主機掛載 Windows 檔案系統
Windows 的 smb 檔案系統可以像 Linux 的檔案系統一樣直接掛載到 Linux 的目錄樹中:
[root@CentOS ~]# vi /etc/fstab
加入
\\192.168.1.x\Shared /Shared cifs user,uid=500,rw,suid,username=username,password=password 0 0
完成後可用mount -a看看有無錯誤訊息
訂閱:
文章 (Atom)