One of the most difficult problems when dealing with a firewall is that the network or subnetwork we want to protect usually has to be split into at least two subnetworks: one on the external side and one on the internal, protected side. This, apart from the planning stage, can result in the reconfiguration of all machines in the network to the new configuration. What is worse is that in case of a hardware fault of the firewall, you'll have to reconfigure all machines in your network so they will be able to see the outside until you repair the firewall machine. The configuration of the firewall can be even harder if you don't have access to the configuration of the machine that actually connects your network to the external world, very often a router or something leased from a telco (telephone company).
We are going to explain a smarter way of adding a firewall to your network without breaking it into subnetworks or reconfiguring any machine on the internal or external network, except from the firewall machine itself, by just fooling the other machines into thinking nothing changed. We will cover the aspects of the network configuration and packet routing, not real packet-filtering firewalling, since this has already been covered in depth in another Linux Journal issue (see Resources).
In the practical examples, we will pretend we have a C class network, where our contact with the external network is the .1 machine in the network (let it be a router, a machine or whatever). We will assume the IP numbers .2 and .3 to be free for our use. We will also need another IP greater than or equal to .4, so we must be sure these aren't used for other purposes. Of course, with a different network configuration, you'll have to adjust some calculations to make the method fit your needs. To make things even clearer in the examples below, let's fix our C class network to the 188.8.131.52 one.
As for the Linux box that will work as a firewall, you must actually have the kernel compiled with the usual networking options, including IP forwarding and IP firewalling and whatever you else may need, for example, IP accounting. Also, enable IP forwarding in the kernel; in newer kernels, this is done by enabling it directly in the /proc file-system. (For example, by using echo 1>/proc/sys/net/ipv4/ip_forward. Your initialization scripts should take care of this.) Another thing to note is that you should have a working arp program installed on your system. In fact, some distributions are shipped with an arp binary that is compiled without the new SIOCSARP kernel interface, so it doesn't work, and if you forget to check this one thing, it may cause you many unnecessary headaches.
The Linux box must have two Ethernet cards installed: eth0, connected to the internal network; and eth1, directly connected to the gateway machine for our network to the world.
Now, the network interfaces on the firewall machine must be configured. The internal network interface will be configured in the same way as the other internal machines, as if it had all machines on the network. So in our class C example, the eth0 configuration would be the following:
inet addr : 184.108.40.206 network : 220.127.116.11 broadcast : 18.104.22.168 netmask : 255.255.255.0
Remember that in place of 22.214.171.124, you can use any other unused address. The commands to do this are
ifconfig eth0 126.96.36.199 netmask 255.255.255.0\ broadcast 188.8.131.52 route add -net 184.108.40.206This configuration will also apply to all machines in the internal network behind the firewall; of course, the IP address will change on each.
The second network interface, eth1, will be configured as if it had a very small network; actually, four IPs is the least we can manage. This is where the firewall machine and the gateway will be placed.
inet addr : 220.127.116.11 network : 18.104.22.168 broadcast : 22.214.171.124 netmask : 255.255.255.252
This is obtained using the following commands:
ifconfig eth1 126.96.36.199 netmask 255.255.255.252\ broadcast 188.8.131.52 route add -net 184.108.40.206 route add default gw 220.127.116.11The routing table is now set, so that packets for the entire class C network will be redirected to the internal eth0 interface, while the packets for the small network will be routed to the external eth1 interface. Finally, the default gateway has to be set for all machines on the internal network, that is, 18.104.22.168. Please note that this routing scheme works because the most specific route is applied first.
There are two more questions to solve. First, how will the gateway know how to reach the internal machines? Remember, we haven't changed the gateway configuration, so it still thinks it has the C class network attached to it. Second, how will the machines be able to reach the gateway? After all, they still believe they have the entire C class network, including 22.214.171.124, on their network interface. Well, it will be easy; we just make believe all the machines are on a class C network. The trick is to hack the process of translating the IP address to the hardware (in our case, Ethernet) address, which is called the ARP (address resolution protocol). (If you're not familiar with this, please consult the NET-HOWTO and Proxy-ARP miniHOWTO.) This can easily be done by telling our firewall machine to answer all ARP requests for the gateway on the internal network and reply to all requests for any internal machines from the gateway. Practically, this is done in two stages. First, by publishing, via arp, the gateway and the firewall machine on the internal network, more exactly:
arp -v -i eth0 -Ds 126.96.36.199 eth0 pub arp -v -i eth0 -Ds 188.8.131.52 eth0 pub
Thus, when someone asks for .1 or .2 on the internal network, the firewall will reply, giving its Ethernet hardware address. In the second stage, we will publish all internal network IPs from .4 to .255, on the firewall-gateway small network. For the entire C class network, it look like this:
arp -v -i eth1 -Ds 184.108.40.206 eth1 netmask\ 255.255.255.128 pub arp -v -i eth1 -Ds 220.127.116.11 eth1 netmask\ 255.255.255.192 pub arp -v -i eth1 -Ds 18.104.22.168 eth1 netmask\ 255.255.255.224 pub arp -v -i eth1 -Ds 22.214.171.124 eth1 netmask\ 255.255.255.240 pub arp -v -i eth1 -Ds 126.96.36.199 eth1 netmask\ 255.255.255.248 pub arp -v -i eth1 -Ds 188.8.131.52 eth1 netmask\ 255.255.255.252 pubThis way, we have partitioned the address space and published all our IPs. When the gateway asks for the hardware address of an internal machine, the firewall will reply giving its address. Since we turned on the IP packet forwarding, once the firewall has a packet and replies to the ARP request, it will forward it to the destination machine according to the routing table.
This solution has proven to be very useful for us, especially when we had to enhance the existing network without causing “too much trouble”. The last step is, of course, tuning the firewall, IP accounting, transparent proxy or whatever you need on the Linux box—but that is another story.
Federico is studying computer science at the University of Udine. When not hacking or coding he enjoys reading sf, listening to music and playing guitar. He can be reached at email@example.com.
Christian Pellegrin is studying astrophysics at the University of Trieste and works part-time as a system administrator and teacher in a high school. When not playing with Linux and other fun software or hardware he enjoys discussing who is the best film director of all times with his girlfriend. E-mails are welcome at firstname.lastname@example.org.
Practical Task Scheduling Deployment
July 20, 2016 12:00 pm CDT
One of the best things about the UNIX environment (aside from being stable and efficient) is the vast array of software tools available to help you do your job. Traditionally, a UNIX tool does only one thing, but does that one thing very well. For example, grep is very easy to use and can search vast amounts of data quickly. The find tool can find a particular file or files based on all kinds of criteria. It's pretty easy to string these tools together to build even more powerful tools, such as a tool that finds all of the .log files in the /home directory and searches each one for a particular entry. This erector-set mentality allows UNIX system administrators to seem to always have the right tool for the job.
Cron traditionally has been considered another such a tool for job scheduling, but is it enough? This webinar considers that very question. The first part builds on a previous Geek Guide, Beyond Cron, and briefly describes how to know when it might be time to consider upgrading your job scheduling infrastructure. The second part presents an actual planning and implementation framework.
Join Linux Journal's Mike Diehl and Pat Cameron of Help Systems.
Free to Linux Journal readers.Register Now!
- SUSE LLC's SUSE Manager
- Murat Yener and Onur Dundar's Expert Android Studio (Wrox)
- My +1 Sword of Productivity
- Non-Linux FOSS: Caffeine!
- Managing Linux Using Puppet
- Doing for User Space What We Did for Kernel Space
- SuperTuxKart 0.9.2 Released
- Parsing an RSS News Feed with a Bash Script
- Google's SwiftShader Released
- Rogue Wave Software's Zend Server
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide