Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Blocking a port for ip in my lan and allow it for others

    Hello all,
    I want a situation where i want to restrict one pc in my lan not to browse the internet, to block http, https ports for that computer and allow other ports.

    The lan ip i want to block its ip is, i dont want this ip to access http, https ports but can do other things. I want an iptables script or comman to use to achieve this.

    Thanks your help will be apprieciated

  2. #2
    Linux Guru Lazydog's Avatar
    Join Date
    Jun 2004
    The Keystone State
    Take a look at this TUTORIAL


    The adventure of a life time.

    Linux User #296285
    Get Counted

  3. #3
    Linux Newbie
    Join Date
    Aug 2009
    Mumbai, India

    Assuming you are using iptables on the system on which to want to block outbound access to HTTP and HTTPS

    iptables -I OUTPUT 1 -p tcp -m multiport --dport 80,443 -j DROP
    iptables -I OUTPUT 2 -p tcp -j ACCEPT

    The first rule blocks outbound traffic to port 80,443 while allowing traffic to other ports. If you are using RHEL, Fedora, CentOS you'll need to add the above lines except for the word iptables to the /etc/sysconfig/iptables file for it to be effective on subsequent reboots.

    If you are configuring iptables on a another system through which traffic is routed to the internet, then the above rules change to

    iptables -I FORWARD 1 -s -p tcp -m multiport --dport 80,443 -j DROP
    iptables -I FORWARD 2 -s -p tcp -j ACCEPT

    URL mentioned in the previous post would anyways give you detailed info.

    -- Syd

  4. $spacer_open

Posting Permissions

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