I know about tcpdrop
which is in base distribution. But this tool requires port numbers to be specified. Is there any tool to drop connections by IP?
Freebsd – How to drop all connections to a given host under FreeBSD
connectionsfreebsdtcp
Related Topic
- FreeBSD Ports: How to see all dependencies for a port, and all subdependencies for those dependencies
- How to check how many connections are open currently on a specific TCP port
- Linux – How to find the total number of TCP connections for a given port and period of time by IP
- FreeBSD Established Connections Maxing out at 300
Best Answer
Well, you could use some unix tools to give you the proper tcpdrop syntax and just run it through xargs in your own script I think. Here's an ugly example, there are probably prettier ways:
This uses awk to peel out the two IP/port pairs and then glue them together with a dot so you can use another awk to just spit out the desired dotted quad space port syntax.
There's probably a slicker all-in-one regex that's more clear. $IPADDR is the ip you want to drop.