Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I see ping does

connect(5, {sa_family=AF_INET, sin_port=htons(1025), sin_addr=inet_addr("0.0.0.0")}, 16) = 0

and then does

getsockname(5, {sa_family=AF_INET, sin_port=htons(56630), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0

I don't see the reason in the documentation of either syscall.

I was thinking it might be due to its subnet being the biggest one one commonly has (/8), but I just set up a (/1), and it still used 127.0.0.1. Even if I set the lo interface down, it still tries 127.0.0.1 and just hangs until I bring it back up. I removed the 127.0.0.1/24 address from lo, and gave lo the address 128.0.0.1/1 with the same options 127.0.0.1/8 had, and that caused `ping 0` to return the error, "connect: Invalid argument". So, I don't know. At least I learned that the behavior seems to really be tied to the address and not the loopback interface, which I though was supposed to abstract the address.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: