I'm not clear about how the tun/tap
interface is working. From Wikipedia, I got this:
Packets sent by an operating system via a TUN/TAP device are delivered to a user-space program that attaches itself to the device. A user-space program may also pass packets into a TUN/TAP device. In this case TUN/TAP device delivers (or "injects") these packets to the operating system network stack thus emulating their reception from an external source.
Now, let's suppose that I create a tun
with IP
12.12.12.1. If on this machine I have two NICs, will I be able to communicate with this tun
(on 12.12.12.1 IP
) from an external machine(let's say 12.12.12.2) no matter what NIC device the second machine is connected to (let's say eth0
or eth1
)?
With other words, are the tun
and NICs independent one of each other, or you need to communicate with the tun
through a specific NIC?
N.B. Links on topic are welcome!
If you set up a virtual network e.g. 12.12.12.0/24
that is reachable via your virtual interface and you send a packet to this network from your machine, the kernel module implementing tun/tap will send this packet from the kernel via a character device to your application. It is up to your application that what it does with this packet. It can be transmitted to some other application (e.g. VPN server). Your application can also feed packets back via this character device, and the OS network stack will see these packets as ingress network traffic.
If the machine acts as a router it can just use a tun/tap virtual interface as a regular one and forward traffic via it, but it is always the application handling the device that manages packets. Outgoing traffic via the virtual interface is always delivered to your application, and incoming traffic via the virtual interface always originates from your application.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With