文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>用cgi动态更改iptables规则

用cgi动态更改iptables规则

时间:2006-02-01  来源:ruiqingzheng

想实现通过apache的认证页面访问sendip.cgi后在iptables中 对通过验证的这个ip开放某功能  1. 最好是只对组用户开放suid属性  但是  不知道为什么还是提示错误 只有对other用户也开放suid了
chmod 4711 /sbin/iptables
chown .nobody /sbin/iptables

2. 更改或添加一个apache用户
$apache/bin/htpasswd /usr/local/apache/conf/passwords juey

3. 配置cgi需要验证

vi $apache/conf/httpd.conf

<Directory "/var/www/html/cgi-bin/">
    AllowOverride AuthConfig
#   AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

vi /var/www/html/cgi-bin/.htaccess

AuthType Basic
AuthName "Restricted Files"
AuthUserFile /usr/local/apache/conf/passwords
<Files sendip>
Require user  juey
</Files>
<Files check.cgi>
Require user  juey
</Files>

4. 用shell写个简单的cgi页面

#!/bin/bash
# fileName: sendip
echo "Content type: text/html"
echo ""

echo "$REMOTE_ADDR"
iptables -L INPUT | grep "^ACCEPT" | awk '{print $4}'| grep -o "$REMOTE_ADDR"

[ $? -eq 0 ] ||  /sbin/iptables -I INPUT -s $REMOTE_ADDR -p tcp --dport 4567 -j ACCEPT

jscript中onunload事件
http://blog.iyi.cn/start/2005/12/post_98.html

<HTML>
<BODY>

</BODY>
</HTML>

相关阅读 更多 +
排行榜 更多 +
百炼英雄抽卡技巧指南

百炼英雄抽卡技巧指南

休闲益智 下载
英雄没有闪滚雷旋风技能如何搭配

英雄没有闪滚雷旋风技能如何搭配

休闲益智 下载
英雄没有闪雷旋风BD构筑推荐

英雄没有闪雷旋风BD构筑推荐

休闲益智 下载