Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Linux kernel anyIP feature #3394

Closed
pumper opened this issue Mar 16, 2023 · 9 comments
Closed

Add support for Linux kernel anyIP feature #3394

pumper opened this issue Mar 16, 2023 · 9 comments

Comments

@pumper
Copy link

pumper commented Mar 16, 2023

Hi

I have a kimailio box that receives messages from one interface and send it from another interface and I use dispatcher module successfully.

Now I assigned an I range to Linux loopback interface through Linux kernel anyip feature. And I can ping the range.

ip -4 route add local 192.168.0.0/24 dev lo

this linux kernel feature is described in https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ab79ad14a2d51e95f0ac3cef7cd116a57089ba82 and https://blog.widodh.nl/2016/04/anyip-bind-a-whole-subnet-to-your-linux-machine/
another linux kernel feature that is required is Non-Local Binds in the Kernel which van be found in https://oswalt.dev/2022/02/non-local-address-binds-in-linux/ and after enabling that we must be able to send data with any ip address with kamailio this feature is described in https://oswalt.dev/2022/02/non-local-address-binds-in-linux/

I want to send messages from source of the ip in this range but kamailio cant do this in the right way.

I added this two directives to kamailio.cfg:

mhomed=yes

ip_free_bind = 1

and when I want to use an ip from the list I use

$fs=”udp:192.168.0.120:5060”;

With no luck

If I use

force_send_socket(udp:192.168.0.120:5060);

kamailio returns an error

bad force_send_socket argument: 192.168.0.120:5060 (kamailio doesn't listen on it)

and if I add listen directive for one ip like:

listen=udp:192.168.0.120:5060

everything works fine but I want to be able to use any ip from list not just one ip.

Thanks.

@henningw
Copy link
Contributor

This is probably not supported yet

@pumper
Copy link
Author

pumper commented Mar 17, 2023

Thanks for quick response I know this linux feature is not supported in kamailio and because of that I put this feature request here.
Thanks.

@joelsdc
Copy link

joelsdc commented Mar 18, 2023

Is there any limitation that stops you from using multiple listen= directives?

In fact, given enough resources, is there even a limit on the number of listen= directives that Kamailio can handle?

@jaybinks
Copy link

jaybinks commented Mar 18, 2023 via email

@sergey-safarov
Copy link
Member

sergey-safarov commented Mar 18, 2023 via email

@joelsdc
Copy link

joelsdc commented Mar 19, 2023

AFAIR, depending on the number of children or socket_workers combined with the amount listen= and the PKG_SIZE setting, RAM would be the limitation.

In an example where you have say 16mb of PKG_SIZE combined with children=1 you would need (16mb * 1 children * 65535 IPs) 1TB of RAM for a /16.

@henningw
Copy link
Contributor

Sure, having a complete network on individual workers will waste a lot of memory. Just to add a bit more context to this request, this is the feature in question link.

This blog post provides some good summary of the option and also explain the related IP_FREEBIND option: link

Copy link

github-actions bot commented Nov 8, 2023

This issue is stale because it has been open 6 weeks with no activity. Remove stale label or comment or this will be closed in 2 weeks.

@github-actions github-actions bot added the Stale label Nov 8, 2023
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 23, 2023
@sergey-safarov
Copy link
Member

sergey-safarov commented Dec 9, 2023

@pumper could you help me understand how to bind to 127.0.0.0/8.
At https://oswalt.dev/2022/02/non-local-address-binds-in-linux/ described use for bind to any IP

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(("0.0.0.0", 0))

But not for network addr with mask.
Hope you can suggest.

Probable it can be done using SO_BINDTODEVICE socket option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants