While thinking about the Problem that is MATLAB once more, the real solution to starting matlab offline became obvious: Only spoof the Mac address for MATLAB itself without influencing other software running on the same machine.
In order to make this work we will have to change the outcome of the ioctrl syscall, which MATLAB uses to determine the MAC Address of the HW adapter. Fortunaly, that was already done here, which will work for matlab just fine.
If you are using Arch Linux then rejoice, for I packaged this little library in the AUR (named libmacspoof). The Package will install libmacspoof.so.1.0.1 under /usr/lib, which is the assumption below. If you compiled the library yourself, you will have to change the path to it in the two lines of script.
open the script that is the matlab command with
sudo nano $(which matlab)
and change the first line from
#!/bin/sh
to
#!/bin/sh
export MAC_ADDRESS=aa:bb:cc:00:11:22
export LD_PRELOAD=/usr/lib/libmacspoof.so.1.0.1
The MAC_address can be found by typing ip link and looking at the results for the WLAN-Adapter (marked in red below)
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether aa:bb:cc:00:11:22 brd ff:ff:ff:ff:ff:ff
3: wlp2s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DORMANT group default qlen 1000
link/ether dd:ee:ff:44:55:66 brd ff:ff:ff:ff:ff:ff
with this simple addtion, matlab should start without problems (even when not connected to any network!)
In order to make this work we will have to change the outcome of the ioctrl syscall, which MATLAB uses to determine the MAC Address of the HW adapter. Fortunaly, that was already done here, which will work for matlab just fine.
If you are using Arch Linux then rejoice, for I packaged this little library in the AUR (named libmacspoof). The Package will install libmacspoof.so.1.0.1 under /usr/lib, which is the assumption below. If you compiled the library yourself, you will have to change the path to it in the two lines of script.
Making matlab use the new ioctl
That part is charmingly simple:open the script that is the matlab command with
sudo nano $(which matlab)
and change the first line from
#!/bin/sh
to
#!/bin/sh
export MAC_ADDRESS=aa:bb:cc:00:11:22
export LD_PRELOAD=/usr/lib/libmacspoof.so.1.0.1
The MAC_address can be found by typing ip link and looking at the results for the WLAN-Adapter (marked in red below)
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether aa:bb:cc:00:11:22 brd ff:ff:ff:ff:ff:ff
3: wlp2s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN mode DORMANT group default qlen 1000
link/ether dd:ee:ff:44:55:66 brd ff:ff:ff:ff:ff:ff
with this simple addtion, matlab should start without problems (even when not connected to any network!)