meh / rust-tun

TUN device creation and handling.
340 stars 133 forks source link

Nothing happening on macOS #53

Open juliuswaldmann opened 1 year ago

juliuswaldmann commented 1 year ago

Hello. I used the following code to set up a simple tun device and read from it:

  `let mut config = tun::Configuration::default();
    config.address((10, 2, 0, 1))
        .netmask((255, 255, 255, 0))
        .up();

    #[cfg(target_os = "linux")]
    config.platform(|config| {
        config.packet_information(true);
    });

    let mut dev = tun::create(&config).unwrap();
    let mut buf = [0; 4096];

    loop {
        let amount = dev.read(&mut buf).unwrap();
        println!("{:?}", &buf[0 .. amount]);
    }`

As you can see it is just the example code from the repository. of course i imported everything correctly. I don't get an error and it seems to work at first but nothing happens when i send a packet to the ip address of the interface.

Running ipconfig getiflist also doesn't show a utun device. I am using macOS 13.1 Ventuara btw. Thank you for your help.

yinheli commented 1 year ago

Did you setup route? For example https://github.com/yinheli/kungfu/blob/master/src/gateway/server.rs#L131

juliuswaldmann commented 1 year ago

Did you setup route?

For example https://github.com/yinheli/kungfu/blob/master/src/gateway/server.rs#L131

No I didn't cause I didn't know I had to. I will try it out and report back if it worked. Thank you for your help