9.19 iptables作业

iptables 周作业
1、拒绝所有主机ping当前的主机。

[root@centos8 ~]#iptables -AINPUT -s 本机IP  -j ACCEPT
[root@centos8 ~]#iptables -AINPUT -d 本机IP -p icmp --icmp-type 8 -j REJECT

[root@centos8 ~]#iptables -vnL
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
   10   840 ACCEPT     all  --  *      *       本机IP                0.0.0.0/0           
   59  4956 REJECT     icmp --  *      *       0.0.0.0/0            本机IP             icmptype 8 reject-with icmp-port-unreachable

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         


Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination   

2、本机能够访问别的机器的HTTP服务,但是别的机器无法访问本机。

[root@centos8 ~]#iptables -AINPUT -s 本机IP  -j ACCEPT
[root@centos8 ~]#iptables -A INPUT -d 本机IP -p tcp --dport 80 -j REJECT 

[root@centos8 ~]#iptables -vnL
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  *      *       本机IP                0.0.0.0/0           
    0     0 REJECT     tcp  --  *      *       0.0.0.0/0            本机IP             tcp dpt:80 reject-with icmp-port-unreachable

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination      

3、当我们发现有 ip 恶意攻击我们得时候,我们可以通过对防火墙设定规则来进行控制。所以我们可以
添加connlimit模块来实现对最大并发得控制。请写出步骤

[root@centos8 ~]#iptables -A INPUT -d 本机IP -m connlimit --connlimit-above 最大并发数 -j REJECT

4、实践题
实验前提需求
在这里插入图片描述
现在我在外地出差使用A7互联网主机,但是现在由于公司有业务需要我 ssh 链接到内网、这时候
我就链接我们公司同事在防火墙上配置相关规则让我链接进公司内网
请写出实现过程:

#开启ip_forward
vim /etc/sysctl.conf 
net.ipv4.ip_forward=1

sysctl -p
#在防火墙上配置
iptables -t nat -A PREROUTING -s 192.168.1.128 -d 192.168.1.129 -p tcp --dport 22 -j DNAT --to-destination 10.0.0.18:22 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值