0

My plan is to read from one tun interface and write to another.

Here are my command when I set up the interface:

sudo ip tuntap add dev router0 mod tun
sudo ip addr add 10.0.0.138/24 dev router0
sudo ip link set dev router0 up

Here is the output of ip addr show dev router0

8: router0: <NO-CARRIER,POINTOPOINT,MULTICAST,NOARP,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 500
    link/none 
    inet 10.0.0.138/24 scope global router0
       valid_lft forever preferred_lft forever

When I try to ping 10.0.0.138 listen on the interface using tshark via sudo tshark -i router0, nothing happens.

Here is my ping 10.0.0.138 output:

PING 10.0.0.138 (10.0.0.138) 56(84) bytes of data.
64 bytes from 10.0.0.138: icmp_seq=1 ttl=64 time=0.063 ms
64 bytes from 10.0.0.138: icmp_seq=2 ttl=64 time=0.058 ms

Here is my sudo tshark -i router0 output:

Capturing on 'router0'

Nothing is coming through

What is the problem?

Happy Jerry
  • 164
  • 1
  • 8
  • Notice that the output of `ip addr show dev router0` says: `state DOWN` – Ron Maupin Jun 15 '22 at 13:23
  • @RonMaupin Am I not putting the state to up with `ip link set dev router0 up` – Happy Jerry Jun 15 '22 at 19:06
  • For a tunnel to be up, both ends of the tunnel need to be up and communicating with each other. – Ron Maupin Jun 15 '22 at 19:24
  • @RonMaupin How could I achieve this? The documentation does not seem to mentio nthat – Happy Jerry Jun 15 '22 at 19:41
  • @RonMaupin I am aware of how that works, but that does not address the issue that the state is down. I am pinging from the same network. What's happening is that packets are skipping the network stack and being sent to my loopback. My question is how can I read from that interface. – Happy Jerry Jun 15 '22 at 19:52
  • A tunnel is a connection between two endpoints that looks like a direct connection between the endpoints because it encapsulates the packets inside other packets that makes all the hops to the tunnel on the other end, so the packet inside the tunnel never sees all the hops that the outer packet sees, and it looks like the inner packet made one hop from the source to the destination. That is a tunnel (a VPN is one type of tunnel that is typically encrypted). The tunnel endpoints must be able to communicate with each other like both end of a cable must connect for the interfaces to be up. – Ron Maupin Jun 15 '22 at 20:00
  • So the tun is only up when a packet is in transit? – Happy Jerry Jun 15 '22 at 20:25
  • No, a tunnel is up when each end communicate with the other end. Depending on the tunnel protocol used, there could be a handshake. Encrypted tunnels exchange the encryption data in phases before the tunnel comes up. Once it is up (both ends), anything sent in one end comes out the other end. Yours is down until the other end comes up and sends a, "_Hey! I'm here!_" to your end. It also works the other way in that your end would reply, "_I'm here, too!_" – Ron Maupin Jun 15 '22 at 20:31

0 Answers0