Find the answer to your Linux question:
Results 1 to 4 of 4
I want to write a quick script that will allow my server to route automatically (I'm testing this on a virtual machine). Would I put this: Code: while true do ...
  1. #1
    Just Joined!
    Join Date
    Jan 2011
    Posts
    87

    setting up iptables with CentOS

    I want to write a quick script that will allow my server to route automatically (I'm testing this on a virtual machine). Would I put this:
    Code:
    while true
    do
    echo 1 > /proc/sys/net/ipv4/ip_forward
    iptables –A POSTROUTING –t nat –o eth0 –j MASQUERADE
    done
    in /etc/rc.d to do it automatically?

  2. #2
    Just Joined!
    Join Date
    Dec 2011
    Posts
    1
    hi~
    Do you means your script will be work ,when your Centos start?
    in /etc/rc.local . you can try it

  3. #3
    Banned
    Join Date
    Nov 2011
    Location
    India
    Posts
    29
    Quote Originally Posted by Mislost View Post
    hi~
    Do you means your script will be work ,when your Centos start?
    in /etc/rc.local . you can try it
    you can simply add this rule in /etc/rc.local ...

  4. #4
    Linux Guru Lazydog's Avatar
    Join Date
    Jun 2004
    Location
    The Keystone State
    Posts
    2,281
    Quote Originally Posted by pauhn View Post
    I want to write a quick script that will allow my server to route automatically (I'm testing this on a virtual machine).

    in /etc/rc.d to do it automatically?
    This would all depend on how you are booting. rc.3 is for CLI boot and rc.5 is for GUI boot.
    Your best bet would be to look in /etc/sysconfig at the iptables file and edit it as needed.

    Regards
    Robert

    Linux
    The adventure of a life time.

    Linux User #296285
    Get Counted

Posting Permissions

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