Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Networking & Security
  • Search

[solved] RTSP, client behind NAT (new iptables code snippet)

Having problems getting connected to the internet or running a server? Wondering about securing your box? Ask here.
Post Reply
Advanced search
2 posts • Page 1 of 1
Author
Message
lost+found
Guru
Guru
User avatar
Posts: 514
Joined: Mon Nov 15, 2004 6:56 pm
Location: North~Sea~Coa~s~~t~~~

[solved] RTSP, client behind NAT (new iptables code snippet)

  • Quote

Post by lost+found » Mon Feb 21, 2011 4:22 pm

Hi,

It seems that current kernels dropped the RTSP helper modules (like the existing ip_nat_ftp and ip_conntrack_ftp for FTP). For clients behind a stateful firewall/NAT, this causes that incoming UDP packets don't reach the client when playing media steams. It is suggested by many to make a prerouting rule for it. I expanded this by making use of the iptables recent module, to get this thing more working like stateful connection tracking. This works for different streaming servers, without the need to define their IP in advance. It seems to work well for my home network, where my cell phone is the client playing video streams from the internet via bluetooth on my Gentoo box (with dnsmasq installed). Comments are welcome... :)

Code: Select all

(...)
iptables -A FORWARD -i br0 -p tcp -s $MOBILE_IP --dport 554 \
    -m recent --set --rdest --syn -m state --state NEW -j ACCEPT
iptables -A FORWARD -i br0 -p udp -s $MOBILE_IP -m multiport --dports 6971,10581 \
    -m recent --update --rdest --seconds 60 -m state --state NEW -j ACCEPT
iptables -A FORWARD -i eth0 -p udp -d $MOBILE_IP -m multiport --sports 6970:6971,10580:10581 \
    -m recent --rcheck --seconds 60 -j ACCEPT
iptables -t nat -A PREROUTING -p udp -m multiport --sports 6970:6971,10580:10581 \
    -m recent --rcheck --seconds 60 -j DNAT --to-destination $MOBILE_IP
(...)
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
(...)
Tested on RTSP streams: http://m.uitzendinggemist.nl/ and http://m.youtube.com/ (YouTube is using higher UDP ports, so the port range is adjusted. For other media something like xxxx:yyyyy for UDP could be necessary. For instance Dutch state radio streams at http://m.publiekeomroep.nl/ use random UDP ports within a certain range, from something like 1040:9991 (haven't counted them all yet).

Documentation:
Recent Module - http://snowman.net/projects/ipt_recent/
RTSP protocol - http://soundscreen.com/streaming/firewall.html
Top
zeolo
n00b
n00b
Posts: 1
Joined: Wed Feb 10, 2021 3:21 pm

[solved] RTSP, client behind NAT (new iptables code snippet)

  • Quote

Post by zeolo » Wed Feb 10, 2021 3:27 pm

I tested with two clients on the same server at the same time, and it works. 8O

I only think you are a genius

So I deactivate the 'nf_conntrack_helper' as well as the 'nf_nat_rtsp' module, to keep your solution
Top
Post Reply

2 posts • Page 1 of 1

Return to “Networking & Security”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic