2020.9.20 第三次做业 iptables

1. 拒绝全部主机ping当前主机

iptables -A INPUT -p icmp --icmp-type 8 -j REJECT

2. 本机可以访问别的机器的HTTP服务,可是别的机器没法访问本机

iptables -A INPUT -p tcp --syn --dport 80 -j REJECT

3. 当咱们发现有 ip 恶意***咱们得时候,咱们能够经过对防火墙设定规则来进行控制。因此咱们能够添加connlimit模块来实现对最大并发得控制。请写出步骤

# 限制每IP所可以发起并发链接数为8
iptables -A INPUT -m connlimit --connlimit-above 8 -j REJECT

4. 实践题

互联网中的主机:centos

[root@centos6 ~]$hostname -I
192.168.1.128
[root@centos6 ~]$route -n 
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
0.0.0.0         192.168.1.129   0.0.0.0         UG    0      0        0 eth0

防火墙:bash

[root@centos8 ~]$hostname -I
10.0.0.8 192.168.1.129
[root@centos8 ~]$route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.0.2        0.0.0.0         UG    100    0        0 eth0
10.0.0.0        0.0.0.0         255.255.255.0   U     100    0        0 eth0
192.168.1.0     0.0.0.0         255.255.255.0   U     101    0        0 eth1
[root@centos8 ~]$cat /proc/sys/net/ipv4/ip_forward
1
# 配置iptables规则
iptables -A FORWARD -s 192.168.1.128 -p tcp --dport 22 -j ACCEPT
iptables -A FORWARD -d 192.168.1.128 -p tcp --sport 22 -j ACCEPT
iptables -A FORWARD -j REJECT

局域网服务器:服务器

[root@centos7 ~]$hostname -I
10.0.0.18
[root@centos7 ~]$route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.0.8        0.0.0.0         UG    0      0        0 eth0
10.0.0.0        0.0.0.0         255.255.255.0   U     100    0        0 eth0
相关文章
相关标签/搜索
本站公众号
   欢迎关注本站公众号,获取更多信息