nixCraft Linux Forum

nixCraft

Linux 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 ...


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

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 07-09-2006, 05:35 AM
raj raj is offline
Contributors
User
 
Join Date: Jun 2005
Location: Hyderabad
Posts: 151
Rep Power: 4
raj is on a distinguished road
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
Sponsored Links
  #2 (permalink)  
Old 07-10-2006, 08:31 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Ubuntu
Posts: 1,061
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 | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
Reply

Bookmarks


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 On

Similar Threads

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


All times are GMT +5.5. The time now is 12:20 AM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

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