I'm trying to get the Ethernet mac address of a computer that has no display by using a desktop start up file that calls ip.

This is what I have to work with:

  1. A laptop

  2. Mini-computer with no display: MSI Cubi -231XTW 5th gen Intel® Core™ i7 i7-5500U Mini PC

  3. Two solid state drives with Ubuntu 19.1 installed and upgraded on them (I installed Ubuntu on them using the laptop).

So far I created: /home/max/.config/autostart/hwadd.desktop:

[Desktop Entry]
Name=Get Hardware Address

I have this script in /usr/bin/hwadd:

cd /home/max/
ip a > /home/max/ipaddress

When I boot my laptop with the hard drive that has this .desktop start up script it works as expected-I get a file with the hardware address info in my home folder.

But, when I place the hard drive into the mini-computer with no display and boot it, let it run for 5 minutes, then power it down, take out drive, mount the hard drive for reading, I find no file that contains the ip output I'm looking for.

Any ideas on how I can get this to work?

  • Does autostart even work in a headless system? AFAIK, it does not.
    – fpmurphy
    Feb 11 '20 at 4:21
  • @fpmurphy I have my user set to auto log in. Does this mean that this user will not log in if the computer is headless?
    – Keenan
    Feb 11 '20 at 17:42

If you have access to your router's control panel or DHCP table, you can find a list of clients that have a local IP assigned to them, along with their mac address.

More in line with your thinking, I don't think autostart works in a headless environment. the scripts in autostart are called by your window manager (or display environment, I don't quite remember which it is).

See also: How to run scripts on headless startup?

  • I do not have access to the router. I use public wifi. I have a Ethernet cable to plug them together but this is why I need the address so I can create the profile so I can configure the headless with the laptop.
    – Keenan
    Feb 10 '20 at 23:45
  • I followed the above link for headless startup. I tried the rc.local solution. On Ubuntu 19.1 I had to enable through systemctl. Got it to work on the laptop, but when I plugged that hard drive in on the mini-computer and started it up it failed somehow.
    – Keenan
    Feb 11 '20 at 0:51
  • 1
    @Keenan If you have an ethernet cable, why not just set up static IP addresses on the ethernet interfaces, then simply SSH into the device?
    – Lawrence
    Feb 11 '20 at 1:36
  • @Lawrence That's what I'm trying to do, but I need the hardware address of the Ethernet on the headless computer first. AFIK.
    – Keenan
    Feb 11 '20 at 1:55
  • why do you need a MAC to ssh??? Feb 11 '20 at 2:17

From the command line on the laptop run

#> arp -a 

This will inspect the arp tables on the switch. Laptop has to be on the same subnet and switch to see it from your laptop. should get something back like

Interface: --- 0xa   Internet Address      Physical Address      Type         a8-54-b2-90-fa-65     dynamic           04-d4-c4-63-46-74     dynamic          74-40-bb-b8-53-6f     dynamic          6c-40-08-a4-86-e0     dynamic          c0-f8-da-80-11-69     dynamic          00-d0-2d-49-a9-e1     dynamic          c0-56-e3-a0-ea-27     dynamic          c4-2f-90-d4-25-1b     dynamic          44-47-cc-89-19-92     dynamic          ec-71-db-b7-4c-bd     dynamic          4c-1b-86-ee-f6-bd     dynamic          fc-03-9f-50-df-32     dynamic         a8-54-b2-90-fa-65     dynamic         a8-47-4a-77-c0-c1     dynamic         ec-71-db-aa-2b-90     dynamic

Now you have the address and MAC, Just have to figure out which one goes to what. netstat may help with that if you don't already know the IP.

Also newer systems will have ip neigh for modern arp -a command

Good luck.

  • I put both hard drives in. I connected an Ethernet cable between them. I booted them both. I tried the command. I get nothing. If I plug in my wifi adapter on the laptop, I get one line.
    – Keenan
    Feb 11 '20 at 1:03
  • Probably one or both have a DHCP IP address. If you have them back to back (no switch) like that they will not get an IP Address (unless one of them is a server configured to serve ip leases). If they have static address you should already know it. Also I am not sure the arp command will work if not connected to a switch? I have never tried to arp for another computers address without a switch as they are both there in front of me. Feb 11 '20 at 1:46
  • I have one with openssh-server installed. I verified that the service is starting up on the laptop. I'm booting the headless with that hard drive. I'm now wondering if there is a problem with the headless one booting like secure boot or something.
    – Keenan
    Feb 11 '20 at 2:02
  • Since it is there just put the monitor on it for a few. Feb 11 '20 at 2:16
  • The monitor I have is a Asus ZenScreen USB-C with USB-A adapter. It requires a driver directlink drive to be installed and possibly tweeked to get to work. So I can't just use it on the headless. My goal was to connect it to the headless, ssh from laptop to headless and configure it to get it working. I installed the driver already and got the ZenScreen to work with the laptop, but that hard drive plugged into the headless didn't turn on the display.
    – Keenan
    Feb 11 '20 at 5:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.