Find the answer to your Linux question:
Results 1 to 4 of 4
I have done all the correct physical connection n setup the ip,subnet n gateway for my eth0 (to internet) n eth1 (to private network). But i don't understand the iptables ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jul 2005
    Posts
    9

    How to do NAT on my linuxbox


    I have done all the correct physical connection n setup the ip,subnet n gateway for my eth0 (to internet) n eth1 (to private network).

    But i don't understand the iptables part.Can anyone guide me on the iptables part.

    using Linux kernel 2.6.9-5.Elsmp...can anyone guide me on this.

  2. #2
    Just Joined!
    Join Date
    Oct 2005
    Posts
    19
    STEP 1:
    Configure the two network interfaces according to the network
    ifcfg-eth0
    DEVICE=eth0
    ONBOOT=yes
    BOOTPROTO=static
    IPADDR=192.168.102.50
    NETMASK=255.255.255.0
    ifcfg-eth1:
    DEVICE=eth1
    ONBOOT=yes
    BOOTPROTO=dhcp
    HWADDR=00:E0:4D:02:60:30

    STEP 2:
    Enable the IPV4 Routing (both static and dynamic)
    static :
    Edit /etc/sysctl.conf
    change "net.ipv4.ip_forward = 0" to "net.ipv4.ip_forward = 1"

    Run the following command:
    # echo 1 > /proc/sys/net/ipv4/ip_forward

    STEP 3:
    Configure the IP tables

    3.1 Flush all the current rules:
    # iptables -F -t nat

    3.2 Set the Masquerading
    # iptables -A POSTROUTING -t nat -o eth1 -j MASQUERADE
    CAUTION :
    The above set up doesn't uses any firewalls. If you need firewalls to be implemented then either visit www.netfilter.org or www.tldp.org.
    other resources(preferred):
    http://www.linuxforum.com/linux_tutorials/5/1.php
    http://www.linuxforum.com/linux_tutorials/6/1.php
    regards
    libregeek

  3. #3
    Just Joined!
    Join Date
    Jul 2005
    Posts
    9
    According to your step 1,i have some confusion on it.Do i need to set an ip like 192.168.0.1 for the eth1 n eth1's gateway is equivalent to eth0's ip address? Do u have any comment on this?

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Oct 2005
    Posts
    19
    There is no need to give GATEWAY in the router configuration. You need the GATEWAY in the client's ifcfg-ethX file. Only thing is that yiou should enable IP forwarding in your linux machine

Posting Permissions

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