Sample Header Ad - 728x90

Unable to receive packets onto utun interface?

1 vote
0 answers
385 views
I'm using the NetworkExtension framework to create a virtual utun interface. My application receives packets from a client and the application writes the packet into the utun interface. Since I have enabled ip forwarding using sudo sysctl -w net.inet.ip.forwarding=1 on the system, the packet is sent to the correct interface en0 and sent out through the wire. When a response is sent back, it is received on the en0 interface. However, I want to forward these packets to the utun interface so that my application can read the packets received. How can I achieve this? Example: 1. VPN Application receives packet from client. 2. Application writes packet to utun interface with source 100.64.0.77 and destination 192.168.1.95 3. OS networking stack sees that the packets destined for 192.168.x.x are to go to interface en0 4. Packet is sent out through wire to 192.168.1.95 5. 192.168.1.95 sends a response packet with destination 100.64.0.77 and source 192.168.1.95 6. The response packet is only received on the en0 interface 7. The response packet needs to be put onto the utun interface somehow so that my application can read the packet. How do I achieve this? Some useful information below:
>netstat -nr
Routing tables

Internet:
Destination        Gateway            Flags        Netif Expire
default            192.168.1.254      UGSc           en0       
default            link#10            UCSI         utun2       
100.64.0.77        100.64.0.77        UH           utun2       
127                127.0.0.1          UCS            lo0       
127.0.0.1          127.0.0.1          UH             lo0       
169.254            link#7             UCS            en0      !
192.168.1          link#7             UCS            en0      !
192.168.1          link#10            UCSI         utun2       
192.168.1.92/32    link#7             UCS            en0      !
192.168.1.99       8c:a9:82:2e:d6:2e  UHLWI          en0    986
192.168.1.254/32   link#7             UCS            en0      !
192.168.1.254      70:f1:96:86:e6:a0  UHLWIir        en0   1196
224.0.0/4          link#7             UmCS           en0      !
224.0.0/4          link#10            UmCSI        utun2       
224.0.0.251        1:0:5e:0:0:fb      UHmLWI         en0       
255.255.255.255/32 link#7             UCS            en0      !
255.255.255.255/32 link#10            UCSI         utun2   

>ifconfig utun2
flags=8051 mtu 1500
options=6403
inet 100.64.0.77 --> 100.64.0.77 netmask 0xffffff00
Asked by SunflowerNetworks (11 rep)
Dec 8, 2020, 02:33 AM
Last activity: Dec 8, 2020, 06:06 AM