0

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]
Version=1.0
Name=Get Hardware Address
Comment=n/a
Exec=hwadd
Terminal=false
Type=Application
Categories=Utility;Application;

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?

Keenan
  • 73

2 Answers2

0

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 00: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 01: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 01:55
  • why do you need a MAC to ssh??? – Mark Stewart Feb 11 '20 at 02:17
  • @Keenan If you know both IP addresses, the MAC address is irrelevant. – Lawrence Feb 11 '20 at 02:49
  • I'm under the impression that when I set the static ip that it needs a hardware address to be linked to. Pardon me but I'm a network noob. – Keenan Feb 11 '20 at 05:44
0

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: 192.168.1.46 --- 0xa   Internet Address      Physical Address      Type
  169.254.7.252         a8-54-b2-90-fa-65     dynamic
  192.168.1.1           04-d4-c4-63-46-74     dynamic
  192.168.1.18          74-40-bb-b8-53-6f     dynamic
  192.168.1.26          6c-40-08-a4-86-e0     dynamic
  192.168.1.32          c0-f8-da-80-11-69     dynamic
  192.168.1.49          00-d0-2d-49-a9-e1     dynamic
  192.168.1.55          c0-56-e3-a0-ea-27     dynamic
  192.168.1.56          c4-2f-90-d4-25-1b     dynamic
  192.168.1.57          44-47-cc-89-19-92     dynamic
  192.168.1.59          ec-71-db-b7-4c-bd     dynamic
  192.168.1.66          4c-1b-86-ee-f6-bd     dynamic
  192.168.1.81          fc-03-9f-50-df-32     dynamic
  192.168.1.103         a8-54-b2-90-fa-65     dynamic
  192.168.1.109         a8-47-4a-77-c0-c1     dynamic
  192.168.1.115         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 01: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. – Mark Stewart Feb 11 '20 at 01: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 02:02
  • Since it is there just put the monitor on it for a few. – Mark Stewart Feb 11 '20 at 02: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 05:52