Skip to content

Instantly share code, notes, and snippets.

@craig-m
Last active November 27, 2020 23:38
Show Gist options
  • Select an option

  • Save craig-m/8f8f7af2cd9a5311624c344c9996636a to your computer and use it in GitHub Desktop.

Select an option

Save craig-m/8f8f7af2cd9a5311624c344c9996636a to your computer and use it in GitHub Desktop.
methods on linux to block a host/network
# some methods on *nix systems to block a host/network
# set a bogus arp address (for IPs in local subnet only)
arp -s 192.168.1.10 00:00:00:00:00:01
# blackhole this subnet
ip route add blackhole 192.168.2.0/24
# blackhole a host
ip route add blackhole 192.168.1.10/32
# iptables firewall block a host
iptables -I INPUT -s 192.168.1.10 -j DROP
iptables -I OUTPUT -d 192.168.1.10 -j DROP
# if you use UFW to manage iptables
ufw deny from 192.168.1.10 to any
# Add line below to /etc/hosts.deny
# only works if server daemons are configured with tcpwrappers - more obsolete these days
ALL: 192.168.1.10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment