I'm trying to connect a tap0 and en0 interface with the natd. The (simplified) background is:
I have one application running on a smartphone and a simple UDP Server running on my laptop. The UDP Server is listening on the tap-Interface and I want to speak to the server with my smartphone application. (As I said this is a bit simplified, the UDP Server has to listen on the tap Interface and cannot listen on en0.)
I tried the following:
$ su $ exec 5<>/dev/tap0 (running in one terminal-tab)
Set the tap0-address, netmask, etc.
$ sudo ifconfig tap0 inet 10.1.1.100 netmask 255.255.255.0 broadcast 10.1.1.255
Enable Port forwarding
$ sudo sysctl -w net.inet.ip.forwarding=1
$ sudo /usr/sbin/natd -alias_address MY_EN0_IP \ -interface tap0 -use_sockets -same_ports -dynamic -clamp_mss \ -enable_natportmap -natportmap_interface en0 \ -redirect_port udp 10.1.1.100:50000 50000 -l
Start a sample UDPServer, listening on 10.1.1.100:50000
Netstat shows the opened port:
$ netstat -n | grep 50000 udp4 0 0 10.1.1.100.50000 *.*
When I send a packet from my smartphone to the laptop with target:MY_EN0_IP:50000 I can see the packet with Wireshark arriving at en0, but the laptop is answering with an "ICMP port unreachable" message.
I have no clue what is going wrong, shouldn't the natd open port 50000 on en0, accept the packets and NAT them to the tap0 interface? What am I missing?