nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

Blocking ports in linux

This is a discussion on Blocking ports in linux within the Linux software forums, part of the Linux Getting Started category; How do i block ports in linux as i do not want to give access to everyone... How do i ...

Register free or login to your existing account and remove all advertisements.


Go Back   nixCraft Linux Forum > Linux Getting Started > Linux software

Linux answers from nixCraft.


Linux software General questions and discussion about Redhat/Fedora Core/Cent OS, Debian and Ubuntu Linux related to softwares should go here.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-09-2006, 04:35 AM
raj's Avatar
raj raj is offline
Senior Member
User
 
Join Date: Jun 2005
Location: Hyderabad
OS: Fedora, Debian Linux
Posts: 307
Thanks: 42
Thanked 8 Times in 8 Posts
Rep Power: 6
raj will become famous soon enough raj will become famous soon enough
Default Blocking ports in linux

How do i block ports in linux as i do not want to give access to everyone...
How do i block a single port ?
How do i block a single port for specfic IP?

thanks in advnace
Reply With Quote
  #2 (permalink)  
Old 07-10-2006, 07:31 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,674
Thanks: 11
Thanked 240 Times in 180 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

The easiest way to block particular TCP port in Linux is use iptables rule as follows:
Code:
iptables -A INPUT -p tcp --destination-port PORT-NUBMER -j DROP
For example block port 22 for everyone:
Code:
iptables -A INPUT -p tcp --destination-port 22 -j DROP
Now let us say you want block port 22 for everyone except for IP 202.65.11.10
Code:
iptables -A INPUT -p tcp --destination-port 22 -s \! 202.65.11.10 -j DROP
To block UDP ports use --tcp udp option:
Code:
iptables -A INPUT -p udp --destination-port PORT-NUBMER -j DROP
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
blocking streaming zafar466 CentOS / RHEL / Fedora 0 04-12-2008 03:37 AM
How to drop all ports except mentioned in script deltamails Networking, Firewalls and Security 2 05-15-2007 12:54 PM
Open Mail Ports B!n@ry Linux software 31 12-29-2006 02:19 AM
iptables rules blocking ftp hammooda Linux software 7 09-23-2006 04:24 PM
Linux : How do I verify which ports are listening? sweta Getting started tutorials 0 07-30-2006 10:02 PM


All times are GMT +5.5. The time now is 01:42 AM.


Powered by vBulletin® Version 3.8.4 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2009 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38