Score:0

Creating a virtual IP to route packets through a specific interface

br flag

I have a server with ip 34.0.0.0 and multiple network devices, each corresponding to a local ip address 192.168.42.1, 192.168.42.2, 192.168.42.3, etc.

I'd like to be able to create a local tunnel through each of these interfaces so that traffic is routed through the corresponding local interface. For example, I'd like to create 192.168.72.1 that routes traffic through 192.168.42.1 to 34.0.0.0. Is this possible?

I know that with multiple destination ip addresses I can selectively route packets through each of the interfaces with iptables but I'm not sure now to create a local tunnel. My server has only one ip address and I'd like to do this purely on the client. Additionally, I don't have control over the sending code so I cannot selectively bind the sockets to each local IP but I can change the target IP that the packets are sent to.

EDIT: After some more digging it seems what I'd like to do is mark a packet as it goes through the OUTPUT chain of iptables and use this to inform the routing decision? Is there an easier way than this? It seems that the packet destination can't be changed after the routing decision is made.

Nikita Kipriyanov avatar
za flag
You need to use routing policy database. Please read LARTC, its purpose is exactly to answer questions like this. And no, you don't need any tunnels or additional IPs, you need additional *routing tables* and *routing rules*.
br flag
@NikitaKipriyanov can you point me to where in LARTC it describes how to do this? Everything I have seen describes how to split packets with different destination IPs, but not how to split packets with the same destination IP by rewriting the destination IP...
Nikita Kipriyanov avatar
za flag
I don't see anything in your quesiton that signifies a different *destination* translation should be done for different packets (and what is the selector). Could you please clarify the task then, by submitting an example of how in the end packets (ideally) should be processed, instead of suggesting an assumed solution (tunnel)? Say, hat, packets from A to M must arrive to X, packets from B to M must arrive to Y, or something like that.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.