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
相關文章
相關標籤/搜索
本站公眾號
   歡迎關注本站公眾號,獲取更多信息