Godstanis
Godstanis

Reputation: 11

curl --interface not going through the created utun interface on Mac OS

My TUN device setup

I have a simple program that creates the interface and logs every packet in Go (removed err handling for clarity):

package main

import (
    "log"
    "github.com/songgao/water"
)

func main() {
    ifce, _ := water.New(water.Config{DeviceType: water.TUN})

    log.Printf("Interface Name: %s\n", ifce.Name())
    packet := make([]byte, 2000)
    for {
        n, _ := ifce.Read(packet)
        log.Printf("Packet Received: % x\n", packet[:n])
    }
}

And after running the program I get this:

sudo ifconfig utun6 198.18.0.1 198.18.0.1 up
ifconfig utun6                           
#utun6: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1500
#        inet 192.18.0.1 --> 192.18.0.1 netmask 0xffffff00
#        nd6 options=201<PERFORMNUD,DAD>

What I try

When I try to curl --interface utun6 http://example.com:

I suppose this is a routing issue.

What I can see in my program and in sudo tcpdump -i utun6:

But when I set up routes (http://example.com ip is 93.184.215.14):

sudo route add 93.184.215.14 192.18.0.1

I actually see the packets from curl (without the --interface flag)

Upvotes: 1

Views: 32

Answers (0)

Related Questions