The officially official Devuan Forum!

You are not logged in.

#1 2020-03-29 02:15:59

VL44K6F0
Member
Registered: 2020-03-29
Posts: 5  

What is going on in /etc/network/if-pre-up.d/ ?

Trying to get mac address spoofing working, but there is mystery/anomaly ruining everything.

random_dec4/5/6 are working perfectly, but 1/2/3 not, giving a 1-2min freeze with "ifup: waiting for lock on /run/network/ifstate.eth0" and DHCP-thing fails also, although at the end mac address gets changed (but still needs networking service restarted for internet access).

Also the script is run twice at boot (sometimes it was even 3 times).
Does variable=$(command) contain hidden characters?

Could someone enlighten me what's wrong?

/etc/network/if-pre-up.d/mac-spoofer

#!/bin/sh
iface=eth0

real_mac=$(ip link show $iface | grep ether | cut -d' ' -f6)
vendor_bits=$(echo $real_mac | cut -d ':' -f 1-3)

random_dec1=$(shuf --input-range=10-99 -n 1)
random_dec2=$(shuf --input-range=10-99 -n 1)
random_dec3=$(shuf --input-range=10-99 -n 1)

random_dec4=10
random_dec5=20
random_dec6=30

echo ""
echo "-----------------"
echo $real_mac
echo $vendor_bits:$random_dec1:$random_dec2:$random_dec3
### OK ---> ### echo $vendor_bits:$random_dec4:$random_dec5:$random_dec6
echo "-----------------"

echo "------------------------------------------"
echo "ip link set $iface address $vendor_bits:$random_dec1:$random_dec2:$random_dec3"
ip link set $iface address $vendor_bits:$random_dec1:$random_dec2:$random_dec3

### OK ---> ### echo "ip link set $iface address $vendor_bits:$random_dec4:$random_dec5:$random_dec6"
### OK ---> ### ip link set $iface address $vendor_bits:$random_dec4:$random_dec5:$random_dec6
echo "------------------------------------------"

Offline

#2 2020-03-29 10:03:57

fsmithred
Administrator
Registered: 2016-11-25
Posts: 1,489  

Re: What is going on in /etc/network/if-pre-up.d/ ?

You're probably running into this issue: https://dev1galaxy.org/viewtopic.php?id=1688
See post #20 for a patch to /etc/init.d/networking or use one of the other fixes in the thread.

Offline

#3 2020-03-29 21:27:28

VL44K6F0
Member
Registered: 2020-03-29
Posts: 5  

Re: What is going on in /etc/network/if-pre-up.d/ ?

Thx. Changing allow-hotplug eth0 to auto eth0 in /etc/network/interfaces kind of solved the problem.

Still wondering why it fails with random generator during the script execution. All test showed that random bits echoed to a file are "good" and read correctly before applying. Yet it fails. But if the random generation is cut off and a identical file with the same "random bits" is put in place and read from, it gives a great success.

Offline

Board footer