ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have several routers A,B,C,... located in remote sites behind firewall(s) and main host X (with public IP).
The routers A,B,C,... are connected to X with various tunnels creating star-like topology with X being a central point.
In general it is possible to communicate between each A,B,C,... router and X.
Routers A,B,C,.. are used as a connection points for mobile measurent devices.
Due to the configuration difficulty each measurement device can have only one pre-configured local unique IP from the class 192.168.10.0/24.
Any of the measurment device can be attached/detached to any of the A,B,C,... routers at any moment.
When the measurement device is attached to the network it starts to send a series of UDP packets.
I can see these packets from currently attached devices at X host.
I am able also to detect which way the device is sending data i.e. which the router is involved in the communication i.e. which tunnel is in use.
But I have problem to send back the reply to the device(s) since I am not able to use fixed routing policy.
The constant routing policy is not adequte since for a moment the device can be moved to another location(s) and connected to another router (btw: the measurment devices are using wifi as a media for communication with the routers so location change and establishing new network access is very easy)
The solution would be the possiblity of sending the reply packet(s) via programmatically defined interface rather than relying on constant routing table.
The question:
Is it possible to send any packet along with extra information about the interface which should be used as a route?
I would like to avoid the necessity of permanent routing table change each time the measurment device is moved to another location.
In other words: how to force a packet to be sent via device without respective entry in routing table?
Of course bridge-like solutions will work but I am interested in sending packets directly to the destination only (i.e. via interface the measurement device being involved in communication) rather than "brodcasting" them to all.
Let's imagine that someone incorrectly configured two measurement devices (with same IPs).
Having the method of sending packet via specific interface I am able to communicate with both of them despite IP conflict...
What is more I can programmatically detect and report this conflict.
Without using some sort of Linux software in a Linux router that was designed to do exactly what you want to do by detecting packets and creating dynamic routes then you have exhausted your options as stated in the posts above.
How sophisticated are your measurement devices? Any chance they could autonomously open/maintain a reverse ssh tunnel to X? Then when you want to connect to a device, you don't care about what its IP is or what router it's behind, you just connect through its tunnel.
This is what I do on our remote systems. It gets past all of the nastyness of hopping through intermediate machines, port forwarding, etc. As soon as the system boots up, it opens a reverse ssh tunnel to one of the servers at our office, with a port that's unique to that device (based on serial number). I don't care where the device is or what network it's behind, to connect to it I just connect to its tunnel. These are pretty advanced devices running a relatively modern 60+ MB embedded Linux distro with lots of bells and whistles, though.
Last edited by suicidaleggroll; 07-09-2014 at 05:29 PM.
Thanks a lot for suggestion but it will not work for me.
The devices are not designed for any software changes. I am happy that they are equipped with wifi and are able to smoothly reconnect.
Therefore it is a must to use intermediate routers which forward data to/from device in the way which is possible at a site (the tunnel type depends on policy of the internet service provider).
More "sofisticated" functions are done at routers.
And it works with the problem of "back transmission" which forces me to permanently mangle routes.
Therefore I've placed the post in programming section with hope to get answer on topic question: how to force the packet to be sent via selected interface?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.