[Solved] Disconnect existing connection at a given time

I have an IP-based phone adapter but I get a lot of annoying robocalls and recently this one scam has been calling in the middle of the night. To cut to the chase, I want to disconnect the adapter and keep it disconnected during a given time period each night.

I found the following page under "parental controls" which should allow me to keep the adapter from reconnecting during the night:

The page mentions breaking existing connections, but it does not actually give the suggestion:

The stop time will stop kids from creating a new connection e.g. to browse one more page on Wikipedia. It will not kick out your kids if they have an existing connection e.g. in an Android game app. To enforce the stop time, you need something extra. Consider the script below, starting with cat.

But there's nothing I can see in the script that seems to do this (and nothing with a cat command). Can anybody help with this?


You may want to break connections using conntrack command.


/usr/sbin/conntrack --delete -s ${ip}
/usr/sbin/conntrack --delete -d ${ip}
/usr/sbin/conntrack --delete -q ${ip}
/usr/sbin/conntrack --delete -r ${ip}
/usr/sbin/conntrack --delete -g ${ip}
/usr/sbin/conntrack --delete -n ${ip}

where ${ip} is the IP of your adapter.

Execute above commands may be a minute after the time based firewall rules kick in.


ifdown and ifup should make all connections "new", but it might kill the parental rules applied in the process.

Trial and error.

1 Like

@codemarauder, @frollic - Thank you guys! I ended up going with the conntrack suggestion because there are often other connections that I would like to not disrupt unnecessarily.

Thanks again!

1 Like

If your problem is solved, please consider marking this topic as [Solved]. See How to mark a topic as [Solved] for a short how-to.

I'm going to chime in with a question since I have the same problem, is there a way to automate the use of the conntrack command?

Cron should work...

1 Like

@jc1685 - if you're not familiar with cron, send me a DM and I'll show you what I did.

1 Like

One thing that I did find that is worth repeating here. I want the phone adapter to be disconnected between 22:00 to 08:00. I ended up needing to make two rules. One that runs from 22:00-00:00 and another that runs from 00:00-08:00. Otherwise I found that the adapter reconnects when the day changes.

I will get an account on the main site so I can update the wiki page with what I have learned.

The problem with the connections is explained and solved already:

:!: Once the time is reached, the default rule order prevents closing already established connections. The rules should be reordered to resolve the issue.

Did you try that and it didn't work or you missed it and edited the wiki?


@trendy, I was about to ask you how to reorder them, then I realized that it's a hyperlink and followed it. OK, I will give that a shot this evening or the next and report back.

@trendy, thank you for pointing that out. The reordering link works for me. I removed my comments from the wiki and added a second link to this page to replace the mysterious:

Consider the script below, starting with cat.

1 Like

I still see your changes from 2nd of January to be the current revision of the page. @vgaetera, since you are actively maintaining the wikipage you may want to take a look :slight_smile:

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.