在Centos 上Xtables-Addons 和Iptables GeoIP 6及過濾實現和安裝
這篇文章將講述怎樣安裝iptable 在內核的的使用,Xtables-addons 是 patch-o-matic(-ng).的繼承, 同樣他也延續了接受了iptable的安裝包。Xtables-addons不同於patch-o-matic,但不需要補丁和編譯安裝。
一個列表裏可用的模塊點here這裏和它們的使用here這裏.
1 初步:
在我們開始前,確保SELinux被禁用:
接着編輯 /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
使SELinux失效:
4 編輯 xtables-addons
xtables-addons源和unarchive得到
wget http://downloads.sourceforge.net/project/xtables-addons/Xtables-addons/1.37/xtables-addons-1.37.tar.xz
tar xvf xtables-addons-1.37.tar.xz
編寫模塊:
xtables- -addons- cd / 1.37
您可以編輯“mconfig "文件選擇什麼是模塊創建和安裝。enabled.默認情況下,使所有模塊。
./configure
make && make install
5 設置建立geoip 模塊
創建geoip數據文件,和iptable 的匹配:
cd geoip/
使用腳本形式 下載和編譯文件夾MaxMind GeoIPCountrydatabase:數據庫
./xt_geoip_dl
./xt_geoip_build GeoIPCountryWhois.csv
把文件移動到系統默認位置:
mkdir -p /usr/share/xt_geoip/
cp -r {BE,LE} /usr/share/xt_geoip/
測試是這樣的:
iptables -I INPUT -m geoip --src-cc CN -j DROP
6 連接:
Xtables-addons:http://xtables-addons.sourceforge.net/
Xtables-addons modules:Xtables-addons:http://xtables-addons.sourceforge.net/modules.php
Xtables-addons man page:Xtables-addons:http://dev.medozas.de/files/xtables/xtables-addons.8.html
MaxMind GeoIP:MaxMind GeoIP:http://geolite.maxmind.com/download/geoip/database
CentOS:CentOS:http://www.centos.org/http://www.centos.org/
echo 0 > /selinux/enforce
... for the change to take effect
2 配置支持:
* iptables >= 1.4.3
* kernel-source >= 2.6.29
For ipset-6 you need:
* libmnl
* Linux kernel >= 2.6.35
3 安裝包:
注意:你會需要同樣的版本的kernel-devel軟件包,因爲安裝包必須和內核保持一致。
uname -r
2.6.32-71.el6.i686
yum install gcc gcc-c++ make automake unzip zip xz kernel-devel-`uname -r` iptables-devel
在這種情況下 kernel-devel-2.6.32-71.el6.i686kernel- -devel- -el6.i686 -2.6.32- 71.
安裝rpmforge repo包:perl-Text-CSV_XS package:
rpm -i http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm
yum install perl-Text-CSV_XS
system-config-securitylevelsystem-config-securitylevel