Community discussions

MikroTik App
 
ghostt
just joined
Topic Author
Posts: 21
Joined: Tue Apr 24, 2018 4:07 pm
Location: Australia

Define SIP in PPPoE

Sat Feb 02, 2019 8:49 am

Hello everyone!

I have a question about SIP, maybe somebody can help.

We have a Mikrotik CCR v6.43.8 running as a PPPoE server with number of PPPoE clients. Each client is a simple SOHO router (not Mikrotik, not managed by us).

What I need is to recognize SIP packets when they are sent from those PPPoE clients to outside world.

If I simply watch ports UDP / TCP 5060-5061 on dynamic PPPoE interfaces, I can see packets. This bit is not a problem. The problem is if an unknown port is used.

Is there any way to recognise a SIP packet regardless TCP / UDP port?

I found the following in one of the forums:
/ip firewall layer7-protocol
add comment="" name=sip regexp=\
   "^(invite|register|cancel) sip[\t-\r -~]*sip/[0-2]\\.[0-9]"

/ip firewall mangle
add action=mark-packet chain=prerouting comment=\
   "SIP Packets" disabled=no in-interface=all-ppp\
   layer7-protocol=sip new-packet-mark=sip_packet passthrough=yes

It worked like that only:
/ip firewall layer7-protocol
add comment="" name=sip regexp="^(invite|register|cancel)"

/ip firewall mangle
add action=mark-packet chain=prerouting comment=\
   "SIP Packets" disabled=no in-interface=bridge-lan\
   layer7-protocol=sip new-packet-mark=sip_packet passthrough=yes
I mean it works only if a SIP client is on a our CCR's LAN (in-interface=bridge-lan).
However, if a SIP client is behind a PPPoE router, that mangle rule is not working, therefore I can’t see SIP packets forwarded from PPPoE interfaces to a remote SIP server…

Changing chain from prerouting to forward in the mangle rule doesn’t help

Sorry if the description is a bit confusing.

Thank you in advance
 
User avatar
pcunite
Forum Guru
Forum Guru
Posts: 1347
Joined: Sat May 25, 2013 5:13 am
Location: USA

Re: Define SIP in PPPoE

Sat Feb 02, 2019 5:41 pm

My understanding, not the authority here, ... for non-encrypted packets, you can identify Session Initiation text that appears. I don't know how traffic is flowing through your router to tell you which chain. This is step 1.

Then you need to identify RTP (the audio) which gets randomly assigned to ports (usually between the 10K-20K range). See wire shark notes here.

You might tell us what you're trying to do. Otherwise, you may have to write a custom packet filter that reads the SIP session data then acts on that to go identify all the ports that were dynamically requested, for that initial session.
 
ghostt
just joined
Topic Author
Posts: 21
Joined: Tue Apr 24, 2018 4:07 pm
Location: Australia

Re: Define SIP in PPPoE

Sun Feb 03, 2019 2:55 am

I don't know how traffic is flowing through your router to tell you which chain. This is step 1.
...
You might tell us what you're trying to do.
Hello pcunite,

Thank you very much for the answer. Our company provides an Internet access for a building. We have a direct connect from our Mikrotik (CCR1036) to Internet with a public static IP address. Then we have our own "management" lan and pppoe server for the clients. Each client has a router that creates a pppoe session to our Mikrotik. Once established, a dynamic pppoe interface is created in Mikrotik, and the client has an Internet access.

I'm trying to stop the pppoe clients using 3-rd party SIP providers, this is a building management policy. Therefore, I'm trying to intercept SIP traffic by the firewall filter on in-interface=all-ppp.

It works on forward chain if I watch traffic on ports 5060-5061. But if a different port(s) is used rather than 5060, I simply don't see the SIP traffic.

So, I thought if there is a possibility within Mikrotik to recognize a SIP (or RTP) packet coming from all-ppp; in similar way Wireshark does that: it recognizes and marks a packet as "SIP" regardless of a TCP or UDP port.
 
User avatar
CZFan
Forum Guru
Forum Guru
Posts: 2098
Joined: Sun Oct 09, 2016 8:25 pm
Location: South Africa, Krugersdorp (Home town of Brad Binder)
Contact:

Re: Define SIP in PPPoE

Mon Feb 04, 2019 12:40 am

Will it not be easier to allow SIP traffic only to the SIP providers you / building management approves of with Address Lists?
 
ghostt
just joined
Topic Author
Posts: 21
Joined: Tue Apr 24, 2018 4:07 pm
Location: Australia

Re: Define SIP in PPPoE

Mon Feb 04, 2019 2:01 am

Will it not be easier to allow SIP traffic only to the SIP providers you / building management approves of with Address Lists?
Thank you for the reply. Yes, you are correct, it would be much easier. However, the building management is the only allowed SIP provider if you are using the building Internet by the resident's usage agreement. ALL others should be blocked. I'm blocking them on ports 5060-5061. But that is the only mechanism I can make working to define that this is a SIP packet if a client is behind PPPoE router.

If a SIP client is on our LAN (not behind PPPoE), the code in my first post works regardless of the port that SIP client uses.

So, if SIP traffic is going from a PPPoE router to the outside world, and the port is different to 5060-5061, I can't stop it. (so far) :)

Thank you again for trying to help.
 
ghostt
just joined
Topic Author
Posts: 21
Joined: Tue Apr 24, 2018 4:07 pm
Location: Australia

Re: Define SIP in PPPoE

Thu Feb 07, 2019 1:13 am

A bit of update, if someone is interested. The rule in my first post doesn't work if a SIP client uses TCP. Wireshark doesn't recognize such packets as "SIP" either.

This is a part of the problem. However I still can't recognize UDP SIP packets if they are sent from behind PPPoE.

Filtering ports 5060-5061 is the only method I'm aware of so far. If I find something I'll share the knowledge. Meanwhile, any help or ideas are welcome.

:)

Who is online

Users browsing this forum: Techsystem, wispmikrotik and 24 guests