You are not logged in.

#1 2023-05-23 11:25:54

fjb59
Member
Registered: 2023-05-23
Posts: 2

run script when device with specific mac address is plugged in

Hello each. How do i set the system up on arch so that when i plg a device with a specifix mac address into ethernet socket, the system runs a script. on other distros i'd probably use ifup but what would i do on arch?

Offline

#2 2023-05-23 12:37:01

seth
Member
Registered: 2012-09-03
Posts: 50,008

Re: run script when device with specific mac address is plugged in

"ip link set <nic> up", but that has nothing to do w/ "plug a device with a specific mac address into ethernet socket"

What does that even mean? What's the "ethernet socket" here? The RJ45 jack?
And how do you plug a "device" there? What kind of "device"? It's for cables.

Are you looking for ifplugd?

You can detect the MAC of an IP w/ arping or scan for all MACs in the local network w/ "arp-scan --localnet", but you need to be in a network segment for this.

This very much seems to be an https://en.wikipedia.org/wiki/XY_problem
What do yo uactually want to achieve here?

Online

#3 2023-05-24 06:37:24

fjb59
Member
Registered: 2023-05-23
Posts: 2

Re: run script when device with specific mac address is plugged in

seth wrote:

"ip link set <nic> up", but that has nothing to do w/ "plug a device with a specific mac address into ethernet socket"

What does that even mean? What's the "ethernet socket" here? The RJ45 jack?

yeah that's the one.

And how do you plug a "device" there? What kind of "device"? It's for cables.

specifically  a cisco phone or a laptop. both have specifici mac addresses attached to their nic.

Are you looking for ifplugd?

I'll check that one out

You can detect the MAC of an IP w/ arping or scan for all MACs in the local network w/ "arp-scan --localnet", but you need to be in a network segment for this.

indeed, but as you know, mac addresses are layer 2 and in itself does not need to be in a network. i notice when monitoring journal and i plug a device in, it reports the mac address of the device plugged

This very much seems to be an https://en.wikipedia.org/wiki/XY_problem
What do yo uactually want to achieve here?

i'll give you the idea is psudo code

on device plugged in to ethernet:
           if macaddress = "aabbccdd" then
                start dnsmasq with one cofiguration
           else if macaddress = ''ddeeffaabb' then
                start dnsmasq with another configurarion
            else
                start dnsmasq with default configurarion

this isn;t limited to dnsmaq btw or i'd do it all with dnsmasq which as you know is very flexible.

Offline

#4 2023-05-24 08:00:06

seth
Member
Registered: 2012-09-03
Posts: 50,008

Re: run script when device with specific mac address is plugged in

i notice when monitoring journal and i plug a device in, it reports the mac address of the device plugged

I assume you're talking about a physically attached devices, probalby some usb dongle?
You still have to ask the link partner for its MAC and that requires a pre-config to know where to send the packages (notably which local NIC)

i'll give you the idea is psudo code

If you're using dhcpcd, it has a config for arping and then discriminate the profile based on the MAC of the link partner.
https://man.archlinux.org/man/core/dhcp … .conf.5.en

But in general you'd do that after obtaining a lease so you can arping / arp-scan from any hook your network manager provides and act on the return.

Online

Board footer

Powered by FluxBB