Creating a Debian Firewall - A step-by-step tutorial
Posted by CyberDog on Mon 3 Oct 2005 at 11:43
For quite some time now I've personally worked with building custom Linux firewall solutions. I wanted to share my knowledge with others interested in the networking and Linux fields, so I've begun work on a Linux Firewall tutorial series.
The format is designed to cater to beginners in Linux, but the topics encourage exploration and can be a good foundation for more experienced users looking to branch out as well. The tutorial utilizes the Debian distribution as its core system, and gives step by step instruction on installing and configuring a computer system for use as a firewall/router/network gateway in a SOHO or home network.
Now that I've finished the core tutorial and am proceeding to the extended topics, I feel the work is ready for public exposure, and I would greatly appreciate some peer review. I'd like to invite the members of the Debian community to review my work, and hopefully provide me with some great feedback!
Without further delay, on to the tutorial...
http://www.cyberdogtech.com/firewalls/
Linux+, A+, CCNP, CCDP
Just my 2¢
Cheers
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
Great job! Thank you!
However One typo to fix,
Section:
Firewall:~# nano -w /etc/shorewall/interfaces
SNIP
Second is our internal interface (eth1):
locl eth1 detect dhcp
^^
But we named the zone "loc"
--
Dan Hunt, St. Brieux Saskatchewan Canada
[ Parent | Reply to this comment ]
Thanks again for pointing out the typo, those silly config files don't spellcheck as well as the rest of the document. :)
[ Parent | Reply to this comment ]
Cheers!
---
stoffell
[ Parent | Reply to this comment ]
1) The tutorial is intended to be modular, so ideally one part shouldn't influence another part, and parts can be skipped based on the reader's needs. And assuming one is running DHCP but skipping the DNSMasq chapter, installing DNSMasq soley for DHCP may or may not make much sense.
2) Furthermore, the tutorial is less about "this is how it should be done" and more about "this is how it can be done." In that sense, I feel I'm doing the reader more of a service by covering a broader range of popular, available software. There's no doubt the regular DHCPD package is basically the standard, so I felt it was important to cover it to some degree. Now that both packages have exposure in the tutorial, the reader can make a more informed decision about what they want based on their own experience.
Thanks for the feedback!
-
Matt
[ Parent | Reply to this comment ]
Thanks,
Jonto
[ Parent | Reply to this comment ]
-
Matt
[ Parent | Reply to this comment ]
the very last line says:
Firewall:~# nano -w /etc/init.d/dnsmasq restart
it should say
Firewall:~# /etc/init.d/dnsmasq restart
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
-
Matt
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
On the other hand, if you're working in a business environment, you can't necessarily trust the people on the LAN either. The fact remains you will probably have to run some of these services, but to minimize risk you can choose to run them on separate machines with totally separate authentication. For example separate machines for DHCP and DNS. If one service were compromised, hopefully the others would be unaffected.
Keep in mind, however, that there's no such thing as perfect security without proper maintenance. A firewall with no services can be compromised if an operating system flaw is found and not patched by the administrator, and this is true of any operating system. By the same token, any system with exposed services (a server) can be perfectly safe if diligently maintained. So while there are best practices, such as dividing tasks amoung separate physical machines, it usually comes down to proper planning, configuration, and maintenance to make the difference between a safe network and a compromised network.
-
Matt
[ Parent | Reply to this comment ]
I'd welcome any other views on the topic, as I can see this is a very well-informed group, but I'm pleased to see that the views I'd been forming aren't completely off-base.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
I have no account, hence the 'Anonymous'-user.
Small typo/fix:
(Assuming eth0 is net and eth1 is local, as it is in the tutorial)
Step 5, and specifically masq.
eth1 and eth0 should be swapped?
-------------
Firewall:~# nano -w /etc/shorewall/masq
We have to tell shorewall that we want all traffic coming from inside the network (on eth1) to be translated out through the interface on eth0). We do this simply by specifying the interfaces:
eth1 eth0
-------------
Cheers
/Erik
[ Parent | Reply to this comment ]
I am running static IP to the net, and static IP on 25 internal boxes.
How should I alter these directions to make this work?
I have eth0 eth1 defined already for the router, but do I replace the dhcp enables entries with the static IP addresses?
I followed your directions and when I try to start shorewall it errors out saying /etc/init.d/shorewall line 121 $SRWL start >> INITLOG 2>&1 not done.
not sure if this is an error from static IP confusion or whether I need to add them etc. I checked shorewall home and it mentions static IPs assignment as "rare" and offers few other hints for me.
thanks
[ Parent | Reply to this comment ]
In the Debian interfaces config, configure both interfaces with their static IP addresses, rather than using DHCP to configure the ISP side.
You can skip the step for a DHCP server entirely if you're using static IP addresses on all your internal hosts. Granted this method isn't usually recommended if for no other reason than configuring 25+ boxes individually would be a major pain...but there's no technical reason you can't do it. Just set your firewall's internal interface as the default gateway on all the internal machines, and make sure none of their IPs conflict, and that is all that's required to make them compatible.
The shorewall error sounds like something that would happen where there's a typo in one of the configs. Did you run "shorewall check" to see if it finds an error? If so, do this from the command line first. If that passes, run "shorewall start" (or "restart") from the command line, rather than using the init script. This should start shorewall in the foreground and allow you to see which config is causing a problem. You can also check /var/log/syslog for the shorewall errors. If you find it was caused by an problem in the tutorial, please let me know.
-
Matt
[ Parent | Reply to this comment ]
yeah, I am not sure why the previous sysadmin used internal static IPs, they are already set and pointed to eth1 gateway.
When I run shorewall check the only error I see is cannot set route filtering on eth0....but then it validates.
When I run start shorewall I see the above error as well as
masquerades network and hosts error unknown interface eth0
ifconfig shows eth0 static IP info is correct, and NIC mac is recognized.
maybe I should just remove shorewall reconfig from the beginning?
[ Parent | Reply to this comment ]
"ERROR: Unknown interface
The interface appears in a configuration file but is not defined in /etc/shorewall/interfaces."
I would agree that it sounds like eth0 is not properly defined in the shorewall interfaces file (/etc/shorewall/interfaces). I would check that before you go starting from scratch.
Since the config is not terribly complicated, you may wish to try starting over. Just rename the /etc/shorewall directory as apt will probably not remove the config files by default.
I also recommend the shorewall mailing list for shorewall support...it's fairly active and you can usually find somebody there who can help you debug program errors.
-
Matt
[ Parent | Reply to this comment ]
much thanks for the tutorial/replies
[ Parent | Reply to this comment ]
I have been using Iptables for a while and trying to configure something new. I followed the tutorial and everything makes sence... but I can't get PAT to work via this configuration. I can figure out how to configure it, but I want to pass this tutorial to a friend that know little about linux... and since I know little about what shorewall is donign can someone explain how it is passing packets from one interface to another and what packages debian needs to have PAT working?
[ Parent | Reply to this comment ]
I'll try to use eth0, it seems more clean.
Pablo Sánchez.
[ Parent | Reply to this comment ]
[ Send Message | View SaintSamuel's Scratchpad ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
Thank's for your time.
[ Parent | Reply to this comment ]