Subject: SIOCAIFADDR vs ifconfig
To: None <tech-net@netbsd.org>
From: Tomas Berndtsson <tomber@packetfront.com>
List: tech-net
Date: 09/22/2001 20:28:19
Hi,
On NetBSD/powermac have a program where I use ioctl SIOCAIFADDR to add
an alias to lo0. I add 192.168.127.26/255.255.255.0. Ifconfig -A lo0
then tells me:
lo0: flags=8009<UP,LOOPBACK,MULTICAST> mtu 33228
inet 127.0.0.1 netmask 0xff000000
inet alias 192.168.127.26 netmask 0xffffff00
And netstat -rn:
127 127.0.0.1 UGRS 0 0 33228 lo0
127.0.0.1 127.0.0.1 UH 1 64 33228 lo0
192.168.127.26 192.168.127.26 UH 0 0 33228 lo0
This looks perfectly alright to me, but when I try to ping
192.168.127.26, I get:
PING 192.168.127.26 (192.168.127.26): 56 data bytes
ping: sendto: No route to host
ping: sendto: No route to host
^C
Now, if I add the same alias, using ifconfig:
ifconfig lo0 192.168.127.26 netmask 255.255.255.0 alias
I get the exact same output from ifconfig -A lo0 and netstat -rn as
when I added it using my program, but now I can suddenly ping it.
I've been trying to read the source of ifconfig to see if it does
anything more than SIOCAIFADDR to set the alias, but I can't see that
it does. Can anyone enlighten me on this?
Greetings,
Tomas