How to get the interface's ip address aliases ?

An interface has multiple IP addresses. There is the SIOCGIFADDR ioctl to get the main IP address, the SIOCAIFADDR to add an alias, and the SIOCDIFADDR to delete it.

What about the aliases ? How do i get them ?

Thanks.
 
have you tried running $ ifconfig without arguments, or with one argument (interface you want)

Code:
killasmurf86 % ifconfig rl0
rl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=8<VLAN_MTU>
	ether 00:50:8d:e7:8d:d7
	inet 192.168.128.100 netmask 0xffffff00 broadcast 192.168.128.255
	inet 192.168.128.98 netmask 0xffffff00 broadcast 192.168.128.255
	inet 192.168.128.99 netmask 0xffffffff broadcast 192.168.128.99
	inet 192.168.128.96 netmask 0xffffffff broadcast 192.168.128.96
	media: Ethernet autoselect (100baseTX <full-duplex>)
	status: active
last 3 are aliases
 
I'd look in source of ifconfig, if i was you.

I'll check my "Advanced Programming in the Unix environment" book, perhaps I'll find some info there
 
OK. I've got it. The getifaddrs returns all the addresses (using family AF_INET) =)

Another question: if there is a SIOCGIFADDR ctl to get the main IP Address, maybe there is such a ctl to get the aliases only (because the are ctls to set and delete them).
 
Back
Top