I have the network:
Computer A (MacOS) (192.168.0.10) <--(Wi-Fi)--> Computer B (Ubuntu) (192.168.0.15).
Computer A has VM (Kali) with NAT interface connection (172.16.219.128).
I want ping 172.16.219.128 (A's VM) from 192.168.0.15 (B).
I added route in 192.168.0.15 (B):
# route add -net 172.16.219.0 netmask 255.255.255.0 gw 192.168.0.10
# route
Destination Gateway Genmask Flags Metric Ref Use Iface
default��� 192.168.0.1 0.0.0.0 UG 600 0 0 wlp7s0
link-local * 255.255.0.0 U 1000 0 0 wlp7s0
172.16.219.0 192.168.0.10 255.255.255.0 UG 0 0 0 wlp7s0
192.168.0.0 * 255.255.255.0 U 600 0 0 wlp7s0
# traceroute 172.16.219.128
traceroute to 172.16.219.128 (172.16.219.128), 30 hops max, 60 byte packets
1 * * *
2 * * *
3 * * *
4 * * *
5 * * *
6 * * *
7 * * *
8 * * *
9 * * *
10 * * *
11 * *^C
Of course, ping also not receive packets. I think computer B even tot send packets through gateway... why?
If I do "ping 172.16.219.128" from computer A it works very well.
P.S: When I change VM interface to Bridge adapter then computer B can ping it (of course, with new IP 192.168.0.20) without adding a route.
sudo sysctl -w net.inet.ip.forwarding=1
sudo sysctl -w net.inet.ip.fw.enable=1
?