RE: getting link-layer addr of unknown interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 11 Dec 2001, Amit Kucheria wrote:

> ip addr is for ip or ipv6. I was looking for link layer addresses. Maybe 
> i should have mentioned that in the subject line before.
> 
> Maybe 'ip link' is what i am looking for. I just glanced at the code.

Yes. ip link show dev eth0
ip l l dev eth0

> So does
>   ioctl(s, SIOCGIFINDEX, &ifr)
> get the list of all interfaces ???

No, it gets the ifindex for one interface given a name.

To get a list, either use netlink or ip l l or check in /proc/net/dev.

> Let me rephrase my requirement.
> 
> I should be able to get the link-layer address of an interface by 
> specifying the interface name ie. eth0, eth1 etc.
> (mac address for ethernet)

Use SIOCGIFHWADDR. See man 7 netdevice.

> And this interface might not have an ip address when i do this.

No matter.

Good luck

-- 
Stéphane Doyon
<sdoyon@vipswitch.com>


-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux