SSDP broadcasting (used with Plex) and pf

Hi,

I'm trying to get Plex's auto discovery to work. This uses Simple Service Discovery Protocol. For the life of me I cannot get this to work. The following is my /etc/pf.conf:

Code:
#############################################################################################################################################################################################################
## Options
#############################################################################################################################################################################################################

#block policy
set block-policy return

# unlimited traffic for loopback
set skip on {lo0}

# increase table size
set limit table-entries 200000

#############################################################################################################################################################################################################
## Macros
#############################################################################################################################################################################################################

# connected to internet
ext_if = "bge0"

# Jail psuedo interfaces

#ssdp
ssdp = "1900"

#https://plexapp.zendesk.com/hc/en-us/articles/201543147-What-network-ports-do-I-need-to-allow-through-my-firewall-
plex = "32400 32443 32469"
plex_discovery = "32410 32412 32413 32414"

tcp_services = "{ ssh, afpovertcp, " $plex "}"
udp_services = "{" $plex_discovery "}"
broadcast_services = "{ mdns," $ssdp "}"

#services Opis needs to connect to
tcp_services_client = "{ smtp, smtps, domain, www, https, ftp }"
udp_services_client = "{ domain, bootpc, bootps, ntp }"

icmp_types = "{ echoreq, echorep, unreach }"

#local network and broadcast networks
localnet = "{ 10.0.0.0/8, 224.0.0.0/24, all-systems.mcast.net, 239.255.255.250 }"


#RFC 1918 addresses
martians = "{ 127.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12, \
169.254.0.0/16, 192.0.2.0/24, \
0.0.0.0/8, 240.0.0.0/4 }"


#############################################################################################################################################################################################################
## Tables
#############################################################################################################################################################################################################

table <bruteforce> persist

table <sshguard> persist

table <emerging_threats> persist file "/root/tables/emerging-Block-IPs.txt"

#############################################################################################################################################################################################################
## Traffic Normalisation
#############################################################################################################################################################################################################

#scrub provides a measure of protection against certain kinds of attacks based on incorrect handling of packet fragments
scrub in all

#############################################################################################################################################################################################################
## Translation
#############################################################################################################################################################################################################

#############################################################################################################################################################################################################
## Filter Rules
#############################################################################################################################################################################################################

# Setup a default deny policy. Remember that in PF the last matching rule wins.
# Therefore, this rule is the catch-all rule. Anything not specifically allowed
block log all label "drop all"

# Prevent spoofing
antispoof log for $ext_if label "antispoof"

# Block anything coming form source we have no back routes for
block in log from no-route to any label "no back route"

# Block packets whose ingress interface does not match the one
# the route back to their source address
block in log quick from urpf-failed label uRPF

# Block EmergingThreats
block log from <emerging_threats> to any label "Emerging Threats"

# Block bruteforce attempts
block log quick from <bruteforce> label "bruteforce"

pass inet proto tcp from any to $ext_if:network port $tcp_services \
flags S/SA keep state \
(max-src-conn 100, max-src-conn-rate 15/5, \
overload <bruteforce> flush global)

# SSHGuard
block in log quick on $ext_if proto tcp from <sshguard> to any port ssh label "SSHGuard bruteforce"

# Proxy FTP Connections
pass in quick on $ext_if inet proto tcp to port 21 divert-to 127.0.0.1 port 8021 label "ftp proxy"
anchor "ftp-proxy/*"

# Allow tcp/udp services
pass in proto tcp from $localnet to port $tcp_services keep state label "tcp services"
pass in proto udp from $localnet to port $udp_services keep state label "udp services"

# Allow tcp/udp client services used by Opis
pass out on $ext_if proto tcp to any port $tcp_services_client keep state label "tcp client connections"
pass out on $ext_if proto udp to any port $udp_services_client keep state label "udp client connections"

# Allow bonjour and ssdp broadcasts
pass in quick on $ext_if proto udp from { $ext_if:network } port $broadcast_services to $localnet keep state allow-opts label "broadcast (in)"
pass out quick on $ext_if proto udp from { $ext_if:network } to $localnet port $broadcast_services keep state allow-opts label "broadcast (out)"

# Allow Multicast traffic
pass in on $ext_if inet proto igmp to $localnet allow-opts label "igmp multicast"

# Allow echo request, icmp unreachable
pass inet proto icmp all icmp-type $icmp_types keep state label "allow select icmp"

# Allow out the default range for traceroute(8):
# "base+nhops*nqueries-1" (33434+64*3-1)
pass out on $ext_if inet proto udp to port 33433 >< 33626 label "traceroute"

# Block RFC 1918 addresses
block drop in quick on $ext_if from $martians to any label "block rfc1918 (in)"
block drop out quick on $ext_if from any to $martians label "block rfc1918 (out)"

If I use sysutils/pftop I can see that I am broadcasting traffic to port 1900 (SSDP), so I'm not sure where my issue is. Plex's auto-discovery works if I disable pf, so I know the issue is with my ruleset.
 
Khaine said:
Code:
# Allow bonjour and ssdp broadcasts
pass in quick on $ext_if proto udp from { $ext_if:network } port $broadcast_services to $localnet keep state allow-opts label "broadcast (in)"
pass out quick on $ext_if proto udp from { $ext_if:network } to $localnet port $broadcast_services keep state allow-opts label "broadcast (out)"
These rules don't allow traffic to/from 255.255.255.255 (broadcast).
 
Turn on logging for the default block rule and see which destination address(es) is/are used by the broadcast traffic.
 
Back
Top