Find the answer to your Linux question:
Results 1 to 6 of 6
Hi In my new Centos i am not able to add iptable rule. iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128 bash: iptables: ...
  1. #1
    Just Joined!
    Join Date
    Dec 2010
    Posts
    16

    not able to add iptable rule

    Hi
    In my new Centos i am not able to add iptable rule.
    iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128
    bash: iptables: command not found
    I am getting this error. I use this rule to forward ports to squid.

    Thanks and Regards
    Suresh

  2. #2
    Linux Enthusiast meton_magis's Avatar
    Join Date
    Oct 2006
    Location
    arizona
    Posts
    665
    are you running the command as root, or your regular user?
    New to the internet, technical forums, or the hacker / open source community??
    Read this to learn good posting habits http://www.catb.org/~esr/faqs/smart-questions.html

    RHCE for RHEL version 5
    RHCT for RHEL version 4

  3. #3
    Just Joined!
    Join Date
    Dec 2010
    Posts
    16
    I am running as root only. I tried installing ubuntu in another machine its working fine and i can add rules. but in centos i am not able to add these rules. Mine is centos 5.5, RHEL version 5

  4. #4
    Linux Guru Lazydog's Avatar
    Join Date
    Jun 2004
    Location
    The Keystone State
    Posts
    2,281
    You say you are root when doing this. Did you log in as root, su - or sudo for root?

    OK, try the following. It looks like the file is not in your path.

    Code:
    locate iptables
    This should tell you where iptables is located on your system.

    Code:
    $PATH
    This will give you your current path. Look at it and ensure that the above output path is in your current path.

    If it is not you then have 2 choices. Either add it to your PATH statement (google for how to do this) or run the commend with FQP.

    Regards
    Robert

    Linux
    The adventure of a life time.

    Linux User #296285
    Get Counted

  5. #5
    Just Joined!
    Join Date
    Feb 2008
    Location
    Mauritius
    Posts
    8
    Hi bro i would say edit this file
    /etc/sysconfig/iptables and add the line
    -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128

    this line should be before commit line ok

  6. #6
    Linux Enthusiast meton_magis's Avatar
    Join Date
    Oct 2006
    Location
    arizona
    Posts
    665
    Quote Originally Posted by peacengell View Post
    Hi bro i would say edit this file
    /etc/sysconfig/iptables and add the line
    -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3128

    this line should be before commit line ok
    That would work, just realize that the file is obliterated by the system-config-iptables (or is it system-config-firewall ...) tool. so if you do that, never run the config tools.
    New to the internet, technical forums, or the hacker / open source community??
    Read this to learn good posting habits http://www.catb.org/~esr/faqs/smart-questions.html

    RHCE for RHEL version 5
    RHCT for RHEL version 4

Posting Permissions

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