Cut Internet temporarily in a device in your LAN

Ok. Then, maybe, you could open a terminal in your PC and try manually the following commands (the idea is to go step by step to check if all the commands are installed before setting up the HA stuff):
Step 1.- nmap is needed so let’s see if this works:

nmap -sP YOUR.IP.ROUTER.ADDRESS/24

Step 2.- same for arp:

arp -an

Step 3.- same for grep:

arp -an | grep YOUR:DEVICE:MAC:ADD:RESS:HERE

Step 4.- same for awk:

arp -an | grep YOUR:DEVICE:MAC:ADD:RESS:HERE | awk '{print $2}'

Step 5.- same for sed:

arp -an | grep YOUR:DEVICE:MAC:ADD:RESS:HERE | awk '{print $2}' | sed 's/[()]//g'

If you run all the steps without errors you should have the IP address of your device when running step 5, and we can join the commands to build the overall script.
If you found errors in a given step you have to find out how to install that command in Windows. I am not able to provide any help here but hopefully others may help.
Good luck!

i get this error while trying above

arp -an | grep 40:f3:08:1a:c1:da
‘grep’ is not recognized as an internal or external command,
operable program or batch file.

installed grep passed the grep command and getting error over here.

C:\Users\Ashfaq>arp -an | grep EC:9B:F3:24:D1

C:\Users\Ashfaq>arp -an | grep EC:9B:F3:24:D1 | awk '{print $2}'
awk: '{print
awk: ^ invalid char ''' in expression

@timseebeckI thank you for your tutorial which is very good explained.

I have followed all the instructions using my pi3 (dietpi raspbian image) as host and my router R7000 with asuswrt. I have issued the command manually to test it “control_internet.sh 2c:0e:3d:68:72:20 on” to disconnect my internet on my phone which is connected through WiFi obviously. Apparently arpspoof if not disconnecting my phone from the internet as I’m still able to surf even with mobile connection (4G) turned off.

root@raspi:/# ps aux | grep arpspoof
root 21243 0.0 0.2 7228 2796 pts/2 S 21:21 0:00 sudo arpspoof -i eth0 -t 192.168.1.4 192.168.1.1
root 21247 0.0 0.1 2500 1408 pts/2 S 21:21 0:00 arpspoof -i eth0 -t 192.168.1.4 192.168.1.1
root 25048 0.0 0.1 4280 1816 pts/2 S+ 21:33 0:00 grep arpspoof

You see above the output that arpspoof is running, so I don’t understand why I’m still connected and surfing on the web

1 Like

Thanks.
I don’t see anything wrong in your setup so I can only suggest to double-check your phone’s MAC address. I would also try to run this command in another terminal:

arp -an | grep 2c:0e:3d:68:72:20

before AND after you run control_internet.sh 2c:0e:3d:68:72:20 on; just to see that the IP that is given to your phone has not changed.
Finally, as my first disclaimer states, I’m just a Google-fu guy with very little knowledge about what is really happening underneath these commands or router’s performance. Sorry :frowning_face:

I’m trying to make a custom component to do it, as i would like to HomeAssistant manage the whole thing. What i’ve done so far: create switches based on IP, pass it to main script array. Get IP address of router and its MAC address. At the moment i’m stucked at getting MAC address of client basically send packet. I know that scapy needs to run as root so i granted privileges to python but still no success. Anybody willing to help me with it? all info in arpspoof.readme

sorted, works like a charm!

1 Like

can you explain how your component works?

Hi gang – love this discussion and the great ideas. Appreciate the inspiration.

I’ve got a (derivative, but hopefully still useful) idea for a component that takes a list of MAC addresses (plus various configuration options) and, for each, automatically creates a group similar to @timseebeck’s (with immediate kill switches, timed switches, usage monitoring, etc.). Idea is to make something that is instantly expandable when a new device-to-manage comes onto the scene.

Fortuitous timing: I’ve been tinkering with this for a while specifically so we didn’t have to buy a Disney Circle.

I’ll chime in when I have more; perhaps we can collectively collaborate on getting this into core.

3 Likes

I used the same technique per @timseebeck opening post ARP spoofing but done in Python with use of scapy library, you can read all this in my repo under arpspoof markdown

It’s not a problem to create a group with custom component and some automation but, everyone’s needs is different regarding automation, so that why i came up with simple idea in creating switches based on list of IPs and you can do whatever you like to do with them :slight_smile: I might try to tweak it to take MAC address too.

1 Like

Creating switches is a great idea. I’m really considering to move to your approach (problem is that I’m a big fan of “if it works, don’t touch it”, and I have to say that my setup is running perfectly for months). So far, I extended the idea up to four devices as next picture shows.

The main drawback for me of your approach is that it is IP-based (instead of MAC-based). My router is not able to give a fixed IP to a device depending on its MAC, although it is true that I could setup static IPs to my children tablets. Anyway, I’ll continue to follow your updates and maybe in a near future I’ll try your component (I’m considering to move to a fresh install of Raspbian Stretch with Python 3.6 in the short term).
Thanks for sharing your work!

I created a special topic for my component so that your approche and related questions are not mixed with mine.

That’s perfect. I tried to edit my first post to include an advice that there is a component for this and a link to your topic but it seems very old posts cannot be edited.

Anyway, I hope everyone reads this last message and go using your approach.
Thanks for sharing!

1 Like

just found a docker image that includes dsniff alpine/arm docker can i add this to hassio then access it. soz for the noobness with docker im only just learning it in depth

Hi, your work gave a idea and i was managed to improve it a bit to work with any kind of device and also use for multiple devices.

Have allok here:

can you make Hassio Add-on ?

1 Like

Thanks. Used this to cut internet on my firetv. you may want to add the following on the command line switch to detect if it is on or not:

 command_state: "ps -ef | grep 'arpspoof -i enp1s0 -t 192.168.0.1 192.168.0.254' | grep -v grep | awk '{print $2}' | wc -l"
 value_template: '{{ value >= "1" }}'

Also a typo on the page: chmod is missing on sudo +s /usr/sbin/arpspoof

Thank you for the code. I use it on start up script to permanently disable the internet access of all my IoT devices (no more phone home)

anyone got this working Hassio?