I have searched through entire internet and none of the solutions I found worked, so probably its time to ask for help.
I have Raspberry Pi 3B+ and i want it to work (for privacy reasons):
- with VPN,
- with disabled ipv6,
- spoofing MAC address on startup, ideally to a random address.
I manage Pi headless through ssh and vnc server, which may be a problem, because I don't see what is happening after resetting networking.
Pi have connection to internet through router on eth0 port. My router is set to ipv4 and have ipv6 disabled, I set it to give IPs in range 192.168.0.100 to 192.168.0.199, router's address is 192.168.0.1.
- After clean instal of Raspbian Stretch i connect through ssh and set basic config, update & upgrade all packages.
Then I set static ip by adding lines to dhcpcd.conf (geany /etc/dhcpcd.conf):
- interface eth0
- noipv6
- static ip_address=192.168.0.110/24
- static routers=192.168.0.1
- static domain_name_servers=192.168.0.1
After that, I disable ipv6 by editing ipv6.conf (geany /etc/modprobe.d/ipv6.conf):
- uncomment line: alias ipv6 off
- add line: blacklist ipv6
I also add comments to lines that contain ipv6 at hosts (geany /etc/hosts) and add line "AddressFamily inet" to sshd_config (geany /etc/ssh/sshd_config).
Next, I install openvpn (apt-get install openvpn resolvconf network-manager-openvpn), add my configuration file and set openvpn to start on boot by uncommenting AUTOSTART="all" (nano /etc/default/openvpn).
At this point i have perfectly working Pi with VPN and disabled ipv6. The problem begins when I want to change/spoof MAC address.
I tried to use macchanger and different commands (like "hw ether"), but nothing worked and I got stuck here. There are no internet connection on Pi and it is not possible to reach him through local network.
I took my Pi to a friend (since i dont have monitor) to check what is going on after i change MAC address.
It turned out that after changing MAC system does not get new IP from router and sometimes set Local-Link IP (169.254.x.x) or wierd (10.0.x.x), but sometimes nothing happen at all and stay without any IP address.
I tried to manage changing MAC address without static IP, but it was the same - Local-Link IP or nothing at all.
Those are examples of commands I tried:
- ifconfig eth0 down; macchanger -r eth0; ifconfig eth0 up
- ifconfig eth0 down; ifconfig eth0 hw ether [pasted random mac]; ifconfig eth0 up
Also I was trying to stop network services before and restart them after spoofing MAC, but non of them helped:
- service network-manager stop/start/restart
- service networking stop/start/restart
- systemctl restart dhcpcd
I also tried changing default route (found it in one of tutorials while doing research) but it also have not worked.
- route add default gw 192.168.0.1
After reboot everything is back to the state from step 5 and Pi works normally with original MAC address. Anyone have idea how to solve this and set spoofing MAC address?
edit 1:
I found out that problem only exist on eth0 port (which I want to use because it is faster). When I change MAC address on Pi's wlan0 port, it normally get new IP from router after I reset DHCP. I use this command to successfully change MAC on wlan0:
- ifconfig wlan0 down && macchanger -r wlan0; ifconfig wlan0 up; systemctl restart dhcpcd
Any ideas why this work on wlan0 but when I do the same sequence for eth0 it does not get new IP?
00:00:00:00:00:aa
Are you sure this is the correct/valid address?sudo systemctl restart dhcpcd
should restart networking, but I suggest you reboot. What do you mean by "how to make it work?" - What IT?169.254.x.x
is NOT a static address it is a Link-local address Why on earth do you want to change MAC?service
may still exist for backward compatibility but probably not forever -- you should stop using it and instead, as Milliways points out, use systemd commands.