As i was searching for a way to block internet connectivity on my kids mobile devices using Home-Assistant and without having to install application on it’ i came across this 2 articles.
both are good and working, but yet, something was missing. so i decided to take a bit from the first one an combine it with part of the second one and came up with very good solution that allows me to “kill” internet connectivity for multiple devices over the network and also undo it.
Yes, i know that using arp spoofing isn’t the best way of doing it and it makes a lot of noise in my local network but hey, it’s working (as you can see in the video)
in this howto guide i’ll explain how to implement it in few simple steps.
1. Installing arpspoof and setting permissions
So, in order to get this right, the first thing we need to do is to install ArpSpoof which is part of the dsndiff package. in order to do son execute the following command:
Now, in order to allow home-assistant run ArpSpoof using sudo commane, we need to set the right permission. execute the following command to edit the sudoers file:
scroll down to the end of the file and add the following to lines:
exit the editor and save the file using ctrl+x and then “y” to save it.
last, grant Home-Assistant the execute permissions using the following command:
2. Configuring Arpspoof switch in Home-Assistant
So, in order to use Arpspoof we need to know the Router Ip Address, the ip address of the remote device and the Network interface name of the Home-Assistant system.
in order to finde your Router IP address you can run “ipconfig” command in windows command line. the output should look somthing like this:
the line that marked in yellow will show you the ip address of your default gateway (Router). write it down for later use.
Next, let’s find the Network interface name of the Home-Assistant system. in order to do this log on to the Home-Assistant using SSH Terminal and execute “ifconfig”. you should see smoething like this:
in this example you can see that the name of the network interface is “enp1s0”.
now, let’s add a new switch to home assistant. in order to do so add the following lines into you configuration.yaml file under the switch section (be sure to replace the ip addresses and network interface name):
“command_on” will start Arpspoof command and will “kill” the device with the ip address of 192.168.0.1.
“command_off” will send kill command with the exact process id we need to kill.
** using the ps command alongside with grep allows we to kill only the instance of arpspoof we need, and this is what makes it useful and multi device support. **