Networking 验证和优化IPTable和squid防火墙规则

Networking 验证和优化IPTable和squid防火墙规则,networking,iptables,squid,hotspot,Networking,Iptables,Squid,Hotspot,我的要求: 我需要从pc上运行wifi热点。连接到热点的人应该能够在访问internet时以全速和限制速度访问pc上运行的本地web服务器。我已尝试使用下面列出的软件工具设置系统。我在一台低功耗的电脑上运行它。所以我希望它尽可能地优化。我需要你检查并确认我是否做得对 连接到wlan0的用户应全速访问127.0.0.1:80 连接到wlan0的用户应通过以下地址的eth0访问互联网: 50KBps 界面和PC设置: eth0-有线互联网连接 wlan0-充当热点-使用hostapd 用于dh

我的要求:

我需要从pc上运行wifi热点。连接到热点的人应该能够在访问internet时以全速和限制速度访问pc上运行的本地web服务器。我已尝试使用下面列出的软件工具设置系统。我在一台低功耗的电脑上运行它。所以我希望它尽可能地优化。我需要你检查并确认我是否做得对

  • 连接到wlan0的用户应全速访问127.0.0.1:80
  • 连接到wlan0的用户应通过以下地址的eth0访问互联网: 50KBps
界面和PC设置:

  • eth0-有线互联网连接
  • wlan0-充当热点-使用hostapd
  • 用于dhcp的dnsmasq和用于热点的dns
  • 本地web服务器在127.0.0.1:80上运行
  • squid用于限制网络传输速率
dnsmasq配置文件:(用于ip范围和dns设置)

用于确定交通路线

IP表条目

规则1

Squid(节流网络速度)服务器在端口3128中运行。因此,将eth0(internet提供接口名)tcp端口80和443路由到squid服务器以限制网络速度。所以squid就像代理服务器一样运行。

 sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to 172.24.1.1:3128
 sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j DNAT --to 172.24.1.1:3128

 
规则2

这里将wlan0(客户端)请求路由到在端口3128中运行的squid代理服务器

sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 80 -j REDIRECT --to-port 3128
sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 443 -j REDIRECT --to-port 3128

 
规则3

它有助于为连接wlan0的客户端提供响应

sudo iptables --t nat -A POSTROUTING --out-interface wlan0 -j MASQUERADE

 
规则4

将特定ip请求路由到lo(本地服务器以127.0.0.1:80运行)

Squid配置

acl test src 172.24.1.2/24

delay_pools 1

delay_class 1 1

delay_parameters 1 100000/100000 #100kilobyte per second

delay_access 1 allow test
所有这些看起来都是可行的,但是电脑和网络有时会变慢,当很多人访问热点时,速度肯定会变慢


另外,我如何对该防火墙系统进行性能分析?

您是否已验证客户端请求不会超过网络接口的最大吞吐量?因此导致硬件瓶颈?

投票的人,请说明原因。以便我纠正并纠正错误。
iptables -t nat -A PREROUTING -i wlan0 -p tcp -d 172.24.1.1 -j DNAT --to-destination 127.0.0.1:80
acl test src 172.24.1.2/24

delay_pools 1

delay_class 1 1

delay_parameters 1 100000/100000 #100kilobyte per second

delay_access 1 allow test