You are not logged in.

#1 2012-08-16 19:56:59

segrived
Member
From: UA
Registered: 2012-05-11
Posts: 7
Website

MAC Spoofing and systemd

What is the best way to create MAC spoofing (MAC address change) on system boot via systemd?
It would be good if i could use it with any service (netcfg, dhcp, networkmanager).
I used to do it with hooks in /etc/rc.d (https://wiki.archlinux.org/index.php/MA … AC_On_Boot). It works fine with any daemon (network, net-pofiles and networkmanager).

For example, following .service-file works (based on dhcp@.service) but sometimes fails with "ip: Interface 'eth0' not found"

[Unit]
Description=dhcpcd on %I
Wants=network.target
Before=network.target

[Service]
Type=forking
PIDFile=/run/dhcpcd-%I.pid
ExecStartPre=/usr/sbin/ip link set dev %I address XX:XX:XX:XX:XX:XX
ExecStart=/sbin/dhcpcd -A -q -w %I
ExecStop=/sbin/dhcpcd -k %I

[Install]
Alias=multi-user.target.wants/dhcpcd@eth0.service

By using

After=sys-devices-pci0000:00-0000:00:0a.0-net-eth0.device

in Unit section it is still very unstable.

Any solutions?

Sorry my english

Offline

#2 2012-08-16 21:54:25

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: MAC Spoofing and systemd

I use netcfg (PRE_UP) for mac spoofing. See wiki for more details.


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#3 2012-08-17 19:31:42

segrived
Member
From: UA
Registered: 2012-05-11
Posts: 7
Website

Re: MAC Spoofing and systemd

net-auto-wired.service doesn't work for me (but with sysvinit (as daemon) does work):

Aug 17 15:41:15 segrived-nb ifplugd[169]: Executing '/etc/ifplugd/netcfg.action eth0 up'.
Aug 17 15:41:16 segrived-nb ifplugd[169]: client: up
Aug 17 15:41:16 segrived-nb ifplugd[169]: Program execution failed, return value is 1

netcfg@.service works, but have some issues, if i start system with unplugged cable:
* interface not up after cable connect
* sometimes it break systemd output (login prompt without clearing the screen)

Also, this solution works only with netcfg, and i want it to work with networkmanager

Previously i used this hook and this code worked with no problems.

# Configuration file
. /etc/conf.d/macspoof

hook_macspoof() {
    stat_busy "Spoofing Media Access Control (MAC)"
    ip link set dev ${INTERFACE} address ${MAC}
    stat_done
}

add_hook sysinit_end hook_macspoof

Last edited by segrived (2012-08-17 19:31:55)

Offline

#4 2012-08-17 20:17:55

progandy
Member
Registered: 2012-05-17
Posts: 5,320

Re: MAC Spoofing and systemd

If you are using NetworkManager, then the correct place to change the mac would be the setting in the connection profile.


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

Board footer

Powered by FluxBB