LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 05-08-2010, 08:10 AM   #1
duzap
LQ Newbie
 
Registered: Jun 2008
Posts: 25

Rep: Reputation: 15
Blocking a specific IP address from server


I would like to COMPLETELY block a specific IP address using iptables.
I found this one:
Code:
iptables -A INPUT -p tcp -s xxx.xxx.xxx.xxx -j REJECT --reject-with tcp-reset
Will this work?
How do I undo the changes later?
 
Old 05-08-2010, 08:45 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
First: I'd suggest "DROP" rather than "REJECT". With "REJECT" you're sending a response back whereas with "DROP" you're simply discarding the traffic so it has less impact on your system and also doesn't tell the sender what is happening.

Secondly: Depending on how iptables is configured for your distro there might additional considerations.
-You might have different chains/rulesets so might need to specify which one to put the new rule in.
-You might have rules at the end of your chain/ruleset that is a catchall that should stay at the end. In that case you'd want to use -I to insert rather than -A to append.

Run "iptables -L" to see what your current configuration is. (Make sure iptables is actually running - if you see only 3 rules then it may be a sign it isn't.)

Also be sure to use iptables-save to save your rules to whatever iptables copy is used at reboot so the rules get reloaded at boot.
 
1 members found this post helpful.
Old 05-08-2010, 12:08 PM   #3
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Also, get rid of the TCP match:
Code:
iptables -I INPUT -s xxx.xxx.xxx.xxx -j DROP
To delete the rule just use -D instead of -I, like:
Code:
iptables -D INPUT -s xxx.xxx.xxx.xxx -j DROP
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Blocking dhcpd address lease for specific MAC address kulman Linux - Server 8 03-30-2013 01:51 PM
Blocking mail to specific domain from specific user orko Linux - Server 0 03-26-2009 02:18 PM
About blocking specific email address alucard001 Linux - Server 1 12-17-2006 07:48 AM
Question: Request a specific IP address from a DHCP server? haertig Linux - Software 2 09-13-2006 04:32 PM
packets being dropped by server from specific ip address alex_fittyfives Linux - Networking 1 08-04-2004 08:14 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 12:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration