0

I'm on OS Sierra. This is (part of) what I get on ifconfig

...
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
    ether 98:01:a7:b4:91:63 
    inet6 fe80::4e:52ae:9fa8:2e6c%en0 prefixlen 64 secured scopeid 0x5 
    inet 192.168.1.33 netmask 0xffffff00 broadcast 192.168.1.255
    nd6 options=201<PERFORMNUD,DAD>
    media: autoselect
    status: active
...
utun1: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1400
    inet 10.161.136.55 --> 10.161.136.55 netmask 0xffffffff

If I try to ping 127.0.0.1 from en0 interface (command ping -S 192.168.1.33 127.0.0.1) it works fine, but if I try to ping it from utun1 (command ping -S 10.161.136.55 127.0.0.1) I get a timeout. Why is that?

Actually, I had a look at netstat and saw this:

Routing tables

Internet:
Destination        Gateway            Flags        Refs      Use   Netif Expire
10.161.136.55      10.161.136.55      UHr            65      550   utun1
10.161.136.55/32   link#14            UCS             0        0   utun1
192.168.1.33/32    link#5             UCS             1        0     en0
192.168.1.33       98:1:a7:b4:91:63   UHLWI           0        9     lo0
...

Why do addresses 10.161.136.55 and 192.168.1.33 have such different configurations for the netif column? How do I change them? I'd like to change line 10.161.136.55 to use netif lo0

  • I wouldn't expect this to work. It doesn't make sense to ping 127.0.0.1 on some other interface than lo0 – Michael Hampton Nov 08 '18 at 20:51
  • @MichaelHampton The behavior I would expect is that `-S` specify a source address, not an interface. And the interface is chosen based on routing table towards the destination, in this case `127.0.0.1`. For that reason I would have expected identical behavior regardless of which local IP address is given to `-S`. The question is not whether it is supposed to work or not, but rather why giving another local IP address to `-S` changes the behavior. – kasperd Nov 08 '18 at 21:14
  • @kasperd Well it doesn't make any sense that way either. – Michael Hampton Nov 08 '18 at 21:18
  • 127.0.0.1 also known as localhost is only available on the host itself through the lo interface. you cant reach it through any other interface, a nice of peace of information about [here](http://www.tech-faq.com/127-0-0-1.html) – Zina Nov 08 '18 at 21:25
  • @MichaelHampton cool, so why does the routing table have the line `192.168.1.33 98:1:a7:b4:91:63 UHLWI 0 9 lo0`, I never set it manually. Is it specific to some network interfaces? – UndefinedBehavior Nov 08 '18 at 22:28
  • Anyway the original question is still unanswered: why does `ping -S 192.168.1.33 127.0.0.1`and `ping -S 10.161.136.55 127.0.0.1` does not? – UndefinedBehavior Nov 08 '18 at 23:44
  • @Zina but I can reach it from interface en0 (192.168.1.33). Why is that? – UndefinedBehavior Nov 08 '18 at 23:45
  • @UndefinedBehavior - strange, as before I posted my comment I tested it on my Virtual Box Ubuntu VM, and now again. I have one interface internal only, one with Internet access ant the lo interface, and I can ping 127.0.0.1 ONLY through the lo interface. I used `-I` which on linux will use the interface. now I saw you said Mac :) so tested in on my Mac, and yes - with the `-S` you can ping from any interface which is not tunnelled. – Zina Nov 09 '18 at 18:59
  • 1
    I have tested it and can ping from my local interface, my en0 interface, my VirtualBox added interfaces, but NOT from a VPN interface. The reason would be that the tunnelled interface does go through the tunnel only, while all the "local" interfaces can reach 127.0.0.1 as they reside on the same host. – Zina Nov 09 '18 at 19:02

0 Answers0