Skip to content

Is tun working on windows? #88

@tubzby

Description

@tubzby

I write a simple piece of test code on windows. after I startup the program, I set ip address of 10.8.0.6 , mask 255.255.0.0

Then I set a route via "route add 192.168.66.0 mask 255.255.255.0 10.8.0.6", then on a console I ping 192.168.66.1 to check if any packet is coming through the tun interface, but I don't see anything related to the ping command.

On the other hand, I used wireshark to capture all the request, seems that the operating system is sending ARP before sending the real traffic.

But, tun only support layer3, how to handle this situation?

test code:

func main() {
	tun, err := water.New(water.Config{
		DeviceType: water.TUN,
	})
	if err != nil {
		panic(err)
	}
	bs := make([]byte, 1500)

	i := 0
	log.SetLevel(log.DebugLevel)
	log.Infof("ready to start wireshark on: %s, isTap: %v", tun.Name(), tun.IsTAP())

	for {
		_, err := tun.Read(bs)
		if err != nil {
			log.Panic(err)
		}

		ver := (bs[0] & 0xf0) >> 4
		if ver == 4 {
			var header ipv4.Header
			header.Parse(bs)
			log.Infof("src:%s, dst:%s, protocol:%d", header.Src.String(), header.Dst.String(), header.Protocol)

		} else if ver == 6 {
			log.Infof("get ipv6 package")
		} else {
			log.Infof("unknown package")
		}

		i++
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions