I have a linux system for which I want to create my own udev rules for the nic. Currently there are no rules, so no ethX is configured. I can't do ifconfig
(it is not showing any interfaces besides lo
) or grep eth in /var/log/*
. Is there a way I can find out the mac address from within my system without looking at the hardware?
3 Answers
Just try (ifconfig does not display interfaces which are down otherwise)
ifconfig -a
of
ip address show
install lshw in your system first. then sudo lshw and examine the output. look for the network sections. mac address is called serial: in the output. or you can look for Ethernet. the nics may not be called ethX (logical name) depending on your distribution, however.
The proper way to find the MAC of your devices is to use the ip(8)
command. They'll show up regardless its current configuration status.
# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DORMANT qlen 1000
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
4: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
5: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
As @MadHatter noted in a comment, the required modules for the device must be present and loaded in the kernel.
modprobe
, then it'll show up inifconfig
output.-a
Option is what I was looking for