debian 4 and NAT

Discussion in 'Server Operation' started by mfaridi, Feb 16, 2008.

  1. mfaridi

    mfaridi New Member

    I use this link for configure NAT on Debian 4 and do everything this link said

    http://www.howtoforge.org/nat_iptables

    but after reboot system I have to do all of this command for run
    how I can save this rules and use them in reboot ???:confused:

    How I can make script from rule and put them in /init.d/
     
    Last edited: Feb 16, 2008
  2. topdog

    topdog New Member HowtoForge Supporter

    Code:
    iptables-save > /etc/iptables-rules
    
    Edit /etc/network/interfaces under your main interface add
    Code:
    pre-up /sbin/iptables-restore < /etc/iptables-rules
    
     
  3. mfaridi

    mfaridi New Member


    Thanks
    first I type this command step by step
    Code:
    iptables --flush      
    
    Code:
    iptables --table nat --flush
    Code:
    iptables --delete-chain
    Code:
    iptables --table nat --delete-chain
    Code:
    iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
    Code:
    iptables --append FORWARD --in-interface eth1 -j ACCEPT
    Code:
    echo 1 > /proc/sys/net/ipv4/ip_forward
    after that I run this command
    Code:
    iptables-save > /etc/iptables-rules
    and then I put this line

    Code:
    pre-up /sbin/iptables-restore < /etc/iptables-rules
    in

    Code:
    /etc/network/interfaces
    before

    Code:
    auto eth0
    and after description of eth0 , but after that I can not ssh to system and NAT does not work


    :eek: :eek:
     
  4. topdog

    topdog New Member HowtoForge Supporter

    That goes under iface eth0 ....
    Note that the rules provided there are just for NAT no firewalling rules are entered.

    what is the output of the file ? To see why you cannot ssh in
    Code:
    cat /etc/iptables-rules
    
     

Share This Page