服务器防火墙位置,WEB   服务器防火墙配置

iptables -P INPUT DROP

iptables -P OUTPUT ACCEPT

iptables -P FORWARD DROP

-A INPUT -p tcp -m tcp --tcp-flags SYN,RST,ACK SYN -m limit --limit 20/sec --limit-burst 200 -j ACCEPT

-A INPUT -i lo -j ACCEPT

-A INPUT -p tcp -m state --state RELATED,ESTABLISHED -j ACCEPT

-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT

-A INPUT -p tcp -m multiport --dports 20 -j ACCEPT

-A INPUT -p tcp -m multiport --dports 21 -j ACCEPT

-A INPUT -p tcp -m multiport --dports 80 -j ACCEPT

-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

-A INPUT -m state --state INVALID -j DROP

-A OUTPUT -o lo -j ACCEPT

-A OUTPUT -p tcp -m tcp --sport 80 -j ACCEPT

-A OUTPUT -p tcp -m tcp --sport 31337 -j DROP

-A OUTPUT -p tcp -m tcp --dport 31337 -j DROP

-A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

-A OUTPUT -m state --state INVALID -j DROP

、查看iptables -nvL –line-number

-L 查看当前表的所有规则,默认查看的是filter表,如果要查看NAT表,可以加上-t NAT参数-n 不对ip地址进行反查,加上这个参数显示速度会快很多-v 输出详细信息,包含通过该规则的数据包数量,总字节数及相应的网络接口–line-number 显示规则的序列号,这个参数在删除或修改规则时会用到

添加

添加规则有两个参数:-A和-I。其中-A是添加到规则的末尾;-I可以插入到指定位置,没有指定位置的话默认插入到规则的首部。

[root@test ~]# iptables -nL --line-number

Chain INPUT (policy ACCEPT)

num  target     prot opt source               destination

1    DROP       all  --  192.168.1.1          0.0.0.0/0

2    DROP       all  --  192.168.1.2          0.0.0.0/0

3    DROP       all  --  192.168.1.4          0.0.0.0/0

添加一条规则到尾部:

iptables -A INPUT -s 192.168.1.5 -j DROP

iptables -I INPUT 3 -s 192.168.1.3 -j DROP

[root@test ~]# iptables -nL --line-number

Chain INPUT (policy ACCEPT)

num  target     prot opt source               destination

1    DROP       all  --  192.168.1.1          0.0.0.0/0

2    DROP       all  --  192.168.1.2          0.0.0.0/0

3    DROP       all  --  192.168.1.3          0.0.0.0/0

4    DROP       all  --  192.168.1.4          0.0.0.0/0

5    DROP       all  --  192.168.1.5          0.0.0.0/0

删除

iptables -D INPUT -s 192.168.1.5 -j DROP

[root@test ~]# iptables -nL --line-number

Chain INPUT (policy ACCEPT)

num  target     prot opt source               destination

1    DROP       all  --  192.168.1.1          0.0.0.0/0

2    DROP       all  --  192.168.1.2          0.0.0.0/0

3    DROP       all  --  192.168.1.3          0.0.0.0/0

iptables -D INPUT 2

修改

[root@test ~]# iptables -nL --line-number

Chain INPUT (policy ACCEPT)

num  target     prot opt source               destination

1    DROP       all  --  192.168.1.1          0.0.0.0/0

2    DROP       all  --  192.168.1.2          0.0.0.0/0

3    DROP       all  --  192.168.1.5          0.0.0.0/0

iptables -R INPUT 3 -j ACCEPT

[root@test ~]# iptables -nL --line-number

Chain INPUT (policy ACCEPT)

num  target     prot opt source               destination

1    DROP       all  --  192.168.1.1          0.0.0.0/0

2    DROP       all  --  192.168.1.2          0.0.0.0/0

3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值