Score:0

Linux - IP tunnel

ru flag

I have two machines on different subnet. Say one is 1.1.1.1/8 while the other is 2.2.2.2/8. The two are able to talk through a common router.

The 2.2.2.2 machine has an internal interface on a third local network 176.16.1.1/24. An application is listening on this interface. The router is not aware of the 176.16.x.x subnet.

On the 1.1.1.1 I want to be able to send data to the 176.16.1.1 interface.

I want 1.1.1.1 to generate IP packets with a source=1.1.1.1 and destination=2.2.2.2. The packets should encapsulate another packet with the source 1.1.1.1 and destination 172.16.1.1.

I expect the 2.2.2.2 machine to decapsulate the packet and deliver the internal 1.1.1.1->172.16.1.1 packet to the application. Since 1.1.1.1 is a routable IP, the app can respond with a non-encapsulated standard IP packet.

Any hint on how to do that would be greatly appreciated. Thanks!

Edit

On the 1.1.1.1 I used the following

ip tunnel add ipiptun1 mode ipip local 1.1.1.1 remote 2.2.2.2
ip link   set ipiptun1 up
ip addr   add 172.16.0.0/16 dev ipiptun1

The above also creates a routing table entry

172.16.0.0/16 dev ipiptun1 proto kernel scope link src 172.16.0.0

And encapsulated packets do arrive at 2.2.2.2 where the inner packet is 172.16.0.0 -> 172.16.1.1.

However, despite 2.2.2.2 having an eth0:103 interface with the 172.16.1.1 address, the data does not arrive at the application. Instead an ICMP unreachable is returned to 1.1.1.1.

Tobias K. avatar
id flag
A few thoughts: 1) 172.16.0.0 itself is a network ID address, and should probably not be used as a client address. 2) If you use TCP I don't think sending one direction via the tunnel and expecting the response via another (the public) interface will work because of the connection-oriented nature. 3) I would just use SSH port forwarding if possible, from 1.1.1.1 `ssh 2.2.2.2 -L 127.0.0.1:1234:176.16.1.1:8000` (using 8000 as example for App-port), and then send your normal packets to 127.0.0.1:1234.
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.