Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    delivering a packet through tun file descriptor leads to different res

    I created a tun interface
        openvpn --mktun --dev tun2
        ip link set tun2 up
        ip addr add dev tun2
    I wrote a program which relates the tun interface to a file descriptor `fd`, crafts a ICMP packet(source ip is, destination ip is and writes the ICMP packet to the `fd`,

    my program source code:

    I run the program `tun` by
        ./tun -i tun2
    but I don't get a ICMP echo reply,
    I capture it via tcpdump, the pcap file is:

    there is no ICMP echo reply

    Then I run a [simpletun][ on two machines, it works fine, and the pcap file is

    in the two pcap files, the two ping packets are the same, but my program doesn't trigger a ping echo reply

    it is strange, the principles of my program and `simpletun` are the same, they both write a ping packet to the `fd`, and the ping packets are the same, why my program doesn't get a echo reply while `simpletun` gets?


    the output of ip add
            1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
                link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
                inet scope host lo
                inet6 ::1/128 scope host
                   valid_lft forever preferred_lft forever
            2: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN qlen 1000
                link/ether 00:24:d7:78:71:38 brd ff:ff:ff:ff:ff:ff
            3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
                link/ether 5c:26:0a:2b:b8:06 brd ff:ff:ff:ff:ff:ff
                inet brd scope global eth0
                inet6 fe80::5e26:aff:fe2b:b806/64 scope link
                   valid_lft forever preferred_lft forever
            7: tun2: <NO-CARRIER,POINTOPOINT,MULTICAST,NOARP,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 100
                inet scope global tun2
    the output of ip ro
            default via dev eth0  proto static
   dev tun2  proto kernel  scope link  src
   dev eth0  proto kernel  scope link  src  metric 1

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    See my response to your other posting... And please don't do duplicate postings - edit or add to only one thread for the topic you are looking for help on.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts