pf
当我打开时,我无法建立新的 NFS 连接。
当我关闭pf
服务器和客户端时,我可以毫无问题地进行安装。
我尝试了keep state
服务器flags S/SA
配置,但结果相同。我设置的标志是否错误?
客户pf.conf
:
pass in on $int_if inet proto { tcp udp } from $nfs_int_ip to ($int_if) port { sunrpc nfsd-status nfsd-keepalive nfsd lockd }
pass out on $int_if inet proto { tcp udp } from ($int_if) to $nfs_int_ip port { sunrpc nfsd-status nfsd-keepalive nfsd lockd }
服务器pf.conf
:
pass in on $int_if inet proto { tcp udp } from $int_subnet to ($int_if) port { sunrpc nfsd-status nfsd-keepalive nfsd lockd }
pass out on $int_if inet proto { tcp udp } from ($int_if) to $int_subnet port { sunrpc nfsd-status nfsd-keepalive nfsd lockd }
sudo tcpdump -tttnnnvvv -i pflog0
以下是我尝试在客户端上挂载时服务器的输出:
00:00:27.567834 IP (tos 0x0, ttl 64, id 13093, offset 0, flags [none], proto UDP (17), length 84)
10.132.42.85.817 > 10.132.42.148.111: [udp sum ok] UDP, length 56
00:00:00.009245 IP (tos 0x0, ttl 64, id 54776, offset 0, flags [none], proto UDP (17), length 56)
10.132.42.148.111 > 10.132.42.85.817: [udp sum ok] UDP, length 28
00:00:00.003862 IP (tos 0x0, ttl 64, id 13094, offset 0, flags [DF], proto TCP (6), length 60)
10.132.42.85.871 > 10.132.42.148.2049: Flags [S], cksum 0x97b8 (correct), seq 1435157682, win 65535, options [mss 1460,nop,wscale 6,sackOK,TS val 1292227501 ecr 0], length 0
00:00:00.000283 IP (tos 0x0, ttl 64, id 54777, offset 0, flags [DF], proto TCP (6), length 60)
10.132.42.148.2049 > 10.132.42.85.871: Flags [S.], cksum 0x2967 (correct), seq 3548396325, ack 1435157683, win 65535, options [mss 1460,nop,wscale 6,sackOK,TS val 1375604124 ecr 1292227501], length 0
00:00:00.001210 IP (tos 0x0, ttl 64, id 13095, offset 0, flags [DF], proto TCP (6), length 52)
10.132.42.85.871 > 10.132.42.148.2049: Flags [.], cksum 0x541f (correct), seq 1, ack 1, win 1040, options [nop,nop,TS val 1292227504 ecr 1375604124], length 0
00:00:00.000260 IP (tos 0x0, ttl 64, id 13096, offset 0, flags [DF], proto TCP (6), length 96)
10.132.42.85.2847810760 > 10.132.42.148.2049: 40 null
00:00:00.000608 IP (tos 0x0, ttl 64, id 54778, offset 0, flags [DF], proto TCP (6), length 52)
10.132.42.148.2049 > 10.132.42.85.871: Flags [.], cksum 0xe635 (correct), seq 1, ack 45, win 29127, options [nop,nop,TS val 1375604130 ecr 1292227504], length 0
00:00:00.000139 IP (tos 0x0, ttl 64, id 54779, offset 0, flags [DF], proto TCP (6), length 80)
10.132.42.148.2049 > 10.132.42.85.2847810760: reply ok 24 null
00:00:00.001038 IP (tos 0x0, ttl 64, id 13097, offset 0, flags [DF], proto TCP (6), length 52)
10.132.42.85.871 > 10.132.42.148.2049: Flags [F.], cksum 0x53d0 (correct), seq 45, ack 29, win 1040, options [nop,nop,TS val 1292227504 ecr 1375604130], length 0
00:00:00.000062 IP (tos 0x0, ttl 64, id 54780, offset 0, flags [DF], proto TCP (6), length 52)
10.132.42.148.2049 > 10.132.42.85.871: Flags [.], cksum 0xe618 (correct), seq 29, ack 46, win 29127, options [nop,nop,TS val 1375604130 ecr 1292227504], length 0
00:00:00.000183 IP (tos 0x0, ttl 64, id 54781, offset 0, flags [DF], proto TCP (6), length 52)
10.132.42.148.2049 > 10.132.42.85.871: Flags [F.], cksum 0xe617 (correct), seq 29, ack 46, win 29127, options [nop,nop,TS val 1375604130 ecr 1292227504], length 0
00:00:00.000332 IP (tos 0x0, ttl 64, id 13098, offset 0, flags [none], proto UDP (17), length 84)
10.132.42.85.895 > 10.132.42.148.111: [udp sum ok] UDP, length 56
00:00:00.000557 IP (tos 0x0, ttl 64, id 13099, offset 0, flags [DF], proto TCP (6), length 52)
10.132.42.85.871 > 10.132.42.148.2049: Flags [.], cksum 0x53cf (correct), seq 46, ack 30, win 1040, options [nop,nop,TS val 1292227504 ecr 1375604130], length 0
00:00:00.000555 IP (tos 0x0, ttl 64, id 54782, offset 0, flags [none], proto UDP (17), length 56)
10.132.42.148.111 > 10.132.42.85.895: [udp sum ok] UDP, length 28
如果我遗漏了任何信息,请告诉我。
答案1
注意:192.168.1.9 是客户端,14 是服务器,在我的两个服务器中运行良好....
客户端pf.conf
:
block all
pass in on em0 inet proto { tcp udp } from 192.168.1.14 to em0 port { sunrpc nfsd-status nfsd-keepalive nfsd lockd }
pass out on em0 inet proto { tcp udp } from em0 to 192.168.1.14 port { sunrpc nfsd-status nfsd-keepalive nfsd lockd }
服务器pf.conf
:
block all
pass in on em0 inet proto { tcp udp } from 192.168.1.9 to em0 port { sunrpc nfsd-status nfsd-keepalive nfsd lockd }
pass out on em0 inet proto { tcp udp } from em0 to 192.168.1.9 port { sunrpc nfsd-status nfsd-keepalive nfsd lockd }
答案2
这些 pf 规则对我有用。已为 mountd 添加端口 797。有一个有用的指南PF:测试你的防火墙
/etc/rc.conf:
mountd_flags="-r -S -p 797"
NFS 客户端:
- nfs_ports="{ sunrpc, nfsd-status, nfsd-keepalive, nfsd, lockd, 797 }"
- nfs_server="10.132.0.2"
- pass in on $ext_if proto tcp from $nfs_server to $ext_if port $nfs_ports keep state flags S/SA
- pass in on $ext_if proto udp from $nfs_server to $ext_if port $nfs_ports
- pass out on $ext_if proto tcp from $ext_if to $nfs_server port $nfs_ports keep state flags S/SA
- pass out on $ext_if proto udp from $ext_if to $nfs_server port $nfs_ports
NFS 服务器:
- nfs_ports="{ sunrpc, nfsd-status, nfsd-keepalive, nfsd, lockd, 797 }"
- nfs_clients="{ 10.132.0.3, 10.132.0.4 }"
- pass in on $ext_if proto tcp from $nfs_clients to $ext_if port $nfs_ports keep state flags S/SA
- pass in on $ext_if proto udp from $nfs_clients to $ext_if port $nfs_ports
- pass out on $ext_if proto tcp from $ext_if to $nfs_clients port $nfs_ports keep state flags S/SA
- pass out on $ext_if proto udp from $ext_if to $nfs_clients port $nfs_ports