System Tuning

This is paper 2 of 4 of my server series. The first paper Server FreeBSD Part 1 - Services and Updating talked about basic updates of your system. Now we get a little more complex in a leadup twords the final paper. Thanks bork for letting me post this here. Also please excuse my grammer. My English is not too good.

The topics we will be covering are in today's paper are:

2. System Tuning
2.1. sysctl
2.1.1. securelevel and chflags
2.1.2. performance
2.2. User management
2.2.1. adduser / rmuser / chpass / watch
2.2.2. Quotas and login.conf
2.2.3. Jail
2.3. File integrity


2. System Tuning

Now that our system is like new and one cannot update anything any more, it is time to start on some basic security and system policys. For that we initially will see what we can do by defect with the basic system in order to increase the safety of our system and to limit exposure to attacks.

2.1. sysctl

Sysctl is an extremely practical tool within FreeBSD since it will allow us of verify or to handle the state of the kernel. Information is stored and posted through a Management Information Base or MIB according to the same model as SNMP For example to post a list of the various variables of state kernel, it is enough for you to carry out simple

($:~)=> sysctl -a

same manner that you would use a ls. Note: that you can limit the entry of the MIB if you just know it after the option in order to post only it. According to the principle of the MIB, you can reduce posting by limit a field of the MIB For example to post all the entries in connection with IP

($:~)=> sysctl net.inet.ip.*

Also note that certain variables are not modifiable and that certain entries of the MIB are in the form of tables used on the occasion by PS, netsat or systat. Finally to obtain a list of the variables sysctl which you can modify, consult the page of handbook of sysctl.

2.1.1. securelevel and chflags

One of the functionalities of FreeBSD consists of the establishment of secure level within the system. There are thus 5 levels of security within FreeBSD which cannot be decreased without starting again init. They can however be increased by a process root via the MIB sysctl, and this same in the course of execution.

To define the securelevel set up by init, modify the following lines in rc.conf:

kern_securelevel_enable="YES"
kern_securelevel="N"

N represents the entirety here corresponding to the one of the 5 possible entrys. Replace it by the level which is appropriate to you. Then if you wish to raise it once your system initialized, modify the following entry sysctl:

($:~)=> sysctl -w kern.securelevel=N

In addition to limitations registered in the code kernel, therefore unchangeable, suitable for each one of them, each level also defines the possible operations on files flags, attributes of files making it possible to improve the safety provided by the traditional UNIX permissions. Below, 5 levels and their limitations:

By syncro
05 Dec 2003