0

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?

uSlackr
  • 6,412
  • 21
  • 37
Isaac
  • 1,215
  • 3
  • 26
  • 44

3 Answers3

2

Just try (ifconfig does not display interfaces which are down otherwise)

ifconfig -a

of

ip address show
cstamas
  • 6,707
  • 25
  • 42
0

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.

johnshen64
  • 5,865
  • 24
  • 17
0

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.

Avoid the use of ifconfig.

# 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.

dawud
  • 15,096
  • 3
  • 42
  • 61