Find the answer to your Linux question:
Results 1 to 2 of 2
I created a tun interface Code: openvpn --mktun --dev tun2 ip link set tun2 up ip addr add 10.0.0.1/24 dev tun2 I wrote a program which relates the tun interface ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2012
    Posts
    87

    delivering a packet through tun file descriptor leads to different res


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

    my program source code:
    https://docs.google.com/file/d/0B09y...it?usp=sharing

    I run the program `tun` by
    Code:
        ./tun -i tun2
    but I don't get a ICMP echo reply,
    I capture it via tcpdump, the pcap file is:
    https://docs.google.com/file/d/0B09y...it?usp=sharing

    there is no ICMP echo reply


    Then I run a [simpletun][http://www.cis.syr.edu/~wedu/seed/La...es/simpletun.c on two machines, it works fine, and the pcap file is
    https://docs.google.com/file/d/0B09y...it?usp=sharing

    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?


    BTW:

    the output of ip add
    Code:
            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 127.0.0.1/8 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 138.96.201.72/20 brd 138.96.207.255 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
                link/none
                inet 10.0.0.1/24 scope global tun2
    the output of ip ro
    Code:
      
            default via 138.96.192.250 dev eth0  proto static
            10.0.0.0/24 dev tun2  proto kernel  scope link  src 10.0.0.1
            138.96.192.0/20 dev eth0  proto kernel  scope link  src 138.96.201.72  metric 1

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,755
    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
  •