centos6下iptables配置xtables-pg电子游戏试玩平台网站

腾讯视频/爱奇艺/优酷/外卖 充值4折起

下面来为各位介绍一个centos6下iptables配置xtables-addons和geoip屏蔽某个国家ip例子,希望文章对各位有帮助.

今天服务器上流量猛增,ip都来自于中国,而且是非正常访问的ip,导致php-fpm耗cpu 100%,网站打开非常慢,本来已经使用iptables限制连接数,但由于同一ip的连接数达不到,所以没办法进行限制,只能采用屏蔽某个地区ip的方法了,xtables-addons就是这样的模块,只需要编译此模块,而不必编译系统内核,就可以和iptables一起工作,达到过滤某个地区的ip。

第一步,检查系统iptables版本,xtables-addons要与iptables版本一致,例如iptables是1.4.7,就需要对应在的xtables-addons 1.47
# uname -r
2.6.32-358.18.1.el6.x86_64
# iptables -v
iptables v1.4.7

那么就要下载xtables-addons 1.47了。

另外需要关闭selinux,编辑/etc/selinux/config,修改为disabled,并使其生效:echo 0 > /selinux/enforce。

第二步,安装perl-text-csv_xs依赖包
# yum install gcc gcc-c make automake unzip zip xz kernel-devel-`uname -r` iptables-devel
# rpm -uvh http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
# yum -y install perl-text-csv_xs

第三步,下载和编译xtables-addons模块
# wget http://sourceforge.net/projects/xtables-addons/files/xtables-addons/1.47/xtables-addons-1.47.tar.xz/download
# tar xf xtables-addons-1.47.tar.xz
# cd xtables-addons-1.47
# ./configure
# make
# make install

假如在./configure时遇到错误,configure: error: package requirements (xtables >= 1.4.5) were not met: no package 'xtables' found:
checking for a bsd-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(make)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the c compiler works... yes
checking for c compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the gnu c compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept iso c89... none needed
checking for style of include used by make... gnu
checking dependency style of gcc... gcc3
checking whether gcc and cc understand -c and -o together... yes
checking for ar... ar
checking the archiver (ar) interface... ar
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -e
checking for fgrep... /bin/grep -f
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is gnu ld... yes
checking for bsd- or ms-compatible name lister (nm)... /usr/bin/nm -b
checking the name lister (/usr/bin/nm -b) interface... bsd nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1966080
checking whether the shell understands some xsi constructs... yes
checking whether the shell understands " ="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %sn
checking for archiver @file support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -b output from gcc object... ok
checking for sysroot... no
checking for mt... no
checking if : is a manifest tool... no
checking how to run the c preprocessor... gcc -e
checking for ansi c header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce pic... -fpic -dpic
checking if gcc pic flag -fpic -dpic works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... gnu/linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking linux/netfilter/x_tables.h usability... yes
checking linux/netfilter/x_tables.h presence... yes
checking for linux/netfilter/x_tables.h... yes
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for libxtables... no
configure: error: package requirements (xtables >= 1.4.5) were not met:

no package 'xtables' found

consider adjusting the pkg_config_path environment variable if you
installed software in a non-standard prefix.

alternatively, you may set the environment variables libxtables_cflags
and libxtables_libs to avoid the need to call pkg-config.
see the pkg-config man page for more details.
请安装iptables开发包iptables-devel:
# yum -y install iptables-devel

第四步,下载和安装geoip模块,你可以到http://geolite.maxmind.com/download/geoip/database/下载csv版本,也可以使用xtables-addons目录下geoip目录下的脚本xt_geoip_dl来下载:
# cd geoip/
# ./xt_geoip_dl

将会下载geoipv6.csv.gz和geoipcountrycsv.zip,并解压缩,得到ip库文件geoipv6.csv和geoipcountrywhois.csv,接下来就是使用xt_geoip_build编译数据库:
# mkdir -p /usr/share/xt_geoip/ #创建数据库文件默认存放位置
# ./xt_geoip_build -d /usr/share/xt_geoip *.csv #编译数据库文件

完成后,将会生成两个目录be和le,目录下保存的文件分别有.iv6和.iv4。

第五步,添加过滤规则,屏蔽中国地区ip:
# iptables -i input -m geoip --src-cc cn -j drop #注意,这将屏蔽所有端口访问
# iptables -i input -p tcp -m tcp --dport 80 -m geoip --src-cc cn -j drop #只屏蔽80端口访问

此时,中国地区已经无法访问网站了,可以保存了:service iptables save

12/26 21:20
centos下安装配置tomcat 演示环境 系统:linux centos 6.3 32位 环境:无安装apache、php、mysql 账号:root 一、下载相关安装包 注:可以先进入 #cd /usr/local/ /进里面后再下载(也可以根据自己情况而定) 1、下载jdk 2、下载tomcat 二、安装jdk和tomcat 注:可以先进入 #cd /usr/local/ /再执行下面的命令 1、编译安装jdk #chmod 777 jdk-6u41-linux-i586-rpm.bin
03/07 23:20
iptables配置实例: iptables配置的目的,一个是防止公网的入侵,一个是让内网的兄弟们上网。在没配iptables之前,只有本机能上网。 rh8.0的“系统设置”中有个“安全级别” ,它主要是针对本机来说的,不能用它来配置iptables。打开“安全级别”,把它配成“无防火墙”级别。 为了配置、测试方便,可以先用“kwrite”编个“脚本”,采用“复制”、“粘贴”方式,把全部语句一次性粘贴到“终端”里执行。这样修改测试都很方便。 打开“其他”—“辅助设施”中的“kwrite”,将下面
09/11 12:44
centos 系统下安装配置fastdfs步骤: 1:安装libevent(libevent-2.0.16-stable) ##卸载系统自带libevent rpm -qa|grep libevent rpm -e libevent* ##为trackerd和storaged节点节点安装libevent cd /home/ylh wget http://unclelu-server.googlecode.com/files/libevent-2.0.16-stable.tar.gz tar -z
07/11 20:34
centos网络配置实例 1,配置dnsvi /etc/resolv.conf 加入: 复制代码 代码如下: nameserver 192.168.0.1 nameserver 8.8.8.8 nameserver 8.8.4.4 2,配置网关: vi /etc/sysconfig/network 加入: gateway=192.168.0.1 完整的如下: 复制代码 代码如下: networking=yes hostname=localhost.localdomain gateway=192.

一步步教大家在win7下安装配置iis的详细图文教程

07/18 16:55
本文将图文并茂一步步教大家在win7下安装配置iis: 一、进入win7的控制面板,打开程序功能,选择打开或关闭windows功能 。 二、在安装windows功能的选项菜单,把interlnet信息服务的所有组件全部勾起来。 三、安装完成后,打开控制面板,进入系统和安全,打开管理工具,点internet 信息服务(iis)管理器。 四、打开iis管理器,进入管理页面,展开右边的个人pc栏,右击网站——添加网站, 在出来的对话框中添加自己的网站名称、物理路径(选择你的网站
11/14 02:02
mac os x 安装maven: 下载 maven, 并解压到某个目录.例如/users/robbie/apache-maven-3.3.3 打开terminal,输入以下命令,设置maven classpath $ vi ~/.bash_profile 添加下列两行代码,之后保存并退出vi: export m2_home=/users/robbie/apache-maven-3.3.3 export path=$path:$m2_home/bin bash_profile 输入命令以使bas

mpich2怎么安装 win7 64位系统下安装配置mpich2的方法教程

07/13 04:19
mpich2是什么?mpich2怎么安装和配置?mpich2 windows是mpich2在windows环境下的安装包,能够帮助用户快速安装并配置mpich2环境.mpich2是与mpi-2相对应的mpich 实现版本,包含了mpi-2相对于mpi-1扩充后的一些功能,比如动态任务管理,并行i/o 等.好了.关于mpich2的介绍先到这里,接下来就让我们一起去看看win7 64位系统下安装配置mpich2的方法教程吧! win7 64位系统下安装配置mpich2教程 1.首先,下载mpich2
05/04 14:21
这里简单演示一下apache下基于加密的认证访问----https加密方式访问。 1.dns解析解析情况: [root@localhost html]# nslookup www.downcc.com server: 192.168.2.115 address: 192.168.2.115#53 name: www.downcc.com address: 192.168.2.115 2.安装apache ssl支持模块:# yum install -y mod_ssl (默认yum安装httpd
03/30 14:05
在学习centos系统,所以找了些整理参考。 1.查看机器的无限网卡型号等信息 因为是usb接口的,所以,命令是 #lsusb 这主要还是看你的无线网卡的硬件信息啦,我的是rtl 8188su,上百度去搜索驱动并下载。在linux下面实在不知道怎么下载的,就找台windows的机子,下载完后拷贝到u盘里,然后接到linux机子下面,然后输入命令 #cd /media去查看,如果文件夹名称有空格,没关系,用*代替就可以了。 2.解压并安装驱动 #tar vxpf r
网站地图