Eu abri uma interface utun e usei os seguintes comandos para configurá-la.
sudo ifconfig utun0 10.0.3.1 10.0.3.1 netmask 255.255.255.0 up
sudo route add -net 10.0.3.0 10.0.3.1
sudo sysctl net.inet.ip.forwarding=1
A execução do ifconfig lo0, en0 e utun0 resulta em:
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
options=3<RXCSUM,TXCSUM>
inet6 ::1 prefixlen 128
inet 127.0.0.1 netmask 0xff000000
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
nd6 options=1<PERFORMNUD>
en0: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
options=10b<RXCSUM,TXCSUM,VLAN_HWTAGGING,AV>
ether 95:ab:3d:5c:07:29
inet 192.168.0.101 netmask 0xffffff00 broadcast 192.168.0.255
media: autoselect (100baseTX <full-duplex,flow-control>)
status: active
utun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1500
inet 10.0.3.1 --> 10.0.3.1 netmask 0xffffff00
Executar netstat -nr resulta em:
Routing tables
Internet:
Destination Gateway Flags Refs Use Netif Expire
default 192.168.0.1 UGSc 35 1195 en0
10.0.3/24 10.0.3.1 UGSc 0 0 utun0
10.0.3.1 10.0.3.1 UH 2 0 utun0
127 127.0.0.1 UCS 0 0 lo0
127.0.0.1 127.0.0.1 UH 47 45013 lo0
169.254 link#4 UCS 0 0 en0
192.168.0 link#4 UCS 1 0 en0
192.168.0.1/32 link#4 UCS 1 0 en0
192.168.0.1 48:54:70:de:60:09 UHLWIir 36 804 en0 1058
192.168.0.101/32 link#4 UCS 1 0 en0
192.168.0.101 95:ab:3d:5c:07:29 UHLWI 0 82 lo0
192.168.0.103 8e:76:28:93:35:f5 UHLWIi 1 325 en0 1180
224.0.0 link#4 UmCS 1 0 en0
224.0.0.251 a9:d5:8c:80:48:17 UHmLWI 0 0 en0
255.255.255.255/32 link#4 UCS 0 0 en0
Internet6:
Destination Gateway Flags Netif Expire
::1 ::1 UHL lo0
fe80::%lo0/64 fe80::1%lo0 UcI lo0
fe80::1%lo0 link#1 UHLI lo0
ff01::%lo0/32 ::1 UmCI lo0
ff02::%lo0/32 ::1 UmCI lo0
Agora posso criar um pacote de solicitação de ping com o IP de origem: 10.0.3.1 e IP de destino: 192.168.0.101 e obter uma resposta bem-sucedida. Mas se eu mudar o IP de destino para 127.0.0.1, não obtenho resposta.