LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 11:43 AM   #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, 01:29 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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, 01: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, 03: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 03:52 PM.
 
Old 07-17-2008, 04: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



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 11:45 AM
Iptables, ban IP, how? cylarz Linux - Security 3 04-22-2006 01:09 PM
allow access from external using iptables cccc Linux - Security 4 02-28-2006 08:05 PM
iptables ban rule hypton Linux - Networking 1 03-09-2004 10:42 PM
using iptables to ban a subnet? Sm0k3 Linux - Networking 4 01-24-2004 03:25 PM

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

All times are GMT -5. The time now is 12:27 AM.

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