iptables -A INPUT -p icmp --icmp-type 8 -j REJECT
iptables -A INPUT -p tcp --syn --dport 80 -j REJECT
# 限制每IP所可以發起併發鏈接數爲8 iptables -A INPUT -m connlimit --connlimit-above 8 -j REJECT
互聯網中的主機: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