LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-17-2008, 12:43 PM   #1
tbeehler
Member
 
Registered: Aug 2003
Location: Washington State, USA
Distribution: Mainly RH 9.0
Posts: 227

Rep: Reputation: 30
ban external access to specific services with iptables?


Hello all,

I am getting attempts on a couple of services that run on my server, and these services don't need to be accessed from the outside world.

So, I have tried the following:

iptables -A INPUT -s ! 192.168.1.0/24 -p tcp --dport 80 -j DROP

to no avail. How do I get iptables to ban access from the outside world to these services, but allow internal access?

I imagine I'm off by just a bit in my above line, but any help would be appreciated! Thanks in advance!
 
Old 07-17-2008, 02:29 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913Reputation: 913
Need more input. What interfaces has the machine got, are
ports being forwarded to it or is it on the perimeter and
dual homed?
 
Old 07-17-2008, 02:44 PM   #3
tbeehler
Member
 
Registered: Aug 2003
Location: Washington State, USA
Distribution: Mainly RH 9.0
Posts: 227

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by Tinkster View Post
Need more input. What interfaces has the machine got, are
ports being forwarded to it or is it on the perimeter and
dual homed?
Sorry about that. There's two interfaces eth0 (internal) and eth1 (external).

There's no port forwarding.
 
Old 07-17-2008, 04:49 PM   #4
david1941
Member
 
Registered: May 2005
Location: St. Louis, MO
Distribution: CentOS7
Posts: 267

Rep: Reputation: 58
Since you want the external interface to drop port 80 and you have existing rules (Maybe not - try /sbin/iptables -L to see the current rules) Use an insert to put your new rule first.

iptables -I INPUT -i eth1 -p tcp --dport 80 -j DROP

Dave

Oops -- use -i eth1 for your external interface

Last edited by david1941; 07-17-2008 at 04:52 PM.
 
Old 07-17-2008, 05:38 PM   #5
tbeehler
Member
 
Registered: Aug 2003
Location: Washington State, USA
Distribution: Mainly RH 9.0
Posts: 227

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by david1941 View Post
Since you want the external interface to drop port 80 and you have existing rules (Maybe not - try /sbin/iptables -L to see the current rules) Use an insert to put your new rule first.

iptables -I INPUT -i eth1 -p tcp --dport 80 -j DROP

Dave

Oops -- use -i eth1 for your external interface
That worked perfectly, thanks! I knew it was something simple, just couldn't get my head around it. Sometimes we just have those days.

Thanks again!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How allow external access to local services (smtp-sendmail-syslog) Marv Bon *BSD 3 08-24-2007 12:45 PM
Iptables, ban IP, how? cylarz Linux - Security 3 04-22-2006 02:09 PM
allow access from external using iptables cccc Linux - Security 4 02-28-2006 09:05 PM
iptables ban rule hypton Linux - Networking 1 03-09-2004 11:42 PM
using iptables to ban a subnet? Sm0k3 Linux - Networking 4 01-24-2004 04:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:18 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration