Find the answer to your Linux question:
Results 1 to 7 of 7
Hi there, I'm very new to the Linux. I'm migrating from Windows environment because of the tons of features I found in Linux. However, I'm still facing problems in the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2004
    Location
    Riyadh
    Posts
    5

    NEED HELP about NAT over SuSE


    Hi there,
    I'm very new to the Linux. I'm migrating from Windows environment because of the tons of features I found in Linux. However, I'm still facing problems in the netwrok configuration. I really appreciate any help from you people.
    So here is the situation:
    P4 - 512 MB RAM - 40 GB HDD
    SuSE 9 - Kernel 2.4.21
    Three NIC
    eth0 connected to the local LAN with IP 192.168.0.1/24
    eth1 connected to the ADSL Modem 1 with IP 192.168.1.100/24 (the ADSL modem IP is 192.168.1.1)
    eth2 connected to the ADSL Modem 2 with IP 192.168.2.200/24 (the ADSL modem IP is 192.168.2.1)
    PPPoE sessions are controlled by the modems, the modems do NAT and are connected by cross cable back-to-back to eth1 and eth2
    Both ADSL links are connected to the same ISP
    I'm using the following articale to balance the load to both ADSL links:
    lartc.org/howto/lartc.rpdb.multiple-links.html
    What I need is, how can I (and if possible step by step) run the NAT service so I can allow my users to go through this SuSE box with all Internet services (like POP3, IM, others) and keep the load balancing works?
    I've tried running the NAT service but it didn't work. And more worse, whenever I restart the box, I lose all the customization of teh routing tables!!

    People, your faster response is really helpful.
    Thanks,

  2. #2
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    How exactly did you set up NAT? Maybe you already tried this, but I think would be wise to use the MASQUERADE target, so that it's SNATed to the source address of the outgoing interface.

  3. #3
    Just Joined!
    Join Date
    Jun 2004
    Location
    Riyadh
    Posts
    5
    Infact as I'm new to the Linux, I didn't know how to setup the NAT. Around 5 hours ago, I found an article which telling me how to (as you wrote) simply use the MASQUERADE. After executing the following commands it works fine, and it some how balancing to the two ADSL links I have.
    modprobe iptable_nat
    iptables -t nat -A POSTROUTING -j MASQUERADE
    echo 1 > /proc/sys/net/ipv4/ip_forward
    But I still have a problem when I'm restarting the system. I've created one file to be a startup script by the following way:
    1. Created ADSLR01 in the /etc/init.d folder
    2. I make executable (I'm not really sure about this command) by running chmod 755 ADSLR01
    3. I used the YaST2 tool in SuSE 9.0 to ask the Linux to run it at level 3 and 5

    Now, when I restart the natting is working fine but the routing rules are not!! If I logon and execute the script manually everything goes fine till the next boot!!

    I'm really working visual basic scripting on Windows fine, and I think I can do well on Linux scripting if I know where to start from (web site or something). However, here down the contents of the ADSLR01 file:
    "Begin of scrip"
    #! /bin/sh
    modprobe iptable_nat
    iptables -t nat -A POSTROUTING -j MASQUERADE
    echo 1 > /proc/sys/net/ipv4/ip_forward
    ip route add 192.168.1.0 dev eth1 src 192.168.1.100 table T1
    ip route add default via 192.168.1.1 table T1
    ip route add 192.168.2.0 dev eth1 src 192.168.2.200 table T2
    ip route add default via 192.168.2.1 table T2
    ip rule add from 192.168.1.100 table T1
    ip rule add from 192.168.2.200 table T2
    ip route add 192.168.0.0/24 dev eth0 table T1
    ip route add 192.168.2.0/24 dev eth2 table T1
    ip route add 127.0.0.0/8 dev lo table T1
    ip route add 192.168.0.0/24 dev eth0 table T2
    ip route add 192.168.1.0/24 dev eth1 table T2
    ip route add 127.0.0.0/8 dev lo table T2
    ip route add default scope global nexthop via 192.168.1.1 dev eth1 weight 1 nexthop via 192.168.2.1 dev eth2 weight 1
    "End of scrip"

    I appreciate your help Dolda2000, thanks.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Well, off the top of my head, it could be the boot order. If that ADSLR01 file gets run before the network interfaces are set up properly, I could imagine that such a thing could happen.
    The iptables rules and ip_forwarding don't hurt if you set them up before the interfaces are up and running, since they aren't bound to an interface. The routing rules, on the other hand, are bound to the interfaces they affect, so the interfaces must be properly set up and running before you set the routing rules.

  6. #5
    Just Joined!
    Join Date
    Jun 2004
    Location
    Riyadh
    Posts
    5
    Thanx, That was what I just learned from monitoring the boot sequince. Can you tell me how to roder (prioritize) the scripts?

  7. #6
    Linux Guru
    Join Date
    Oct 2001
    Location
    Täby, Sweden
    Posts
    7,578
    Well, unfortunately, I'm not sure how SuSE's boot sequence works, since I haven't used SuSE. Considering that SuSE is RedHat-based, though, I'd be guessing that it uses the same SysV-like boot sequence that RedHat does.

    If it does, here's a brief of how it works:
    1. You have the subsystem setup scripts in either /etc/init.d or /etc/rc.d/init.d (on RedHat, /etc/init.d is a symlink to /etc/rc.d/init.d).
    2. Then you have the runlevel directories - /etc/rc.d/rc[0-6].d - one for each runlevel. For example, /etc/rc.d/rc5.d is used for getting into runlevel 5.
    3. In each of the runlevel directories, there are symlinks to the scripts in init.d. The names of these symlinks decide the boot sequence. When a runlevel is entered, first all the symlinks that have names beginning with K are run with the argument "stop". Then, all the symlinks that have names beginning with S are run with the argument "start".
    4. The order in which they are executed is simply decided by ordering the symlinks in alphabetical order. Thus, it is the convention for these symlinks to, after the initial K or S, have two digits. Thus, when sorting the symlinks, these digits decide the boot order.

    When the system boots, it usually enters runlevel 3 or 5 depending in your distro and settings. For RedHat-based distros, runlevel 3 is for booting into a text environment (usually for servers) and runlevel 5 is for booting into a graphical environment. Usually these two are exactly equal, only that runlevel 5 also starts a graphical display manager.

  8. #7
    Just Joined!
    Join Date
    Jun 2004
    Location
    Riyadh
    Posts
    5
    That was great description for the boot order. It uses the sam as RedHat. I've used the S99ADSLR01 and set it in the init 3 folder and it works just fine.
    Thanks again.

Posting Permissions

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