Last active
November 5, 2016 02:56
-
-
Save yaasita/5114683 to your computer and use it in GitHub Desktop.
techracho
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- check_mailman_qfiles.org 2013-05-13 17:01:56.000000000 +0900 | |
+++ check_mailman_qfiles 2013-05-13 17:05:17.000000000 +0900 | |
@@ -9,7 +9,6 @@ | |
use strict; | |
use warnings; | |
-use File::Find::Rule; | |
use Getopt::Long; | |
my $qfiles_base = '/var/lib/mailman/qfiles'; | |
@@ -29,9 +28,9 @@ | |
my %problems; | |
my $problem_status; | |
-foreach my $qdir (qw(archive bounces commands in news out retry)) { | |
+foreach my $qdir (qw(archive bad bounces commands in news out retry shunt virgin)) { | |
# Get all the 'pickle' files in the queue directory | |
- my @files = File::Find::Rule->file->name('*.pck')->in("$qfiles_base/$qdir"); | |
+ my @files = <$qfiles_base/$qdir/*>; | |
next unless @files; | |
# Get the modification times of the files, sorted desc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
iptables -P INPUT DROP | |
iptables -N ACCEPT_IP | |
#webは日本国内からのアクセスに限定 | |
iptables -A INPUT -p tcp -m multiport --dport 80,443 -j ACCEPT_IP | |
#WebサーバへのDoS攻撃対処 | |
iptables -A INPUT -p tcp -m multiport --dport 80,443 -m state --state NEW -m hashlimit \ | |
--hashlimit-name web_limit --hashlimit 60/m --hashlimit-burst 700 \ | |
--hashlimit-mode srcip --hashlimit-htable-expire 360000 -j ACCEPT | |
#SMTPS,IMAPSは日本国内からのアクセスに限定 | |
iptables -A INPUT -p tcp -m multiport --dport 465,993 -j ACCEPT_IP | |
#25番はどこからでもアクセスさせる | |
iptables -A INPUT -p tcp --dport 25 -j ACCEPT | |
# 補足) | |
# この例では送信は587ではなくより安全な465(SMTPS)を使います | |
# 25番を開放しないと受信ができないため開放します | |
# (メールサーバ間は25番でやりとりされるため) | |
# 第三者中継かどうかはあて先が自ドメインかそうでないかの判定が | |
# 必要になるためIPベースでは行えません | |
# MTA側で設定すべきです |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# diff -u ./check_mailq.org /usr/lib/nagios/plugins/check_mailq | |
--- ./check_mailq.org 2013-04-08 17:33:52.000000000 +0900 | |
+++ /usr/lib/nagios/plugins/check_mailq 2013-04-08 17:34:03.000000000 +0900 | |
@@ -165,9 +165,9 @@ | |
# Finally look at the overall queue length | |
# | |
- if (/mqueue/) { | |
+ if (/^\-\-/) { | |
print "$utils::PATH_TO_MAILQ = $_ "if $verbose ; | |
- if (/ \((\d+) request/) { | |
+ if (/ (\d+) Request/) { | |
# | |
# single queue: first line | |
# multi queue: one for each queue. overwrite on multi queue below |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# diff -u check_mailq.org /usr/lib/nagios/plugins/check_mailq | |
--- check_mailq.org 2013-04-09 10:22:53.701747418 +0900 | |
+++ /usr/lib/nagios/plugins/check_mailq 2013-04-09 10:26:15.281747415 +0900 | |
@@ -47,6 +47,7 @@ | |
$msg_q = 0 ; | |
$msg_p = 0 ; | |
$state = $ERRORS{'UNKNOWN'}; | |
+$utils::PATH_TO_MAILQ = "/opt/zimbra/postfix/sbin/mailq"; | |
Getopt::Long::Configure('bundling'); | |
$status = process_arguments(); | |
@@ -164,9 +165,9 @@ | |
# Finally look at the overall queue length | |
# | |
- if (/mqueue/) { | |
+ if (/^\-\-/) { | |
print "$utils::PATH_TO_MAILQ = $_ "if $verbose ; | |
- if (/ \((\d+) request/) { | |
+ if (/ (\d+) Request/) { | |
# | |
# single queue: first line | |
# multi queue: one for each queue. overwrite on multi queue below |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
iptables -P INPUT DROP | |
# hashlimitについて | |
# --hashlimit-name | |
# ハッシュテーブルの名前を指定します | |
# hogeという名前にした場合は/proc/net/ipt_hashlimit/hogeで参照可能です | |
# --hashlimit | |
# hashlimit-burstで指定した値を超えた場合の制限ルールを設定します | |
# 1/mなら1分間に1回のみ許可 | |
# --hashlimit-burst | |
# hashlimit適用までに受け付ける接続回数ですこの値を超えた場合に | |
# hashlimitの制限をうけることになります | |
# --hashlimit-mode | |
# 特定ホストの識別方法を指定します。srcipで送信元IPアドレス。 | |
# srcip,dstportと指定すればポートが異なれば別ホストとしてカウントします | |
# --hashlimit-htable-expire | |
# ハッシュテーブルの有効期限です。最後の接続したパケットから指定した時間(ミリ秒) | |
# 経てばレコードを削除します | |
#sshは5回まで新規接続許可それ以降は1分に1回に制限、6分間無接続なら制限解除 | |
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -m hashlimit \ | |
--hashlimit-name ssh_limit --hashlimit 1/m --hashlimit-burst 5 \ | |
--hashlimit-mode srcip --hashlimit-htable-expire 360000 -j ACCEPT | |
#webは700回まで新規接続許可それ以降は1秒に1回に制限、6分無接続なら制限解除 | |
iptables -A INPUT -p tcp -m multiport --dport 80,443 -m state --state NEW -m hashlimit \ | |
--hashlimit-name web_limit --hashlimit 60/m --hashlimit-burst 700 \ | |
--hashlimit-mode srcip --hashlimit-htable-expire 360000 -j ACCEPT | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
while (<STDIN>){ | |
next unless /^apnic\|JP\|ipv4\|(.+)\|(.+)\|\d+\|allocated/; | |
print "iptables -A $ARGV[0] -s $1/".(32-log($2)/log(2))." -j RETURN\n"; | |
} | |
print "iptables -A $ARGV[0] -j DROP\n"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
iptables -P INPUT DROP | |
# limitについて | |
# --limit | |
# limit-burstを超えた場合の制限を指定します | |
# --limit-burst | |
# limitによる制限がかかるまでの回数です | |
#webは1000回までは許可、以降は1分間に120回までに制限する | |
iptables -A INPUT -p tcp -m state --state NEW --dport 80 -m limit --limit 120/m --limit-burst 1000 -j ACCEPT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#key | |
bind s split-window -v | |
bind v split-window -h | |
bind j select-pane -D | |
bind k select-pane -U | |
bind h select-pane -L | |
bind l select-pane -R | |
bind -r < resize-pane -L 1 | |
bind -r > resize-pane -R 1 | |
bind -r - resize-pane -D 1 | |
bind -r + resize-pane -U 1 | |
bind : command-prompt | |
bind C-i select-pane -t :.+ | |
bind Escape copy-mode | |
setw -g mode-keys vi | |
#option | |
set -g display-time 6000 | |
set -g status-interval 30 | |
set -g history-limit 5000 | |
#set -g mouse-select-pane on | |
#status line | |
set -g status-right "#(w | head -1 | cut -d, -f4) | %Y/%m/%d (%a) %p %I:%M" | |
setw -g window-status-format "#I:#W" | |
setw -g window-status-current-format "#I:#W_#P" | |
set -g status-bg black | |
set -g status-fg cyan | |
set -g status-left-fg black | |
set -g status-left-bg magenta | |
set -g status-right-fg black | |
set -g status-right-bg green | |
set-window-option -g window-status-current-attr bright,reverse | |
set-window-option -g window-status-current-bg cyan | |
set-window-option -g window-status-current-fg black | |
set-window-option -g xterm-keys on | |
set-option -g default-terminal "screen-256color" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment