Results 1 to 2 of 2

Thread: Blocking ports in linux

  1. #1
    Senior Member raj's Avatar
    Join Date
    Jun 2005
    Location
    Hyderabad
    Posts
    566
    Thanks
    57
    Thanked 41 Times in 38 Posts
    Rep Power
    14

    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

  2. #2
    Never say die nixcraft's Avatar
    Join Date
    Jan 2005
    Location
    BIOS
    Posts
    4,513
    Thanks
    17
    Thanked 807 Times in 511 Posts
    Rep Power
    10

    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
    All [Solved] threads are closed by mods / admin to avoid spam issues. See Howto mark a thread as [Solved]


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. blocking streaming
    By zafar466 in forum CentOS / RHEL / Fedora
    Replies: 0
    Last Post: 12th April 2008, 03:37 AM
  2. How to drop all ports except mentioned in script
    By deltamails in forum Networking, Firewalls and Security
    Replies: 2
    Last Post: 15th May 2007, 12:54 PM
  3. Open Mail Ports
    By B!n@ry in forum Linux software
    Replies: 31
    Last Post: 29th December 2006, 02:19 AM
  4. iptables rules blocking ftp
    By hammooda in forum Linux software
    Replies: 7
    Last Post: 23rd September 2006, 04:24 PM
  5. Linux : How do I verify which ports are listening?
    By sweta in forum Getting started tutorials
    Replies: 0
    Last Post: 30th July 2006, 10:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •