Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

iptables and Shorewall configuration

Posted on 2006-11-07
13
Medium Priority
?
1,168 Views
Last Modified: 2007-12-19
How would I go about configuring Shorewall to give the following policy and rules:
I already have zones: fw, net and lan.

~# iptables -L
Chain INPUT (policy DROP)
target        prot  opt source               destination
DROP       all  --  anywhere             anywhere            state INVALID
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
DROP       tcp  --  anywhere             anywhere            tcp option=!2 flags:SYN/SYN
input_rule  all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     icmp --  anywhere             anywhere
ACCEPT     gre  --  anywhere             anywhere
REJECT     tcp  --  anywhere             anywhere            reject-with tcp-reset
REJECT     all  --  anywhere             anywhere            reject-with icmp-port-unreachable

Chain FORWARD (policy DROP)
target     prot opt source               destination
DROP       all  --  anywhere             anywhere            state INVALID
TCPMSS     tcp  --  anywhere             anywhere            tcp flags:SYN,RST/SYN TCPMSS clamp to PMTU
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
forwarding_rule  all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere

Chain OUTPUT (policy DROP)
target     prot opt source               destination
DROP       all  --  anywhere             anywhere            state INVALID
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED
output_rule  all  --  anywhere             anywhere
ACCEPT     all  --  anywhere             anywhere
REJECT     tcp  --  anywhere             anywhere            reject-with tcp-reset
REJECT     all  --  anywhere             anywhere            reject-with icmp-port-unreachable

Chain forward_vlan1 (1 references)
target     prot opt source               destination

Chain forwarding_rule (1 references)
target     prot opt source               destination
ACCEPT     all  --  anywhere             192.168.1.5
forward_vlan1  all  --  anywhere             anywhere

Chain input_rule (1 references)
target     prot opt source               destination
input_vlan1  all  --  anywhere             anywhere

Chain input_vlan1 (1 references)
target     prot opt source               destination

Chain output_rule (1 references)
target     prot opt source               destination
0
Comment
Question by:thehaze
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
13 Comments
 
LVL 11

Expert Comment

by:kblack05
ID: 17911094
you could use 'iptables-save >> snapshot.iptables.txt' then import the file with your shorewall configuration.
0
 

Author Comment

by:thehaze
ID: 17912476
How are they then 'imported' to the shorewall configuration? Can this be done from the command prompt?
0
 
LVL 11

Expert Comment

by:kblack05
ID: 17914773
Yes you can use 'iptables-restore' to start the firewall without aid from shorewall, then when you start shorewall you can use it to capture the existing configuration. In other words, you have used iptables tool sets to create a snapshot of the rules, portable, then when you use iptables tools to reload the rule sets Shorewall should be able to obtain the EXISTING firewall configs and load it into your browser interface.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:thehaze
ID: 17915436
How do I start shorewall you can use to capture the existing configuration.?
0
 
LVL 11

Expert Comment

by:kblack05
ID: 17915525
Google shorewall..

http://www.shorewall.net/starting_and_stopping_shorewall.htm#id2464306

You should be able to simply start shorewall with the existing configuration for IP Tables in effect, and it will grab all the running rules...
0
 

Author Comment

by:thehaze
ID: 17915654
I know how to start and stop shorewall. With 'shorewall start' it overwrites the current contents of iptables with the contents of the config files. I've tried shorewall save saved.txt, but it merely states that shorewall is not started.
0
 
LVL 11

Accepted Solution

by:
kblack05 earned 2000 total points
ID: 17916050

Try
Start iptables with the previous firewall config.

then issue

iptables-save >> /var/lib/shorewall/new.iptables

shorewall restore /var/lib/shorewall/new.iptables


###

Shorewall has now been integrated with iptables-save/restore.

Shorewall now supports multiple saved configurations.

The default saved configuration (restore script) in /var/lib/shorewall is now specified using the RESTOREFILE option in shorewall.conf. If this variable isn't set then to maintain backward compatibility, 'restore' is assumed.

The value of RESTOREFILE must be a simple file name; no slashes ("/") may be included.

The "save" command has been extended to be able to specify the name of a saved configuration.

           shorewall save [ <file name> ]

The current state is saved to /var/lib/shorewall/<file name>. If no <file name> is given, the configuration is saved to the file determined by the RESTOREFILE setting.

The "restore" command has been extended to be able to specify the name of a saved configuration:

          shorewall restore [ <file name> ]

The firewall state is restored from /var/lib/shorewall/<file name>. If no <file name> is given, the firewall state is restored from the file determined by the RESTOREFILE setting.

The "forget" command has changed. Previously, the command unconditionally removed the /var/lib/shorewall/save file which records the current dynamic blacklist. The "forget" command now leaves that file alone.

Also, the "forget" command has been extended to be able to specify the name of a saved configuration:

              shorewall forget [ <file name> ]

The file /var/lib/shorewall/<file name> is removed. If no <file name> is given, the file determined by the RESTOREFILE setting is removed.

The "shorewall -f start" command restores the state from the file determined by the RESTOREFILE setting.

0
 

Author Comment

by:thehaze
ID: 17916150
I try doing the following:
root@lbox:/# iptables-save >> /var/lib/shorewall/new.iptables
root@lbox:/# shorewall restore /var/lib/shorewall/new.iptables
then recieve:
ERROR: <restore file> must specify a simple file name: /var/lib/shorewall/new.iptables
0
 

Author Comment

by:thehaze
ID: 17916204
The format of iptables-save and 'shorewall save' are different. I can save the current shorewall firewall with 'shorewall save', then restore it using 'shorewall restore', without any issue. Likewise a iptables-save can be rebuilt using a iptables-restore without problems.

I have a complex iptables firewall which somehow has to imported into shorewall..?
0
 
LVL 11

Expert Comment

by:kblack05
ID: 17916295
You're right. This method works on 2.x and older, but I see now that there is a spurious use of "printf" in the newer version.

Let me see if I can find an import filter, or perhaps someone here might have one...
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

​Being a Managed Services Provider (MSP) has presented you  with challenges in the past— and by meeting those challenges you’ve reaped the rewards of success.  In 2014, challenges and rewards remain; but as the Internet and business environment evol…
Hello EE, Today we will learn how to send all your network traffic through Tor which is useful to get around censorship and being tracked all together to a certain degree. This article assumes you will be using Linux, have a minimal knowledge of …
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question