1、拒绝所有主机ping当前的主机
在INPUT链中加上一条限制ping的规则,如在主机8(10.0.0.6)禁止主机6(10.0.0.6)的访问。
iptables -A INPUT -s 10.0.0.6 -p icmp --icmp-type 8 -j REJECT
2、本机能够访问别的机器的HTTP服务,但是别的机器无法访问本机
以主机8(10.0.0.8)和主机7(10.0.0.7)为例:8能够访问7,7不能访问8
iptables -A INPUT -s 10.0.0.1/32 -j ACCEPT
iptables -A INPUT ! -s 10.0.0.7/32 -m state --state NEW -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED -j ACCEPT
iptables -A INPUT -j REJECT --reject-with icmp-port-unreachable
3、当我们发现有ip恶意攻击我们的时候,我们可以通过对防火墙设定规则来进行控制。所以我们可以添加connlimit模块来实现对最大并发的控制。请写出步骤
设定IP10.0.0.8为恶意攻击
** (1)查看日志:cat /var/log/message IP10.0.0.8连接数比较多,可以设定为恶意攻击
(2)在INPUT链上添加,当IP10.0.0.8连接数量大于5时拒绝访问
iptables -A INPUT -d 10.0.0.8 -p tcp --dport 22 -m connlimit --connlimit-above 5 -j REJECT**
4、实践题
实验前提需求
现在我在外地出差使用A7互联网主机,但是现在由于公司业务需要我ssh链接到内网、这时候我就链接我们公司同事在防火墙上配置相关 规则让我链接进公司内网
请写出实现过程:
**用DNAT实现
(1)A8启用路由转发
#vim /etc/sysctl.conf
net.ipv4.ip_forward=1
#sysctl -p
(2)A8上配置防火墙规则:
iptables -t nat -A PREROUTING -d 10.0.0.8 -p tcp --dport 22 -j DNAT --to-destination 10.0.0.18
(3)启动A7的http服务,查看端口号
#vim /etc/httpd/conf/httpd.conf
systemctl restart httpd
(4)在A8上配置A7规则
iptables -t nat -R PREROUTING 1 -d 10.0.0.18 -p tcp --dport 22 -j DNAT --to-destination 192.168.100.7:8000**
共有条评论 网友评论