Netplan and spoofed MAC address. Correct ip address or MAC address, never both

Ubuntu 18.04.03 (version using Kernel 5), Sysadmin / Backup using Virtualmin

I’ve run into an issue trying to spoof a MAC address. (My ISP uses MAC address and like that I always get the same IP address.)

Looking on-line, find a lot of tutorials on this subject, but I cannot get any of them work. Below is my 01-netplan.yaml file. With the MAC address set, on reboot I only get the changed MAC address, never gets assigned the IP address. Remove the spoof address and then I get the IP address. But never both together. :frowning: (worth noting that in Werbmin >> Networking >> Network Interfaces gets all messed up when you manually add to the .yaml file, displays settings like macaddress as an interface)

01-netplan.yaml :-

network:
version: 2
renderer: networkd
ethernets:
enp7s0:
match:
macaddress: OL:DA:DD:RE:SS:C9
macaddress: NE:WA:DD:RE:SS:62
dhcp4: true
dhcp6: false
nameservers:
addresses: [127.0.0.1,127.0.0.53]

I found one online that said to set it MAC spoofing in /etc/systemd/network.

00-default.link

[Match]
MACAddress=OL:DA:DD:RE:SS:C9

[Link]
MACAddress=NE:WA:DD:RE:SS:62
NamePolicy=kernel database onboard slot path

But exactly the same thing happens. Edit yaml to have no spoof address, define that file, reboot, and all I have is the changed MAC address, no IP address.

Looking in /run/systemd/network, I have two files. Names and Contents …

10-netplan-enp7s0.network

[Match]
MACAddress=OL:DA:DD:RE:SS:C9

[Network]
DHCP=ipv4
LinkLocalAddressing=ipv6
DNS=127.0.0.1
DNS=127.0.0.53

[DHCP]
RouteMetric=100
UseMTU=true

10-netplan-enp7s0.link

[Match]
MACAddress=OL:DA:DD:RE:SS:C9

[Link]
WakeOnLan=off
MACAddress=NE:WA:DD:RE:SS:62

I was surprised that all the files (internal interface left out of this) have the same priority. So I had 10-netplan-enp7s0.network / 10-netplan-enp7s0.link / 10-netplan-enp5s0.network

Any thoughts would be greatly appreciated.

Kind Regards - Nigel.

ou - man, just reinstall your mac… if you got spoofed - have look on log files - it will tell you everything… but in mean time if your ip is spoofed, just reinstall… - I know, just do it… or otherwise ask that company called ubuntu for solution before you get upset here and give out over reacted reply. - my suggestion for end would be just use debian not *untu crap

lol unborn. That’s the funniest thing I’ve read in a long time. He is not using a MACintosh, His Ip was not spoofed. It a legit question about how IPv6 uses mac address to assign IPs automatically.

To his question, Not sure how to do it either, My ISP automatically assigns me an IPv6(mac based) without anything at all shown in netplan.yaml. I just leave that ip as is and then add additional IPs as needed manually by adding to the [addresses] line (non mac based). Although automatically getting a new mac based IP would be nice. I might look into it more.

Actually the issue has nothing to do IPv6, or getting spoofed.

It’s all IPv4. If I define a new MAC address (following the correct format) then two unexpected things happen.

1/ When you open the Webmin >> Networking >> Network Configuration you have “extra” entries now displayed as “interfaces” called “macaddress” … obviously not correct.

2/ When I reboot the server, using the “ip a” command, I see only the spoofed MAC address, no ip address has been allocated. (Take the macaddress setting out of .yaml and now all OK, but no (obviously) spoofed macaddress)

That’s the problem!

Nigel.

@scotwnw I think I said it somehow shortly or within incompleted words which could sound I was talking about macintosh computer, uhmm actually I was talking about mac address change in my own language - my bad :pray:

What I mean it was this - how to change mac address in correct wording…

…be sure to replace eth0 with the name of the network interface you want to modify and enter the MAC address of your choice:

$ su
$# ifconfig eth0 down
$# ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx
$# ifconfig eth0 up

Note: You’ll have to modify the appropriate configuration file under /etc/network/interfaces.d/ or the /etc/network/interfaces file itself if you want this change to always take effect at boot time. If you don’t, your MAC address will be reset when you restart.

@NigelAves you might try that solution, I hope it was helpful somehow…

EDIT: su = super user or root, in case you are sudoer then use sudo command :wink: