通过我的 12.04 LTS Shorewall 盒进行的互联网连接充其量也只是时好时坏。Ping 在本地和互联网上都有效,没有丢包(无论是从盒本身还是从内部 LAN)。HTTP 连接通过 squid 工作得很好,但是当我不使用 squid 时,它们很慢而且时好时坏。SSH 也很慢,有时连接很困难。HTTPS 和电子邮件根本不起作用。
此盒子将用相同的设置替换运行良好的 11.04 盒子。这是在新硬件上全新安装的 12.04 LTS。
网络配置:
% ifconfig
eth0 Link encap:Ethernet HWaddr bc:5f:f4:47:99:24
inet addr:X.X.X.X Bcast:255.255.255.255 Mask:255.255.254.0
UP BROADCAST RUNNING MULTICAST MTU:576 Metric:1
RX packets:36215 errors:2882 dropped:0 overruns:0 frame:2882
TX packets:6652 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2983691 (2.9 MB) TX bytes:660681 (660.6 KB)
Interrupt:16
eth1 Link encap:Ethernet HWaddr bc:5f:f4:47:99:22
inet addr:10.0.0.1 Bcast:10.0.0.255 Mask:255.255.255.0
inet6 addr: fe80::be5f:f4ff:fe47:9922/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5875 errors:0 dropped:9 overruns:0 frame:0
TX packets:4424 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:661913 (661.9 KB) TX bytes:762000 (762.0 KB)
Interrupt:16
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:18 errors:0 dropped:0 overruns:0 frame:0
TX packets:18 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1284 (1.2 KB) TX bytes:1284 (1.2 KB)
我不认为这是一个路由问题:
% route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default X.X.X.X 0.0.0.0 UG 100 0 0 eth0
10.0.0.0 * 255.255.255.0 U 0 0 0 eth1
X.X.X.0 * 255.255.254.0 U 0 0 0 eth0
我已启用 IP 转发:
% sudo sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1
我尝试打开和关闭 rp_filter,结果相同。
我曾尝试专门向 shorewall 添加一条规则以允许流量通过 80 和 443,但是并没有解决问题(并且根据给定的策略也没有必要这样做)。
Shorewall 配置如下:
% grep -v ^# /etc/shorewall/interfaces
net eth0 detect dhcp
loc eth1 detect dhcp
% grep -v ^# /etc/shorewall/zones
fw firewall
net ipv4
loc ipv4
% grep -v ^# /etc/shorewall/rules
SECTION NEW
Ping(ACCEPT) fw loc
% grep -v ^# /etc/shorewall/policy
fw fw ACCEPT info
fw net ACCEPT info
fw all REJECT warning
loc fw ACCEPT info
loc net ACCEPT info
net fw REJECT notice
net loc DROP error
all all REJECT info
% grep -v ^# /etc/shorewall/masq
eth0 10.0.0.0/24
相关iptables:
% sudo iptables -L
...
Chain net2loc (1 references)
target prot opt source destination
dynamic all -- anywhere anywhere ctstate INVALID,NEW
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
Drop all -- anywhere anywhere
LOG all -- anywhere anywhere LOG level error prefix "Shorewall:net2loc:DROP:"
DROP all -- anywhere anywhere
...
% sudo iptables -t nat -L -v -n
...
Chain POSTROUTING (policy ACCEPT 116 packets, 8749 bytes)
pkts bytes target prot opt in out source destination
189 12557 eth0_masq all -- * eth0 0.0.0.0/0 0.0.0.0/0
Chain eth0_masq (1 references)
pkts bytes target prot opt in out source destination
73 3808 MASQUERADE all -- * * 10.0.0.0/24 0.0.0.0/0
在我看来一切都很好。
我认为这是一个连接跟踪问题,但我不知道如何诊断它,更不用说修复它了。任何帮助都将不胜感激。
答案1
您需要从 shorewall 内部启用 ip 转发
sudo nano /etc/shorewall/shorewall.conf
然后找到该行IP_FORWARDING=keep
并将其更改为On
:
IP_FORWARDING=On
保存并退出文件,然后运行:
sudo shorewall restart