This is the old SliTaz forum - Please use the main

generic iptables firewall.conf?
  • foxsamfoxsam January 2011
    I am having two troubles involving, I think, firewall and NAT etc...
    one. I cannot access the internet via ppp0 (usb modem) while eth0 (LAN network, no internet) is up. I am assuming that the problem is a routing table problem that is causing it to look on the LAN for internet addresses.
    two. I am trying to get the computer to share (masquerade) the internet connection out through the ethernet into my (real, wireless) router's WAN port so i can use my modem as wifi.

    The question here is, is there a generic firewall.conf that i can just copy? I am having trouble getting past step one. I installed iptables and dependencies and tried setting the rules but I really don't know what I am doing.

    Stage 2 will be to get this modem working over bluetooth but for now usb is good :)

  • OldGuyOldGuy January 2011

    is this the setup you would like to achive?

    Internet -> mobile device -> [ ppp0 -> PC -> eth0 ] -> [eth0 -> router -> wlan0] --wireless-- [wlan0 -> hostPC] ?

    Does your router have a internal DSL/cabel modem?
    Does it need to be connected to an external DSL/cable modem and ttherefore uses PPPoE?
    Does it really use straight IP on the WAN port?

    Your first problem indeed sounds like a routing table issue.
    Pls. post the result of "route -n" while the ppp0 is up and connected

    The following "BASIC!!!" script should help you to use your PC as a NAT-router:

    $IPTABLES -t raw -F
    $IPTABLES -t mangle -F
    $IPTABLES -t nat -F
    $IPTABLES -t filter -F



    $IPTABLES -A FORWARD -p tcp ! --syn -m state --state NEW -j DROP

    echo "1" > /proc/sys/net/ipv4/ip_forward

    Edit: Inserted the missing 'state' in the last line.

    Pls. be aware that this is NO FIREWALL but masquerading only!!!!

  • foxsamfoxsam January 2011
    this is without ethernet cable plugged in:
    it works and connects to the internet.

    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface UH    0      0        0 ppp0 UH    0      0        0 lo         U     0      0        0 ppp0

    this is after i connected ethernet:
    I had to start dhcp to listen by clicking start in netbox dhcp tab.

    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface UH    0      0        0 ppp0 UH    0      0        0 lo     U     0      0        0 eth0         UG    0      0        0 eth0         U     0      0        0 ppp0

    I get an error running the script (if I did it right)

    iptables v1.4.5: Couldn't load match `--state':/usr/lib/iptables/xtables/ cannot open shared object file: No such file or directory

    Try `iptables -h' or 'iptables --help' for more information.

  • Trixar_zaTrixar_za January 2011
    @OldGuy Last time I checked iptables was part of Linux's firewall :-/

    @foxsam What kind of connection are you trying to use with ppp0?
  • foxsamfoxsam January 2011
    @Trxar_za If i understand your question:

    I am trying to get what OldGuy said above:
    Internet -> mobile device (USB 3g modem)-> [ ppp0 -> PC -> eth0 ]
    -> [eth0 -> router (WAN port) -> wlan0] --wireless-- [wlan0 -> hostPC]

    But I am really stuck before that:

    Internet -> mobile device (USB 3g modem)-> [ ppp0 -> PC -> eth0 ]
    -> [eth0 -> LAN(via router LAN port)]

    When ethernet is connected it (i think) looks on the LAN segment for internet IPs.
  • OldGuyOldGuy January 2011
    @Trxar_za - Indeed "part of". Just because one uses some software, which usually is used to setup a firewall, doesn't mean that you'll have a firewall at the end of it. To my understanding a firewall does a lot more than 'only' masqerading. The script I put up doesn't provide much more then NAT and foxsam should be aware of that he will not get a real firewall with this script. ;-)

    @foxsam - It seems there is a 'Default Gateway' ( configured in your eth0-Interface setup. There can be only one (where did I hear that one before :-) ) 'Default Gateway' in a router. Therefore check your eth0 setup and delete the gateway entry.

    As for the problem with the library: it seems there are some unsolved dependencies with your iptables installation.
  • foxsamfoxsam January 2011
    where do i remove the default gateway from? I don't think is is set anywhere. Can it be geetting it from dhcp?

    what to do about iptables to fix it?
  • GokhlayehGokhlayeh January 2011

    when iptables is installed SliTaz setup the firewall using /etc/firewall.conf - which already contains some basic rules. Note it also drops all forward by default.
    This file can be useful to setup you're own configuration, including masquering etc...
    And by default it doesn't prevent any direct connection to the net, or direct local connection, just drop input from unknown senders.
  • erniaernia January 2011
    if i don't get it wrong in route -n output you have two destination fields, so packets go away through the first catch, that in your case is eth0, which i suppose is not what you want.
    route del default gw eth0 should del the wrong route :
    if i understood what you are trying to do i think that if you want use your box as a ppp nat server for your network you should not start dhcp but start eth0 with a fixed address and without a default gw, then configure the default gw in the wlan-lan router to point to your box.
    oldguy's iptables rules should do the forwarding job
  • OldGuyOldGuy January 2011
    @foxsam - Just to make sure: We are talking abozt Slitaz (whaz version?) on your routing-PC, right?

    Also, could you pls. describe in more detail how your networks are setup?
    It seems that your eth0 interface still gets an IP address asigned by a DHCP-server.
    As we are talking about a multi network setup, it is crucial to understand your physikal and locial network setup.
    Can you therefore pls. fill in the missing information?

    Internet -> (USB 3g modem) -> usb-cable -> (ppp0 [routing PC])

    ([routing PC] eth0) -> crossover cable/hub/switch?? -> (wan0 [Router])
    Which other devices are physically connected to this network? (DHCP-server?)
    If this is connected through a hub/switch, is this the multiport LAN side of your wifi-router?
    What is the wan0-interface IP-setting on the wifi-router? Staic or DHCP?

    ([Router] eth0) -> crossover cable/hub/switch?? -> (eth0 [local PC])
    Which IP-address/Netmask combinations are used in this network?
    Which other devices are physically connected to this network? (DHCP-server?)

    If this is connected through a hub/switch, is this the multiport LAN side of your wifi-router?

    ([Router] wlan0) -> wireless -> (wlan0 [mobile PC])

    Which IP-address/Netmask combinations are used in this network?

  • OldGuyOldGuy January 2011
    Sorry, there was something missing in the script I provided. :-(

    Pls. change


    This should fix the "... / cannot open shared object file ..." problem. ;-)

  • foxsamfoxsam January 2011
    thanks for all the help :) I am too new to realise that I was going to confuse so many people with missing info.

    First of all I am using slitaz 3.0

    Here is what you wanted to know (i probably will still miss something but it is not intentional)

     i think is clear. usb modem connected using wvdial.

     is really 2 seperate problems in different scenarios. the one i want to keep is B.

     ([routing PC] eth0) -> link port of wireless router getting assigned ip via dhcp. connected to the router is another computer wirelessly. I can only use net1 OR net2A in this setting. not both at the same time.

     I want to connect ([routing PC] eth0) -> WAN port which is set as static. (I am pretty sure it can work if masqurade works, It has a setting for the port to be "IP Routing", and get its IP from dhcp which i think means that it works as a regular client and connects it to the other ports.) and hope to be able to connect to both net1 and net2.
     the router has busybox and i can telnet in and post what some commands return like the route -n ifconfig etc.. if it will help..

    none (if I understand...)

    wifi to other computers that i want to be able to access internet and servers running on [router PC] and [router] not sure how they are setup. how should i check?
  • OldGuyOldGuy January 2011
    I'm still a bit confused.

    Are you using anything (hub/switch), besides your wifi-router, to interconnect PC's within your local network?

    Can you provide more information on the wifi-router. (Brand, Modell)?

    Is the 3g modem the only access to the internet or is it just an alternative to some DSL/cabel?
  • foxsamfoxsam January 2011
    ok. thanks for helping me get this straight.

    the router is *it*

    the router is a verizon/westel 7501
    very robust capabilities

    it looks like it can do what i want from another wireless router as a wireless client too.

    3g is the *only* way I connect to the internet.
  • foxsamfoxsam January 2011
    I *think* if If I can get it to the stage that if I skip the router in the middle and use a crossover to another pc and it works, then I can get it working via the router. At least that will be a router issue not a slitaz issue.

    btw I *love* slitaz for what it is. small and light.
  • OldGuyOldGuy January 2011
    Ok, then let's approach this step by step.

    Modify your /etc/network.conf as follows:

    Restart networking "#>/etc/init.d/network restart"

    Run the script I priviously provided to enable NAT and forwarding.

    Thereafter, pls. configurate a PC with the following fixed IP configuration:
       ip =
       netmask =
       default gateway =
       dns server = (use the IP address of the dns-server provided from your ISP via the ppp0 Interface of the Slitaz PC)
    and connect it with a cross-over cable to eth0 of the Slitaz PC.
    (Instead of using a cross-over cable you now also could connect both PC's to the LAN side of the 7501 and use this as a switch between the PC's)

    You should now be able to browse througt the Internet at the same time from both PC's

    Keep us updated on how things are going.
  • foxsamfoxsam January 2011
    I am now writing this post from my laptop connected via crossover from the slitaz router PC which is connected via modem. if you can read this that means that masquerading is working.

    I am a little stuck tho bec on slitaz i can ping but midori does not work. it cannot resolve addresses. I will need to look into it later.

    thanks for all the help and support. I will keep you posted on stage 2, getting the routerr working, i did not get a chance to try yet.

    :) :)
  • OldGuyOldGuy January 2011
    Ok, first step done. :-)

    As for the wifi-router, ould you pls. check in your manual what kind of options for the WAN side you have with the 7501?
    I think it would be best to configurate it as a 'standard' router without NAT.
    If possible give the WAN interface a fixed/static IP-address (i.e NM GW, disable NAT and directly connect it to the eht0-interface of your Slitaz PC.
    Configure the LAN side of the router to your needs (e.g. Network NM )
    Let the DHCP-server of the wifi router distribute the according IP-address range
    (e.g. to NM DG DNS
    For the DNSserver you got tu use the Information provided by your ISP!!

    The final step would be to add a static route on your Slitaz PC
    #> route add -net netmask gw

    Now everyone 'behind' the wifi-router should be able to access the Internet if the 3g-modem is connected.
    Everyone behind your wifi-router should now also be able to communicate with your Slitaz PC and the Slitaz PC should be able to reach each host 'behind' the wifi-router.

    Happy routing ... :-)
  • foxsamfoxsam January 2011
    i am not sure exactly where i am up to :)
    the current setup is working nicely like this:
    modem -> slitaz pc -> LAN port router -> wireless -> laptops/wifi clients

    the router does work as if it was connected to the internet as far as the wireless clients connecting are concerned. meaning i can connect wirelessly to the router and the internet. i can also connect to the ssh server on the slitaz pc which is serving the internet to the router.

    the only part i want to fix is to get the router to give out dhcp so i dont need to set static ip for the computers connecting to wifi. I think if the slitaz was connected to the wan port this would be able to work.

    also it seems that something somewhere in what we changed makes it that I need to manually set dns server in slitaz or else i cannot connect to the internet. i think that may be part of the static IP?

  • OldGuyOldGuy January 2011
    Hmm ..., the DNS-server should be set when the ppp0 dialup is completed.
    Nevertheless, as an interrim solution you could set the IP-address of your providers DNS-server in the DNS entry of /etc/network.conf.

    As for the static IPs of your hosts, this will be fixed when the router is correctly setup.

    Couls you pls. reseach the 'static IP' config of the WAN side of the wifi-router and let us know what possibilities there are?

    If possible test the configuration I mentioned before:

    If possible give the WAN interface a fixed/static IP-address (i.e NM GW, disable NAT and directly
    connect it to the eht0-interface of your Slitaz PC.
    Configure the LAN side of the router to your needs (e.g. Network NM )
    Let the DHCP-server of the wifi router distribute the according IP-address range
    (e.g. to NM DG DNS
    For the DNS-server you got to use the Information provided by your ISP!!

    BTW, do you have a pdf-manual for your router ?
  • foxsamfoxsam January 2011
    I tried that configuration to connect 2 pcs using a crossover cable. it worked fine.

    I am working on the router side of things to get this working. I am sure that it can be done. the router is very flexible.
    a very interesting guide to getting the router to be a print server and ftp. it has a script to put in the firewall that starts the servers. I can porbably get it done in the firewall setting page.

    pdf guide:
  • foxsamfoxsam January 2011
    maybe i can keep this setup and setup a dhcp server on slitaz. i think it may make more sense to have all in one place.
    don't worry i'll be around for a while i am still stuck on a few other unrelated points.

    i am trying to get my printer setup and trying to get the modem to connect with bluetooth. and theres always more ideas cooking.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

SliTaz Social