Skip to content

Instantly share code, notes, and snippets.

@mulderu
Created August 1, 2016 01:32
Show Gist options
  • Save mulderu/52505a4fa5c1c28acb2ae11dbf8dc015 to your computer and use it in GitHub Desktop.
Save mulderu/52505a4fa5c1c28acb2ae11dbf8dc015 to your computer and use it in GitHub Desktop.
-- IP Block / UNBlock by iptables in centos
root@localhost log]# iptables -I INPUT -s 116.31.116.6 -j DROP
[root@localhost log]#
[root@localhost log]# !tail
tail -f secure
Aug 1 20:34:55 localhost sshd[16720]: pam_succeed_if(sshd:auth): requirement "uid >= 1000" not met by user "root"
Aug 1 20:34:57 localhost sshd[16720]: Failed password for root from 116.31.116.6 port 61677 ssh2
Aug 1 20:34:58 localhost unix_chkpwd[16723]: password check failed for user (root)
Aug 1 20:34:58 localhost sshd[16720]: pam_succeed_if(sshd:auth): requirement "uid >= 1000" not met by user "root"
Aug 1 20:34:59 localhost sshd[16720]: Failed password for root from 116.31.116.6 port 61677 ssh2
Aug 1 20:34:59 localhost unix_chkpwd[16724]: password check failed for user (root)
Aug 1 20:34:59 localhost sshd[16720]: pam_succeed_if(sshd:auth): requirement "uid >= 1000" not met by user "root"
^C
[root@localhost log]# iptables -D INPUT -s 192.168.1.100 -j DROP
[root@localhost log]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
DROP all -- 116.31.116.6 anywhere
ACCEPT udp -- anywhere anywhere udp dpt:domain
ACCEPT tcp -- anywhere anywhere tcp dpt:domain
ACCEPT udp -- anywhere anywhere udp dpt:bootps
ACCEPT tcp -- anywhere anywhere tcp dpt:bootps
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
ACCEPT all -- anywhere anywhere
INPUT_direct all -- anywhere anywhere
INPUT_ZONES_SOURCE all -- anywhere anywhere
INPUT_ZONES all -- anywhere anywhere
ACCEPT icmp -- anywhere anywhere
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
DROP all -- 116.31.116.6 anywhere
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment