Results 1 to 7 of 7

Thread: How do I save my changes to Iptables?

  1. #1
    Join Date
    Feb 2005
    Location
    Haugesund, Norway
    Posts
    18

    How do I save my changes to Iptables?

    Suppose I add some stuff to iptables by telneting to the router and adding stuff manually. The changes will then work without a reboot, but they will be lost if the router is rebooted for some reason.

    How do I prevent this from happening? I've seen some references to "flashfs", but any information I'm able to find always seems to require prior knowledge, and then I'm stuck...

    I'm running the latest custom firmware from Oleg, in case it matters.

  2. #2
    Join Date
    Dec 2003
    Location
    Russian Federation
    Posts
    8,356
    Have you read this page already?

  3. #3
    In short:
    1. mkdir -p /usr/local/sbin
    2. make file post-firewall and put all the changes you make there (remember to start file with #!/bin/sh)
    (ex.
    echo "#!/bin/sh" > post-firewall
    echo "iptables -a INPUT...." >> post-firewall
    ...)
    2.1 Test your script Ex: ./post-firewall
    3. flashfs save
    4. flashfs commit
    5. flashfs enable
    6. reboot

    7. Everytime you wish to edit the post-firewall script you have to repeat steps 2-4 and 6.

    Sjur

  4. #4
    Join Date
    Feb 2005
    Location
    Haugesund, Norway
    Posts
    18
    Thanks, both of you.

    Oleg, I had seen that page before, but I'd forgotten all about it.

    Sjur, you forgot to set the script to executable (+x) in you "recipe", but you did manage to avoid using vi.... :-)

    I think I've gotten the gist of it now. I'll test it later...

  5. #5
    Oh, yeah. chmod +x. Good.

    And yes, vi is kinda picky on who its friends are
    Maybe I should aks if anyone has compiled another texteditor like pico or something...

    Sjur

  6. #6
    Join Date
    Feb 2005
    Location
    Haugesund, Norway
    Posts
    18
    It worked as advertised, and my iptables for the FORWARD chain now reads:

    Code:
    Chain FORWARD (policy ACCEPT)
    target     prot opt source               destination
    ACCEPT     all  --  anywhere             anywhere           state RELATED,ESTABLISHED
    DROP       all  --  anywhere             anywhere           state INVALID
    ACCEPT     all  --  anywhere             anywhere
    ACCEPT     udp  --  anywhere             anywhere           udp dpt:6112
    DROP       all  --  192.168.12.105       anywhere            TIME from 22:30:00 to 23:59:59 on Sun,Mon,Tue,Wed,Thu,Fri,Sat
    DROP       all  --  192.168.12.105       anywhere            TIME from 00:00:00 to 07:00:00 on Sun,Mon,Tue,Wed,Thu,Fri,Sat
    DROP       all  --  anywhere             192.168.12.105      TIME from 22:30:00 to 23:59:59 on Sun,Mon,Tue,Wed,Thu,Fri,Sat
    DROP       all  --  anywhere             192.168.12.105      TIME from 00:00:00 to 07:00:00 on Sun,Mon,Tue,Wed,Thu,Fri,Sat
    My sons computer is connected by wireless, and I've made a manual assignment forcing his MAC address to always be given the 192.168.12.105 IP address by the router. It seems to me I should now have prevented any packets being forwarded between the LAN and the WAN from 22:30 in the evening to 07:00 in the morning. I've used two rules for each direction to get past midnight, but maybe I could have used one rule that said to accept packets from 07:00 to 22:30 instead?

    I've just used -A to add these four rules in the post-firewall script.

    Oh, and one more thing: What is the purpose of the rule that says to accept udp packets to port 6112? This one is added by the router itself, and I don't know the purpose.

  7. #7
    Join Date
    Dec 2003
    Location
    Russian Federation
    Posts
    8,356
    Quote Originally Posted by oyvindk
    Oh, and one more thing: What is the purpose of the rule that says to accept udp packets to port 6112? This one is added by the router itself, and I don't know the purpose.
    Starcraft, just disable it.

Similar Threads

  1. Iptables
    By byteZero in forum WL-500g Q&A
    Replies: 2
    Last Post: 07-11-2006, 19:23
  2. Save As a File
    By kwewel in forum Dutch Discussion - Nederlands
    Replies: 0
    Last Post: 16-08-2005, 23:14
  3. Iptables
    By barsju in forum WL-500g Q&A
    Replies: 15
    Last Post: 01-03-2005, 01:36
  4. How to stop printer-related stuff to save memory?
    By RoofCat in forum WL-500g Q&A
    Replies: 9
    Last Post: 16-02-2005, 15:22
  5. How to save current firmware?
    By JOCKYW2001 in forum WL-HDD Custom Development
    Replies: 30
    Last Post: 06-10-2004, 12:26

Posting Permissions

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