LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 10-18-2019, 04:06 AM   #1
uezelbruezel2000
LQ Newbie
 
Registered: Nov 2010
Posts: 7

Rep: Reputation: 0
Soft phone on linux server does not work due to udp:50000?


Hi everyone,

great forum. I'm running since more than 10 years a linux server behind my router (fritzbox which connects to the internet / dsl) and since a few year a home automation but I stumbled across a problem I need some advice.

My linux server has the ip 192.168.1.1 and is connected via ethernet to my fritzbox router on 192.168.1.2. My linux router has wifi and dhcp and does all the wireless stuff. My fritzbox is responsible for the ethernet and the dhcp on wired devices. Everything runs smoothly and I can get internet access with my smartphones connecting to my linux server which forwards it to the router. Also my self built home automation (fhem) runs on the server without any issues:

smartphone (192.168.2.xxx) wlp2s0 <--> linux server wlp2s0 (192.168.2.1) <--> linux server enp0s10 (192.168.1.1) <--> fritzbox (192.168.1.2) <--> dsl/internet


With one exception: on my smartphones I got an softphone app for my fritzbox. Basically it is a SIP to call others on a landline. When I connect my smartphones to my linux server wlp2s0 (192.168.2.1) I can ring other phones but voice is not transmitted in any direction. Affected ports by the sip are tcp 5060 and udp 50000:50100.

Now if I instead use a xiaomi wifi mini router instead the linux server which connects also via ethernet to my fritzbox and I connect my smartphones to this access point it works.

Additionally I installed an app on my smartphone to check which apps use which ips and ports. I found in the case of my smartpphone connecting to my linux server the sip:5060 is used. In the case where I connect to the xiaomi mini router the sip:5060 and additionally udp:50000.

Looks like the udp:50000 is missing on my linux server. Any idea how I could solve this?

Thanks Marc

My config is
> ifconfig
enp0s10: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 xxxxxxxxxxxxxxxxxx prefixlen 64 scopeid 0x20<link>
ether xx:xx:xx:xx:xx:xx txqueuelen 1000 (Ethernet)
RX packets 529503 bytes 533861226 (509.1 MiB)
RX errors 0 dropped 83480 overruns 0 frame 0
TX packets 266939 bytes 34459918 (32.8 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 24732 bytes 2011483 (1.9 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 24732 bytes 2011483 (1.9 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
tun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500
inet 172.16.0.1 netmask 255.255.255.255 destination 172.16.0.2
inet6 xxxxxxxxxxxxxx:933d prefixlen 64 scopeid 0x20<link>
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 100 (UNSPEC)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 8 bytes 544 (544.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.2.1 netmask 255.255.255.0 broadcast 192.168.2.255
inet6 xxxxxxxxxxxxxxxx prefixlen 64 scopeid 0x20<link>
ether xx:xx:xx:xx:xx:xx txqueuelen 1000 (Ethernet)
RX packets 217970 bytes 28356969 (27.0 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 372911 bytes 479375138 (457.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


> iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere ctstate NEW
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

> ip route
default via 192.168.1.2 dev enp0s10 onlink
172.16.0.0/24 via 172.16.0.2 dev tun0
172.16.0.2 dev tun0 proto kernel scope link src 172.16.0.1
192.168.1.0/24 dev enp0s10 proto kernel scope link src 192.168.1.1
192.168.2.0/24 dev wlp2s0 proto kernel scope link src 192.168.2.1
 
Old 10-18-2019, 05:39 AM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,347

Rep: Reputation: Disabled
Quote:
Originally Posted by uezelbruezel2000 View Post
With one exception: on my smartphones I got an softphone app for my fritzbox. Basically it is a SIP to call others on a landline. When I connect my smartphones to my linux server wlp2s0 (192.168.2.1) I can ring other phones but voice is not transmitted in any direction. Affected ports by the sip are tcp 5060 and udp 50000:50100.
This is due to the SIP protocol not being NAT friendly.

SIP uses UDP/5060 for authentication and call setup, but the actual voice data is transmitted using RTP (Real-time Transport Protocol). The latter has no default port number.

During call setup, the calling party will inform the peer of the IP address and port number to be used for the RTP connection, but if that party is behind NAT, both will probably be wrong. In your case, the smartphone app will probably request RTP data be sent to 192.168.2.<something>/UDP/50000. Not only is that the wrong IP address, but at that point the NAT router hasn't even created a mapping for a UDP port. And even if it had, it would be an incredible stroke of luck if the external port number of that mapping happened to be identical to the internal port.

There are two ways to fix this.
  1. Have the client send the external IP address rather than the NATed address. This requires configuration on the client side; you need to specify a STUN server somewhere in the softphone app.

    STUN is simply a service that tells a VoIP client the IP address it's being NATed behind, and there are a number of public STUN servers you can use (Google is your friend).

  2. Have the router/gateway modify the data inside the SIP control session to reflect the NAT mapping. This requires the router to contain an Application Layer Gateway (ALG) (also known as a "NAT helper") for the SIP protocol.

    You may already have this module on your router, but it doesn't load automatically. Try modprobe nf_nat_sip and see what happens.
The Xiamo router probably contains a permanently enabled SIP ALG as well as ALGs for other NAT-unfriendly protocols that insert layer 3 references in their control streams, like FTP and PPTP.
 
1 members found this post helpful.
Old 10-18-2019, 06:09 AM   #3
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,347

Rep: Reputation: Disabled
I forgot: On recent kernels, the nf_conntrack module doesn't invoke NAT helper modules by default. You can do this manually with a rule in the "raw" table:
Code:
iptables -t raw -A PREROUTING -p udp --dport 5060 -j CT --helper sip
 
1 members found this post helpful.
Old 10-18-2019, 12:46 PM   #4
uezelbruezel2000
LQ Newbie
 
Registered: Nov 2010
Posts: 7

Original Poster
Rep: Reputation: 0
Thumbs up

Dear Ser Olmy,

congratualations! I have never seen such a detailed, competent and helpful answer ever to any of my questions I had. This solution would not have come to my mind.

I tried

Code:
modprobe nf_nat_sip
and

Code:
iptables -t raw -A PREROUTING -p udp --dport 5060 -j CT --helper sip
and it immediately worked!

Thank you so much!

Marc
 
  


Reply

Tags
forwarding, route, sip, udp



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Googlecl stops work due change OAutGooglecl stops work due change OAuth 1.0 to OAuh 1.0 to OAuth 2.0 neymac Slackware 5 11-21-2015 03:26 PM
Port 50000 not listening still the system thinks it is in use devUnix Linux - Networking 6 10-21-2013 03:02 AM
Port 50000,1026,1027 in firewall log bgeddy Linux - Networking 2 10-24-2007 04:55 PM
mrt vs. DB2, the battle for port 50000 tongar SUSE / openSUSE 0 05-09-2007 10:32 AM
problems with Broadcom 4318 and BLAG 50000 poblano Linux - Wireless Networking 6 08-13-2006 02:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 01:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration