LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 10-08-2023, 12:15 PM   #1
sbergman20
LQ Newbie
 
Registered: Oct 2023
Posts: 1

Rep: Reputation: 0
How should I understand writing responses to a TUN device?


I'm trying to understand TUN as I'm working on a toy VPN implementation.

I have a point-to-point TUN with local IPs of 10.0.1.170/10.0.1.171. If I ping 10.0.1.171, I can see the packet in my agent that listens on the tun interface.

My confusion is how I could either return a real reply or a simulated reply back to the client that initiated the ping request to begin with.

So far, I've tried crafting a echo response packet while swapping the src and destination IPs. However, the IP is just the TUN device. How does it reach the client? Am I understanding the flow correctly?

I tried to draw a picture, but feel my intuition is wildly off.

https://user-images.githubuserconten...961600e16a.png.

To further expand this to a real world application. In a VPN if packets proxy to the TUN device to be encrypted before being sent off to some UDP tunnel, the client device is still going to expect a response. The writing _back_ to the TUN device to pass the packet back to the kernel is what is confusing me!

Is the entire trick here a NAT rule that says masquerade all IPs going to 10.0.1.171?
 
Old 10-10-2023, 03:10 PM   #2
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,857

Rep: Reputation: 161Reputation: 161
> My confusion is how I could either return a real reply or a simulated reply back to the client that initiated the ping request to begin with.
No, you can't do it because it is encrypted packet.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"SIOCGIFINDEX: No such device" when trying to get the interface index of a tun device. werner291 Linux - Software 2 02-14-2016 04:29 AM
vnuml tun device /dev/net/tun not found. asalford Linux - Networking 1 01-30-2007 10:11 PM
TUN device error palanisaravanan Linux - Networking 1 11-24-2004 12:17 AM
Getting FD for an existing tun device alanwolfen Programming 1 10-18-2004 11:39 AM
Universal tun/tap device driver support giddyupman Linux - Networking 4 05-14-2004 10:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration