APLawrence.com -  Resources for Unix and Linux Systems, Bloggers and the self-employed
RSS Feeds RSS Feeds

(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version


Using and configuring ipfilter on old SCO Unix. They added this in SCO 5.0.6, it is just a port of the BSD code.

Ipfilter is available from SCO as TLS709 and is now included in Openserver 5.0.6.

I don't recommend that production servers have an external interface. See Why servers should not be on the Internet for my reasons.

Ipfilter provides NAT (which allows machines on an internal lan to access the outside world through your SCO server) and a packet filtering firewall capability (which prevents the big bad outside world from doing damage to your inside machines).

There is an excellent and complete How-To at http://www.obfuscation.org/ipf/ipf-howto.txt. I recommend that you download that and read it thoroughly: this article is only a brief overview of ipfilter and its use. The IPFILTER Home Page is also available.

The README tells you most of what you need to do, but you also need to edit /etc/default/inet and set ipforwarding and ipsendredirects to "1".


The NAT component of this is very simple. To set this up for my internal lan (which uses 10.1.36.? addresses), I simply do:

MYIP=`ifconfig net0 | grep inet | awk '{ print $2 }'`
ipnat -F
ipnat -C
ipnat -f - <<EOF
map net0 -> $MYIP/32

Note that net0 is my DSL line; if I were using ppp that line would be

map ppp0 -> $MYIP/32
And in either case you could also be more general with:
map net0 ->

and the rest would stay the same.

That's it. Note that you might use "net0" or "ppp0"; it's just whatever interface is used for your external network- "ifconfig -a" will show you if you don't know.

With NAT, every machine can get to the Internet, but it does so in disguise, with its actual IP address not being seen by the outside world.

The idea is that you have one or more "real" Internet addresses that will be used for communicating with the outside world. When machine wants to browse, the NAT software translates that address to one of the real addresses. When packets come back to that real address, it translates in the other direction and the packets go to The real addresses can get reused for different machines, and sometimes can even be in use at the same time: visualize Sally acting as translator for Bob and Bill. If Bob and Bill are trying to talk to the same person, Sally could get confused as to where to send the answers. But if Bob and Bill are talking to two different people, Sally knows where the answers go because she knows who they have been talking to. Therefor, even a small number of real addresses can serve quite a few users.

If you have Windows machines, they'll need a default route pointing at the SCO server, and they'll also need a DNS server assigned- that would likely be the same DNS address that you'd put in the SCO /etc/resolv.conf. You configure these things through the "Properties" tab of the TCP-IP configuration of the NIC card in Control Panel->Network. If you don't see TCP-IP listed under your NIC, then you need to Add->Protocol->Microsoft->TCP/IP (See Windows Network Configuration).


Ipfilter is a packet filtering firewall- it examines each incoming or outgoing packet, checks that packet against a list of rules, and then either lets it continue wherever it was going or stops it. That's all it does.

For example, here's a set of rules that pretty much closes down this machine for the outside world:

# flush all rules
ipf -F a
MYIP=`ifconfig net0 | grep inet | awk '{ print $2 }'`
ipf -f - <<EOF
# commom tcp ports
block in log quick on net0 proto tcp from any to $MYIP port = 21
block in log quick on net0 proto tcp from any to $MYIP port = 23
block in log quick on net0 proto tcp from any to $MYIP port = 25
block in log quick on net0 proto tcp from any to $MYIP port = 79
block in log quick on net0 proto tcp from any to $MYIP port = 80
block in log quick on net0 proto tcp from any to $MYIP port = 110
block in log quick on net0 proto tcp from any to $MYIP port = 113
block in log quick on net0 proto tcp from any to $MYIP port = 139
block in log quick on net0 proto tcp from any to $MYIP port = 143
block in log quick on net0 proto tcp from any to $MYIP port = 443
block in log quick on net0 proto tcp from any to $MYIP port = 111
# common udp
block in log quick on net0 proto udp from any to $MYIP port = 111
block in log quick on net0 proto udp from any to $MYIP port = 123
block in log quick on net0 proto udp from any to $MYIP port = 137
block in log quick on net0 proto udp from any to $MYIP port = 161
block in log quick on net0 proto udp from any to $MYIP port = 162
block in log quick on net0 proto udp from any to $MYIP port = 457
# log 
ipmon > /var/adm/firewall &

Note that you can use the supplied "mkfilters" script to create a set of default rules for you. This is a Perl script, so you may need to install Perl on older versions of SCO.

An important point to understand here is that these services don't necessarily have to be running, but you should still block them. Here's why: you could comment ftp out of /etc/inetd.conf, and that would obviously prevent ftp access to your machine (it does not prevent you from using ftp FROM your machine to some other machine). But the inetd daemon still listens on port 21 (ftp), and just that tells some other machine that you are here. What the bad guys do is scan ports looking for information. Just knowing you have a machine is information. Knowing that a particular port is being listened to is more information. Blocking the port (which is what ipfilter has been told to do above) has two purposes: it hides you, and perhaps even more importantly, it slows down the bad guys. Why? Because they have no way of knowing whether you haven't replied because you aren't there or that the reply is just slow getting back to them because of network traffic, slow communications lines, etc,

Not everyone agrees with that. The author of the How-To referenced above thinks that you should respond as inetd would when the service is not available. His reasoning is that running silent tells the attacker that you are running a packet filter. He thinks it's better to fool them into thinking that there are just no services available. Ipfilter has capabilities that will let you do that. Of course, if you really don't have the services running, it doesn't matter either way.

A better way

Every firewall book will tell you that the only proper way to do it is to deny all traffic by default, and selectively let in only what you want or need. Certainly it seems much more secure than letting in everything by default and blocking what you don't want, and it's silly to argue about that on a theoretical level. However, I've found that because of the complexity of configuration, it's actually just as easy (and sometimes even more easy) to screw up a rule and allow more than what you intended. That leaves you in the same situation as you would have if you forgot to block certain traffic. So, regardless of the experts opinions, I think that in actual practice, the non-expert might be better off explicitly listing the things they want to block. No doubt that opinion will make some people angry, but I've seen enough accidentally open firewalls to make me think I'm right.

Ipfilter does have some tricks to make this sort of configuration easier, though, and as it turns out, you can actually do it both ways. What wasn't obvious from the rules shown above is that ipfilter works like this: check every packet against every rule. If the rule applies to the packet, and the rule has the "quick" keyword in it, stop right there: pass it or block it (whichever the rule says) and don't look at any more rules. But, if the "quick" keyword isn't in the rule, ipfilter keeps looking for more rules that match the packet. If it doesn't find any, then it will do whatever the other rule told it to do. But if it does find another matching rule, it forgets all about the first rule- it's not cumulative, it's not collecting "points"- it's forgotten.

Ipfilter also has the ability to "keep state". According to the IPFILTER How-To referenced above, this is not simply a matter of watching the SYN flag (the SYN flag is set when a client first contacts a server and when the server first replies but not thereafter: therefore a packet coming from outside with SYN set is not part of an established connection that you originated); ipfilter really maintains a state table (which can be viewed with "ipfstat -s"). Given this understanding, the following set of rules should be close to self-explanatory:

MYIP=`ifconfig net0 | grep inet | awk '{ print $2 }'`/32
ipf -F a
ipf -f - <<EOF
block in log all
block in log on net0 all
pass out quick on net0 proto tcp/udp from $MYIP to any keep state
pass out quick on net0 proto icmp from $MYIP to any keep state

Looks good, doesn't it? This is taken directly from the How-To, and it's rather elegant in its simplicity. Obviously this would be very secure: everything except that which we originate is blocked.

Too bad it doesn't work.

The NAT also has an ftp proxy.

Search for "nat ftp proxy" for more on this.

Well, let's not be too hard on it- it does partially work. It definitely blocks everything we don't want, and it seems to let us get out. But it doesn't work well enough for real use. For example, you can't use ftp (unless it's passive) with this setup. You can't use the kind of secure ftp and pop I described in DSL and Cable Modem Security with SSH. And of course it definitely won't allow any service that you really do want your machine to provide to the outside world.

So this is where you have to start adding rules. The "ipmon" listings of log files can help you do that; if you log all blocked packets, you get to see why what you hoped would work didn't. In this case, it should be pretty obvious what the problem is: we're not letting anything in to this machine, even if we are the ones originating it. So, if we want to use the port forwarding techniques of the DSL and Cable Modem article, we need a different set of rules:

MYIP=`ifconfig net0 | grep inet | awk '{ print $2 }'`/32
ipf -F a
ipf -f - <<EOF
block in log all
block in log on net0 all
pass in quick on lo0 proto tcp/udp from to
pass out quick on net0 proto tcp/udp from $MYIP to any keep state
pass out quick on net0 proto icmp from $MYIP to any keep state

Of course, once you start down this path, you have to constantly check to make sure you haven't inadvertently opened up more that you wanted to. Therefore, I suggest that you still add the explicit blocks (with the "quick" keyword) that we started with. Explicitly block everything you know you never want to let through no matter what. If you keep your explicit blocks as the first rules, no surprises can come through later. If your other rules are rock solid, you haven't hurt anything with these.

While it may sound paranoid, comment unneeded services out of /etc/inetd.conf, too. On my home machine, I have absolutely nothing in inetd.conf- not a single uncommented line. You, of course, may need services that I don't.

Somebody once said ( or should have, if they didn't) "Security is not a destination; it is a journey". Let's hope that it's a pleasant journey for most of us. Tools like ipfilter can certainly make that more likely.

If this page was useful to you, please help others find it:  


More Articles by - Find me on Google+

Click here to add your comments
- no registration needed!

Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments

If you want a picture to show with your comment, go get a Gravatar

Kerio Connect Mailserver

Kerio Samepage

Kerio Control Firewall

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments

Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

I am a Kerio reseller. Articles here related to Kerio products reflect my honest opinion, but I do have an obvious interest in selling those products also.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.


This post tagged:

       - Networking
       - SCO_OSR5
       - Security

My Troubleshooting E-Book will show you how to solve tough problems on Linux and Unix systems!

book graphic unix and linux troubleshooting guide

Buy Kerio from a dealer
who knows tech:
I sell and support

Kerio Connect Mail server, Control, Workspace and Operator licenses and subscription renewals

Click and enter your name and phone number to call me about Kerio® products right now (Flash required)