2020-09-19

1、拒绝所有主机ping当前的主机

[09:28:02 root@centos8 ~ ]#iptables -AINPUT -p icmp -j REJECT
[22:08:04 root@centos7 ~]#ping 10.0.0.8
PING 10.0.0.8 (10.0.0.8) 56(84) bytes of data.
From 10.0.0.8 icmp_seq=1 Destination Port Unreachable
From 10.0.0.8 icmp_seq=2 Destination Port Unreachable
From 10.0.0.8 icmp_seq=3 Destination Port Unreachable
[10:08:08 root@centos6 ~]#ping 10.0.0.8
PING 10.0.0.8 (10.0.0.8) 56(84) bytes of data.
From 10.0.0.8 icmp_seq=1 Destination Port Unreachable
From 10.0.0.8 icmp_seq=2 Destination Port Unreachable


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

[10:05:36 root@centos8 ~ ]#iptables -IINPUT 2 -p tcp --dport 80 -j REJECT
[10:07:46 root@centos8 ~ ]#curl 10.0.0.6
10.0.0.6
[10:07:57 root@centos8 ~ ]#curl 10.0.0.7
10.0.0.7
[22:04:49 root@centos7 ~]#curl 10.0.0.8
curl: (7) Failed connect to 10.0.0.8:80; Connection refused
[10:05:11 root@centos6 ~]#curl 10.0.0.8
curl: (7) couldn't connect to host

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

[14:45:31 root@centos8 data ]#iptables -AINPUT -m connlimit --connlimit-above 10 -j REJECT

4.实践题
(1)配置主机
A7:
设置A7网卡为仅主机,配置IP地址为192.168.1.128、网关为192.168.1.129。
A8:
配置两块网卡eth1:192.168.1.129(仅主机)和eth0:10.0.0.8(NAT)
B8:设置B8网卡为NAT,配置IP地址为10.0.0.18、网关为10.0.0.8
(2)配置防火墙规则
A8开启ip_forward
配置防火墙规则:

[21:38:56 root@centos8 ~ ]#iptables -AFORWARD -j REJECT
[21:39:05 root@centos8 ~ ]#iptables -IFORWARD -d 10.0.0.0/24 -p tcp --dport 22 -j ACCEPT
[21:39:18 root@centos8 ~ ]#iptables -IFORWARD -d 10.0.0.0/24 -p tcp --dport 80 -j ACCEPT

实现A7只能访问B8ssh服务

[21:42:06 root@centos6 ~]#curl 10.0.0.18
curl: (7) couldn't connect to host
[21:43:18 root@centos6 ~]#ssh 10.0.0.18
root@10.0.0.18's password: 
Last login: Sat Sep 19 09:38:19 2020 from 192.168.1.128
[09:43:38 root@centos7 ~]#

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值