FAST BUILD BOXES |
IN A BOX |
like this |
like this |
like this |
shutdown -r -F now
and let it reboot.
When it starts back up it will run "fsck" which is the conceptual equivalent
of "chkdsk /f" in the Windows world.
Ghost 2003 comes with SystemWorks 2003 or often comes with
motherboard software. Ghost 2003 also works in (the recommended) normal mode
but after the disk is cloned the boot record must be repaired on the
cloned drive by first booting to a rescue floppy.
There is other software out there that has the ability
to clone Linux hard drives. I’m just used to Ghost.
shutdown -r -F now
to repair
any potential problems.
For future reference:
http://www.us.debian.org/releases/sarge/debian-installer/ http://www.debian.org/distrib/netinst http://www.debian.org/releases/stable/i386/ch04s02.html.en |
Make a new directory on your Windows computer and call it 'debian' or
something. Then download the latest version of the Debian installer for "Sarge" and save it there. Go to: http://cdimage.debian.org/debian-cd/3.1_r2/i386/iso-cd/debian-31r2-i386-netinst.iso for the Debian 3.1 (Sarge, Stable) network installation CD, which I recommend. |
We are going to erase the hard drive so make sure you don't
have any data on it you might need.
Boot up the computer using the Installer CD or the Installer floppy #1. If you use the floppy to boot up, it will prompt you for the second floppy. I recommend the CD-ROM. The instructions below pertain to the CD-ROM method in the default "ask as few questions as possible" mode. To install the recommended 2.6.x version of the Linux kernel, type in: linux26 |
[Choose Language] This determines the language of the installer and picks a keyboard. This installation has only been tested with English - English |
[Choose country or region] Choose what is appropriate |
Unplug the Ethernet cable, we want DHCP to fail. |
[Select a keyboard layout] American English selects a standard qwerty keyboard |
[Module needed by your ethernet card] |
[!! Configure the network]
Network autoconfiguration failed We wanted this to happen, simply press: [Continue] On the next screen, choose the default of: [Configure network manually] |
[Configure the network] Plug the Ethernet cable back in (and make sure Num Lock is on!) [IP address:] 111.111.111.111 [Netmask:] 255.255.255.x [Gateway:] 333.333.333.333 [Name server addresses:] 444.444.444.444 555.555.555.555 [Hostname:] sfa [Domain name:] example.com
|
[!! Partition disks] Choose [Erase entire disk] [Partitioning scheme:] You are free to choose any of the three partitioning schemes provided but we need at least 1GB of space for each data partition. If you choose the [Desktop machine] or [Multi-user workstation] method of partitioning, ideally you would have 4GB or more for either the /var partition or the /var/spool partition respectively. If you are building this with a 1GB or 2GB drive (not recommended), choose [All files in one partition] For a larger drive choose: [Desktop machine] Then arrow up and change the "Mount point:" of partition "#6 logical" from /home to /var Here is an example of what the finished product could look like: IDE1 master (hda) - 10.0 GB Maxtor 5T010H1 hda1 #1 primary 2.8 GB ext3 / (bootable) (root partition) hda5 #5 logical 353.7 MB swap (swap partition) hda6 #6 logical 6.8 GB ext3 /varThe same drive using and modifying the [Multi-user workstation] partitioning scheme: It took me about 10 minutes of playing with the software to figure out how to modify what the partitioning software came up with, but this will provide a little better performance (due to reduced file fragmentation). You need a 6GB or larger drive and a little patience to do this. Change the mount point of "#1 primary" from / to /boot Change the mount point of "#5 logical" from /usr to / Change the mount point of "#6 logical" from /var to /var/lib (Enter manually) Delete both partitions #9 and #8, then recreate logical partitions #8 and #9 from the free space and change the mount points to what is illustrated below. Each data partition should be at least 1GB as shown. The /var/spool directory is where our mail queues will be, so it would be desirable to make it 3GB or larger. IDE1 master (hda) - 10.0 GB Maxtor 5T010H1 hda1 #1 primary 279.6 MB ext3 /boot (bootable) hda5 #5 logical 3.6 GB ext3 / (root) hda6 #6 logical 1.8 GB ext3 /var/lib hda7 #7 logical 386.6 swap swap hda8 #8 logical 1.0 GB ext3 /var/log hda9 #9 logical 3.0 GB ext3 /var/spoolOnce you have what you like, choose [Finish partitioning and write changes to disk] [Write changes to disk?] [Yes] |
[Installing the Debian base system] Wait.... [Install the GRUB boot loader to the master boot record?] If you would like the install the GRUB boot loader choose [Yes] If you would like the install the LILO boot loader [Tab] over and select [Go Back] Then select the 'Install the LILO boot loader...' [Finish the installation] Remove the CD or floppy when prompted, then hit [Continue] This will reboot. |
[Debian base system configuration] - Welcome to your new Debian system! [OK] |
[Time zone configuration] [Is the hardware clock set to GMT?] [NO] [Select your time zone:] Simply choose what is appropriate. |
[Password setup] This will ask for root's password and allow you to create a "normal" user and a password for that user. Watch your [Num Lock] status. Use really good passwords and don't forget them. Please add one, and just one, normal user here. If you plan on storing mail locally on this machine (not documented here), or even if you don't, create a user who's main purpose in life might be to hold root's mail. I suggest calling the user myroot or something similar. |
Make sure you are connected to the Internet
[Apt configuration] [Archive access method for apt:] Choose [http] then your [Mirror country] then a mirror near you. (mirrors.kernel.org works very well in the US) [HTTP proxy information] (configure if needed, otherwise leave unconfigured) |
[Debian software selection]
[Choose software to install:] Do not select anything here. Simply [Tab] over and select [Ok] |
[Configuring console data] IMPORTANT! choose "Don't touch keymap" You chose one earlier whether you knew it or not and choosing any keyboard here may remove the keyboard mapping and you may not be able to get it back without starting the installation over!!!!! |
[Configuring Exim v4 (exim4-config)]
[General type of mail configuration:] choose [no configuration at this time] [Really leave the mail system unconfigured?] [Yes] [Root and postmaster mail recipient:] The "normal" user we added earlier will display here. This is fine, so simply accept this. Since all mail will be relayed to another server, this setting will actually end up being ignored. However, if you configure your system to store mail locally, all of root's mail will be redirected to this "normal" user's mailbox. This is necessary because you typically cannot access root's mailbox remotely. |
[Debian base system configuration]
[Setup of your Debian system is complete] [OK] |
Once you get the login prompt, login as root and issue the following command:
apt-get install ntpdate
|
hwclock --systohc
|
dpkg-reconfigure locales
|
[Configuring locales] You use [PgUp] [PgDn] [up-arrow] [down-arrow] [tab] and [spacebar] to navigate and select. Your ISO-8859-x locale should already be selected. You can simply [Tab] over to [Ok]. The installer software correctly assumed I wanted en_US ISO-8859-1. I suggest you have this also (in addition to others if you require them). If you need to change the locale, or add additional locales, use the [arrow] [spacebar] and [tab] keys. I suggest you do NOT pick a UTF-8 locale. SpamAssassin and amavisd-new may have problems if you do. [Which locale should be the default in the system environment?] I suggest you do NOT choose [None], I suggest you choose [en_US] |
ls -l /etc/console This lists the contents of the /etc/console directory.
You should see a file named "boottime.kmap.gz"If you get "Total: 0" then we have no keymap file. If, and only if, we have no keymap file, run the command: dpkg-reconfigure console-data And choose [Select keymap from arch list] Follow the prompts that apply to you and when the program exits check again to see if there is now a file called "boottime.kmap.gz" in the /etc/console
directory.If the file is not there, reboot and try again. We cannot continue until a keymap file is installed. Worst case is we would have to start the installation over again! |
Once you are back at the shell prompt, reboot the system with [Ctrl][Alt][Delete] |
pwd (which means "print working directory"; it will reply with "/root") |
apt-get install libc6-dev dpkg-dev db4.3-util libdb4.3-dev libberkeleydb-perl vim lynx ncftp bzip2 unzip perl-doc libwww-perl ntp-simple zlib1g-dev unzoo arj zip lzop nomarch arc zoo unarj ftp lsof less libdbi-perl libmail-spf-query-perl libconvert-binhex-perl gcc make autoconf automake1.7 libtool flex bison libldap2 libcompress-zlib-perl dnsutils rblcheck pax libmail-spf-query-perl libdbi-perl libnet-ident-perl cabextract libio-socket-ssl-perl
|
apt-get remove ipchains lpr nfs-common portmap pidentd pcmcia-cs
pppoe pppoeconf ppp pppconfig uw-imapd qpopper mailagent |
i
",
(short for "insert"). You can edit text pretty much as you would expect in
Write mode. You exit out of Write mode and return to Command mode by hitting
the [Esc] key. There are many commands that can be learned in Command mode but
we only need to learn two more in addition to "i
". Those commands
are ":
" (a colon) and "/
" (a forward slash). The
colon is used to enter the third mode, the Command line mode and the slash
enables the Search command. When you are in Command line mode, you will see a
colon at the bottom of the screen. Here is a list of commands we will use while
in Command line mode:
:q
quit (provided you have not made any changes) By the way,
the lower case q is used often in *nix as a way to exit a screen. :q!
exits vi and discards changes (great when you trashed the
file and just want to start over!) :wq
saves the changes and exits vi (write and quit) :w
saves the current changes but does not exit vi (write) G
The capital "G" Goes to the bottom of the page (very handy)
/text_to_search_for
moves the cursor to the first occurrence of
text_to_search_for
Run this to see which program vi points to:
ls -l /etc/alternatives/vi
If it says it is pointing to nvi or other program instead of vim (like this): /etc/alternatives/vi -> /usr/bin/nvi Then we need to fix it so it points to (symbolically links to) vim:
mv /etc/alternatives/vi /etc/alternatives/nvi
If you run this again:
ls -l /etc/alternatives/vi
You should see that it now links to vim. |
vi /etc/resolv.conf Make sure our domain name is at the top, in the form: search example.com The file should look something like: search example.com nameserver 444.444.444.444 nameserver 555.555.555.555 Repair it if it is not. (Use "i", then edit it) remember - the numeric keypad is useless. If you made changes, Exit the file with [Esc] : wq If you did not need to change anything, Exit the file with [Esc] : q
|
vi /etc/hosts The top of file should look something like: 127.0.0.1 localhost.localdomain localhost 111.111.111.111 sfa.example.com sfaRepair it if it does not (localhost.localdomain is not strictly required). Remember, use "i" to insert and don't use the numeric keypad. If the hostname "sfa" is listed on both lines, remove it from the 127.0.0.1 line. Since we are here, you might as well add any other hosts you would like our spamfilter to know about. I suggest you (at least) put your internal mail server(s) here. Simply append any other entries to the bottom of the list. If you made changes, Exit the file with [Esc] : wq If you did not need to change anything, Exit the file with [Esc] : q If you have a mess on your hands, Exit the file with [Esc] : q! and try again.
|
reboot logout |
shutdown -h now
apt-get update
(to update the local database of available
packages) followed by apt-get upgrade,
to install the
latest version of any and all packages it found on our system. This is fine because
we are using the "stable" version of Debian, but you should not upgrade your system
or install packages indiscriminately, especially if you use any packages from
the "testing" or "unstable" branches. This could make stuff stop
working. Fortunately there is something called "Apt-Pinning" that enables us to
prioritize the order of "stable", "testing", and "unstable" software sources. This file
has to be created by us.
The most succinct explanation of this can be found at
http://jaqque.sbih.org/kplug/apt-pinning.html. If you ever use "apt-get upgrade",
I strongly recommend using
apt-get -s upgrade
to "simulate" the upgrade process
before you actually upgrade.
vi /etc/apt/preferences |
Enter this text in the file ("i" to insert) EXACTLY as shown. Yes, you can select the text with your mouse, hit [Ctrl]+c , and then right-click in the vi editor window.
Package: *
Exit the file with [Esc] : wq as usual.
|
apt-get -s install [package]
before you install any package. It lets you "simulate" what would happen.
If you want a package that is an
"unstable" or "testing" version, you would have to specifically request the "unstable"
or "testing" version or change the priority before you install it (unless the only version
is "unstable" or "testing" or your current version is "unstable" or "testing"). For example
apt-get -t unstable install [package].
If you use tools like
tasksel, you may have to temporarily change the priority prior to installing a
new set of packages. The most stable situation is to only upgrade to new
packages if a security flaw is found and make sure you have the ability to
completely restore the hard drive if upgrades don't go well. So I don't
frighten you too much, the Debian package maintainers are amazing, so apt-get usually works very well.
apt-cache
to search the local database for
available packages. apt-cache search [search terms]
will find packages that
sound like what you want and: apt-cache show [packagename]
will return more details
on a particular package. apt-cache showpkg [packagename]
will return more
details on a particular package. apt-cache policy [packagename]
will return which
versions are available along with the priority of each version. apt-setup
will enable you to change mirrors. The
alternative is to edit /etc/apt/sources.list
manually (which I prefer). apt-get clean
clears the local repository of all retrieved
package files. apt-get autoclean
clears the local repository of retrieved
package files of programs that are no longer installed. dpkg -l [packagename]
will list the version and a short
description of the package we have installed.
cp /etc/apt/sources.list /etc/apt/sources.backup
This creates a backup file. Then: vi /etc/apt/sources.list |
At this point, the contents of the file look something like this:
#deb file:///cdrom/ sarge main deb http://mirrors.kernel.org/debian/ stable main deb-src http://mirrors.kernel.org/debian/ stable main deb http://security.debian.org/ stable/updates main We need to modify this file so the result will look something like this: (with only the http server unique to your particular system) deb http://mirrors.kernel.org/debian/ stable main non-free contrib deb-src http://mirrors.kernel.org/debian/ stable main deb http://security.debian.org/ stable/updates main deb http://mirrors.kernel.org/debian/ testing main non-free contrib deb-src http://mirrors.kernel.org/debian/ testing main deb http://mirrors.kernel.org/debian/ unstable main non-free contrib deb-src http://mirrors.kernel.org/debian/ unstable main Note what I have done here: The line #deb file:///cdrom/ sarge main has been erased. ([up-arrow] to the top of the file and hold down the [Delete] key.) The 4 bottom lines have been copied from the top 2 lines, and then modified slightly as indicated. The words "non-free" and "contrib" have been added to 3 of the lines. You are welcome to simply copy and paste what I have listed above. Save and exit the file. |
apt-get update
|
apt-get install lha unrar
|
less
. less
is a great file
and directory viewer.
less
.
less
: less /path/file
less
:
ls -l | less
(current directory, or)
ls -l /path/directory | less
history | less
locate
.
locate
allows you to search a database of every file name on the
system.
updatedb
command, and then you can search through it.
locate
and less
together:
updatedb
locate kmap | less
less
/usr/share/keymaps/i386/qwerty/
cd
cd
and hit [return]. We just saved ourselves
having to type the entire path name just in order to change to that directory.
I like that.
cd
to get back home.
iptables -F
|
iptables -L |
vi /etc/network/interfaces And insert the following text (remember, it's "i" to insert) in the blank line just below "iface lo inet loopback": pre-up iptables-restore < /etc/firewall-rules
Save and exit the file as usual with [Esc] : wq From now on I will assume you know how to edit, save, and exit files using vi. If not stated, it will be implied that after editing a file, you need to save and exit it, or if necessary, discard changes and start over. |
If you have not done so, reboot again and runiptables -L to verify the firewall loaded during start up. |
iptables -F
from the
console to clear out iptables. This will allow you another shot at it.
top
ps afx
ps afxl
ps -A
ls -F /etc/rc2.d
lsof -i | grep LISTEN
grep -v "^#" /etc/inetd.conf | sort -u
netstat -pn -l -A inet
netstat -pn -l inet
cd /usr/bin
wget http://verchick.com/mecham/public_html/debian/lsconfig
chmod +x /usr/bin/lsconfig
lsconfig
cp -r /etc/init.d /etc/init.d-original |
/etc/init.d/lpd stop
|
update-inetd --disable time
|
/etc/init.d/inetd restart
|
lsof -i | grep LISTEN
The only daemon you should see is at this point is *:ssh You may have to run this again: update-inetd --disable discard If there are other programs shown, try rebooting and test again. |
update-inetd --enable ident
/etc/init.d/inetd restart
update-rc.d lpd defaults
/etc/init.d/lpd start
cp -i /etc/init.d-original/lpd /etc/init.d
update-rc.d lpd defaults
/etc/init.d/lpd start
/etc/ntp.conf
and
insert it per the example in the file. NTP is a flexible and complex system so I leave
it up to you to research it further if you care to.
/etc/ntp.conf
:
/etc/init.d/ntp-server stop
ntpdate clock.fmt.he.net
ntpdate ntp1.tummy.com
/etc/init.d/ntp-server start
date
and to change the time zone it's tzconfig
apt-get upgrade
|
If the kernel is upgraded, once the upgrade process is complete, you must:
reboot
|
cd /usr/local/src
If all goes well, the last thing you will see is: "Appending installation info to /usr/local/lib/perl/5.8.4/perllocal.pod" |
To avoid any compatibility problems with Net::Server, please read this:
http://verchick.com/mecham/public_html/spam/net-server.html
|
apt-cache policy postfix spamassassin amavisd-new
|
postfix: Installed: (none) Candidate: 2.1.5-9 Version Table: 2.2.10-1 0 400 http://mirrors.kernel.org unstable/main Packages 2.2.4-1.0.1 0 450 http://mirrors.kernel.org testing/main Packages 2.1.5-9 0 600 http://mirrors.kernel.org stable/main Packages spamassassin: Installed: (none) Candidate: 3.0.3-2 Version Table: 3.1.0a-2 0 450 http://mirrors.kernel.org testing/main Packages 400 http://mirrors.kernel.org unstable/main Packages 3.0.3-2 0 600 http://security.debian.org stable/updates/main Packages 600 http://mirrors.kernel.org stable/main Packages amavisd-new: Installed: (none) Candidate: 20030616p10-5 Version Table: 1:2.3.3-2 0 400 http://mirrors.kernel.org unstable/main Packages 20030616p10-5 0 600 http://mirrors.kernel.org stable/main Packages 450 http://mirrors.kernel.org testing/main PackagesThis tells us there are newer versions of Postfix available in the "testing" and "unstable" branches. Once we have completed our setup, you can optionally upgrade to the newer version by simply installing it using "apt-get -t testing install [list of packages]". Note that if you decide to install the testing version of Postfix, some other important system files will also get upgraded to the testing version (notably libc6, libc6-dev and locales). When mixing testing with stable, there is always some potential of future problems with program dependencies, but generally, Debian is very smart about these issues. The more cautious person would not upgrade. I have experienced problems with new versions of libc6 when using a 2.4 version of the Linux kernel. I had to upgrade to a 2.6 kernel to solve the problem. The report shows there is a newer version of SpamAssassin available. We can also upgrade SpamAssassin to the new version once our install is done, or you can install the new 3.1 version now. It shows us there is an unstable version of amavisd-new available, but we are NOT going to install it. The configuration files for that new Debian version are not consistent with the typical way amavisd-new is configured. Instead of one configuration file, this new version splits the configuration files into half a dozen files in a couple different directories. We will instead install an old version of amavisd-new. We need to install this old version via apt-get because it creates the amavis user and group, installs several scripts for startup and maintenance, creates the directory structure and installs other ancillary files. We will manually install the author's version 2.4.2 of amavisd-new over the top of 20030616-p10. So with this in mind:
apt-get -t stable install amavisd-new
apt-get install razor pyzor
If you would like to install the newer version of spamassassin: apt-get install spamassassin/testing
Otherwise: apt-get install spamassassin
apt-get install postfix postfix-pcre postfix-mysql postfix-ldap
|
Debconf will pop up a Postfix configuration screen. For [General type of configuration?] select: No configuration |
mkdir /root/.spamassassin mkdir /var/lib/amavis/tmp mkdir /var/lib/amavis/db mkdir /var/lib/amavis/var chown -R amavis:amavis /var/lib/amavis chmod -R 750 /var/lib/amavis ln -s /etc/amavis/amavisd.conf /etc/amavisd.conf
|
Now we will replace our (currently unconfigured) amavisd-new version 20030616-p10
with version 2.4.2.
amavisd-new stop
To prevent the Debian version of amavisd-new from installing over our custom one when we run 'apt-get upgrade', place the package on hold: echo "amavisd-new hold" | dpkg --set-selections |
cd /usr/local/src wget http://ftp.debian.org/debian/pool/main/p/postfix/postfix_2.1.5.orig.tar.gz tar xzvf postfix_2.1.5.orig.tar.gz
|
ls -l |
rm postfix* |
The second line below will need to be edited if you have a different version of
the Postfix source code. MAKE SURE you answer "n" to "overwrite?" Do each section separately. cp -i /usr/share/postfix/main.cf.debian /etc/postfix/main.cf
cp -i /usr/local/src/postfix-2.1.5/conf/* /etc/postfix
cp -i /etc/postfix/header_checks /etc/postfix/body_checks
cp -i /etc/postfix/access /etc/postfix/sender_access
|
The master.cf we download here can be used with Postfix versions 2.3.x, 2.2.x and 2.1.x postfix stop
cd /etc/postfix
mv master.cf master.cf-original
wget http://verchick.com/mecham/public_html/debian-postfix-2.2-amavisd/master.cf
|
postfix stop vi /etc/postfix/master.cf
|
Add these lines near the bottom of master.cf. Note: the items on these lines are separated by tabs. And the "-o" is the lower case letter o, not zero. These settings are from http://www.ijs.si/software/amavisd/README.postfix. You can copy and paste this entire section once the cursor is in the correct position (see below) and you are in insert mode. Note: when copying sections like this that contain tabs, rather than using a right click of the mouse to paste into the editor, press [Shift]+[Insert]: |
smtp-amavis unix - - - - 2 smtp -o smtp_data_done_timeout=1200 -o smtp_send_xforward_command=yes -o disable_dns_lookups=yes -o max_use=20 127.0.0.1:10025 inet n - - - - smtpd -o content_filter= -o local_recipient_maps= -o relay_recipient_maps= -o smtpd_restriction_classes= -o smtpd_delay_reject=no -o smtpd_client_restrictions=permit_mynetworks,reject -o smtpd_helo_restrictions= -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,reject -o smtpd_data_restrictions=reject_unauth_pipelining -o smtpd_end_of_data_restrictions= -o mynetworks=127.0.0.0/8 -o smtpd_error_sleep_time=0 -o smtpd_soft_error_limit=1001 -o smtpd_hard_error_limit=1000 -o smtpd_client_connection_count_limit=0 -o smtpd_client_connection_rate_limit=0 -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks |
Add this just below the 'pickup' service type:
-o content_filter= -o receive_override_options=no_header_body_checks |
# ========================================================================== # service type private unpriv chroot wakeup maxproc command + args # (yes) (yes) (yes) (never) (100) # ========================================================================== smtp inet n - - - - smtpd #submission inet n - - - - smtpd # -o smtpd_etrn_restrictions=reject # -o smtpd_client_restrictions=permit_sasl_authenticated,reject #smtps inet n - - - - smtpd # -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes #submission inet n - - - - smtpd # -o smtpd_etrn_restrictions=reject # -o smtpd_enforce_tls=yes -o smtpd_sasl_auth_enable=yes #628 inet n - - - - qmqpd pickup fifo n - - 60 1 pickup -o content_filter= -o receive_override_options=no_header_body_checks cleanup unix n - - - 0 cleanup qmgr fifo n - n 300 1 qmgr #qmgr fifo n - - 300 1 oqmgr tlsmgr unix - - - 1000? 1 tlsmgr rewrite unix - - - - - trivial-rewrite bounce unix - - - - 0 bounce defer unix - - - - 0 bounce trace unix - - - - 0 bounce verify unix - - - - 1 verify flush unix n - - 1000? 0 flush proxymap unix - - n - - proxymap smtp unix - - - - - smtp # When relaying mail as backup MX, disable fallback_relay to avoid MX loops relay unix - - - - - smtp -o fallback_relay= # -o smtp_helo_timeout=5 -o smtp_connect_timeout=5 showq unix n - - - - showq error unix - - - - - error discard unix - - - - - discard local unix - n n - - local virtual unix - n n - - virtual lmtp unix - - - - - lmtp anvil unix - - - - 1 anvil scache unix - - - - 1 scache # smtp-amavis unix - - - - 2 smtp -o smtp_data_done_timeout=1200 -o smtp_send_xforward_command=yes -o disable_dns_lookups=yes -o max_use=20 127.0.0.1:10025 inet n - - - - smtpd -o content_filter= -o local_recipient_maps= -o relay_recipient_maps= -o smtpd_restriction_classes= -o smtpd_delay_reject=no -o smtpd_client_restrictions=permit_mynetworks,reject -o smtpd_helo_restrictions= -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,reject -o smtpd_data_restrictions=reject_unauth_pipelining -o smtpd_end_of_data_restrictions= -o mynetworks=127.0.0.0/8 -o smtpd_error_sleep_time=0 -o smtpd_soft_error_limit=1001 -o smtpd_hard_error_limit=1000 -o smtpd_client_connection_count_limit=0 -o smtpd_client_connection_rate_limit=0 -o receive_override_options=no_header_body_checks,no_unknown_recipient_checks |
/etc/postfix/main.cf
the main
configuration file for Postfix. Following are suggested values to use in
main.cf. These have been tested for this configuration and will work fine, but
there are many judgment calls involved in this, and it is a good idea at some
point to learn more about Postfix configuration, on your own. You could first
look at the sample Postfix main.cf file /usr/share/postfix/main.cf.dist
. There are comments describing some of the most common options.
Refer also to the Postfix documents on your machine in the
/usr/local/src/postfix-2.1.5/README_FILES
directory, or
read the documentation on the Postfix web site
http://www.postfix.org/documentation.html. I also recommend
http://www.postfix-book.com/.
postmap
command to create binary files (Berkeley DB format) that Postfix will ultimately use to
retrieve the data. For example, if you have a file called "filename" and you "postmap filename",
a new file is created "filename.db". Postfix will retrieve data from "filename.db", not
"filename".
There are more than a dozen other types of data files that Postfix
can use to store data. Hash tables are an appropriate choice for
several tables we will use, and pcre (Perl Compatible Regular Expressions)
is appropriate for a couple tables we will use to hold content filtering data.
In its simplest form a hash table is comprised of 2 pieces of data,
a key and a value; typically referred to as the key/value pair. The key
and the value are separated with whitespace (typically a space or tab).
The data in a typical table that we use in Postfix would look something like:
postconf -e "alias_maps = hash:/etc/aliases"
|
newaliases
now, and every time after you edit the aliases file. The
newaliases
command is just like postmap
except that it's
specific to the aliases file.
newaliases
|
postconf -e "myorigin = example.com" |
postconf -e "myhostname = sfa.example.com" |
Please read important notes above.postconf -e "mynetworks = 127.0.0.0/8, 222.222.222.222/24, 10.10.10.10/24"
|
postconf -e "message_size_limit = 10485760" |
postconf -e "local_transport = error:no local mail delivery" |
postconf -e "mydestination = " |
postconf -e "local_recipient_maps = " |
Set up a reference to the virtual file:postconf -e "virtual_alias_maps = hash:/etc/postfix/virtual" Then edit the virtual file: vi /etc/postfix/virtual and add postmaster and admin in the format:
postmaster postmaster@example.com
Save and exit the file, then create the binary file that Postfix will use:postmap /etc/postfix/virtual |
postconf -e "relayhost = [666.666.666.666]" |
Set up a reference to a file we will create to store the data:postconf -e "relay_recipient_maps = hash:/etc/postfix/relay_recipients"
Then edit that file: vi /etc/postfix/relay_recipients
For the moment, we are going to accept mail for all users in our domain(s) so enter each domain you accept mail for in the format:
@example.com OK
Then create the binary file that Postfix will use: postmap /etc/postfix/relay_recipients The entries above are temporary. They are wildcards that allow mail to your domains. You MUST remove the entries above at some point in the near future and replace them with every single one of your valid recipients' email addresses. When you are ready to enter each user individually in the relay_recipients file, you would first remove (or comment out) the data above that allows mail to all users in the domain, and then list each user individually in the form: user1@example.com OK user2@example.com OK user3@example.com OK |
/etc/postfix/transport
and we
will set it up in similar fashion to relay_recipients.
Create a reference to it in main.cf: postconf -e "transport_maps = hash:/etc/postfix/transport"
Then edit it: vi /etc/postfix/transport
Add 1 new line for each domain for which you will be handling mail, similar to the example below. The IP address is that of whatever server is the final destination of messages addressed to our domain(s) (our Exchange server). It does not matter where you place these items in the file, but I like to put them at the top. example.com smtp:[666.666.666.666]
(DO include the brackets on these lines!) You can also use a FQDN hostname instead of an IP address (i.e. smtp:[exchange.example.com]). Then create the binary file Postfix will use: postmap /etc/postfix/transport |
postconf -e "relay_domains = example.com, example2.com, example3.com"
|
recipient_delimiter
should be set to match the delimiter you are currently using to
separate the user name from the address extension. Amavisd-new
also uses $recipient_delimiter
and this setting needs to match the
Postfix setting. This has nothing to do with the comma you are using to separate
multiple people you send email to (user1@example.com, user2@example.com, user3@example.com)
using your email client (MUA).
Typical settings - Choose one I Don't use recipient delimiters: postconf -e "recipient_delimiter = "
I currently use the plus sign: postconf -e "recipient_delimiter = +"
I currently use the minus sign: postconf -e "recipient_delimiter = -"
|
If (and only if) the IP address you present to the world is not the IP
address of your spamfilter (you are configured to run behind a NAT firewall
or a proxy server) please add these two lines to main.cf, then you must
uncomment and configure proxy_interfaces (1.2.3.4 represents the public
IP address):# Specify your NAT/proxy EXTERNAL address here. |
postconf -e "smtpd_helo_required = yes" |
SMTP session | V restriction stage------------- test ---------------REJECT-> | \ | DUNNO | \ | V | next test------REJECT-> | | \ OK OK DUNNO | | \ | | V V V next restriction stage------- |
postconf -e "smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender_access,
reject_non_fqdn_sender, reject_unknown_sender_domain" |
postconf -e "smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination, reject_unauth_pipelining"
|
postconf -e "smtpd_data_restrictions = reject_unauth_pipelining"
|
/^Received: from localhost \(localhost\.localdomain \[127\.0\.0\.1\]\)/ IGNORE
-o receive_override_options=no_header_body_checks,no_unknown_recipient_checks
Optional: postconf -e "header_checks = pcre:/etc/postfix/header_checks" |
Optional: postconf -e "body_checks = pcre:/etc/postfix/body_checks" |
postconf -e "content_filter = smtp-amavis:[127.0.0.1]:10024" |
vi /etc/postfix/sender_access |
#Example sender access map file
makeabuck@mlm.tld 550 No MLM thanks
allspam.tld 550 Spam is not accepted here
badguy.net REJECT
justaspamminfool@allspamallthetime.com REJECT
newsletter-fake-domain.com OK
my-bogus-test-domain.com OK
postmap /etc/postfix/sender_access |
vi /etc/postfix/main.cf Check the contents of the file for errors and repair if needed. You will probably want to edit relay_domains and mynetworks. |
postfix start |
telnet 127.0.0.1 25 You should see: 220 sfa.example.com ESMTP Postfix (Debian/GNU) hit [enter] a few times; then type: quit to exit |
postfix stop
). Make sure you ran newaliases
and all the postmap commands above. Check all the settings in main.cf and master.cf.
There is a nice paper on troubleshooting Postfix at
http://www.postfix-book.com/debugging.html but keep in mind our system is not
ready to relay mail at this point (it will end up in the queue because we
have not yet configured amavisd-new).
postfix reload |
cd p
then hit the [tab] key and
the bash shell will fill the remainder in with the first unambiguous item. If there
is more than one item, you can hit the [tab] key twice and it will list all the available
items.cd p[tab] e[tab]
c[tab][enter]
cd /usr/local/src This next line may be edited for a different version of postfix: cd postfix-2.1.5/examples/chroot-setup postfix start chmod +x LINUX2 cp LINUX2 /usr/bin LINUX2 cd You can check if Postfix is happy: postfix check |
Additional anti-UCE settings for our Debian Anti-Spam Anti-Virus Gateway Email Server
|
cp /etc/amavis/amavisd.conf /etc/amavis/amavisd.conf-2.4.2-original |
Either: vi /etc/amavis/amavisd.conf
or use the WinSCP editor to edit this file. |
Move to the line that begins with:# @bypass_virus_checks_maps = (1); And uncomment by removing the "#" symbol at the beginning of this line. |
Insure the amavis user and group are set like so:
$daemon_user = 'amavis';
Locate the line that begins with $mydomain:$mydomain = 'example.com';
and change to reflect the actual name of our domain. Next, uncomment # $myhostname and change it to our host's FQDN:$myhostname = 'sfa.example.com';
|
Locate this next line:@local_domains_maps = ( [".$mydomain"] ); Comment out that line, then add a new one just like it with all your domains listed in it. Like this: @local_domains_maps = ( [ ".$mydomain", '.example2.com', '.example3.com' ] );
Or like this: @local_domains_maps = ( [qw( .example.com .example2.com .example3.com )] );
Yes, you need those periods there, and don't forget the semi-colon at the end. Note that in Perl, single quotes and double quotes work differently from each other. |
Next are these two lines, uncomment both of them:# @mynetworks = qw( 127.0.0.0/8 [::1] [FE80::]/10 [FEC0::]/10 # 10.0.0.0/8 172.16.0.0/12 192.168.0.0/16 ); # defaultThen edit the second line, replacing entries on the second line with your network(s). These should be the same network(s) you have listed in the Postfix "mynetworks" setting: @mynetworks = qw( 127.0.0.0/8 [::1] [FE80::]/10 [FEC0::]/10 222.222.222.222/24 10.10.10.10/24 ); # default |
Change$sa_tag_level_deflt = 2.0; to $sa_tag_level_deflt = undef; This will insure all mail addressed to domains in @local_domains will get a spam score in the header, spam or not. Change $sa_tag2_level_deflt = 6.31; to $sa_tag2_level_deflt = 5.0; This low number is assuming your email clients do not automatically discard spam. Set this to 8.0 or higher if they do. The Subject line will be prepended with "Spam> " for any mail that scores above $sa_tag2_level_deflt and is passed to a recipient. Change $sa_kill_level_deflt = 6.31; to $sa_kill_level_deflt = 8.0; On our system, this will trigger the spam to be quarantined if it scores 8.0 or higher. If you plan on deleting the spam, set this at 12.0 or higher. If you only want spam tagged and sent to the recipients (not quarantined at all), set this at 9999 (this would be for ISPs and large companies that configure the MUAs to further process spam). |
/etc/cron.d/amavisd-new
and
/etc/cron.daily/amavisd-new
.
Note that when these cron jobs are running, the Bayes files will at times be
inaccessible. If you happen to see in a log file that SpamAssassin has timed out,
this could be one possible reason.
Now find:$virus_admin = "postmaster\@$mydomain"; The default is fine, but you may wish to change it. Now add a line for banned file notifications: $banned_admin = "postmaster\@$mydomain"; |
Next, locate this section:
$mailfrom_notify_admin = "virusalert\@$mydomain"; $mailfrom_notify_recip = "virusalert\@$mydomain"; $mailfrom_notify_spamadmin = "spam.police\@$mydomain";and change it to: $mailfrom_notify_admin = "postmaster\@$mydomain"; $mailfrom_notify_recip = "postmaster\@$mydomain"; $mailfrom_notify_spamadmin = "postmaster\@$mydomain";Just below this, remove the '#' to uncomment this line: # $hdrfrom_notify_sender = "amavisd-new <postmaster\@$mydomain>";
|
Next, locate # $recipient_delimiter . You set recipient_delimiter
in Postfix and the setting in this file needs to be set similarly. This is
typically set to one of these three options:
$recipient_delimiter = ''; # No recipient delimiter (this is the default)or $recipient_delimiter = '+'; or $recipient_delimiter = '-'; Change: #$sa_spam_subject_tag = '***SPAM*** '; to $sa_spam_subject_tag = 'Spam> '; The longer version simply takes up too much real estate on the subject line. |
The next line I would like to change begins with:$final_spam_destiny = D_BOUNCE; Change this to: $final_spam_destiny = D_DISCARD; |
$spam_quarantine_to = undef;
and the email with a SpamAssassin kill score of 12 or higher would evaporate
into thin air, or you could configure $sa_quarantine_cutoff_level.
But don't do this; at least not yet. Setting
$spam_quarantine_to = undef;
essentially
means "we don't have a spam quarantine area so I guess I have to just dump the
mail". This is something you probably should not implement at first; at least not if you
enjoy being employed.
If you decide to do this, I suggest you wait
a month or so to get a feel for the system (and let the
Bayes
database initialize). You can eliminate about
90% of the email that ends up in the "spam-bin" by using this suggestion.
Next, locate the line that looks like this: $virus_quarantine_to = 'virus-quarantine'; I suggest you do one of three things here. You can leave this alone, and viruses will be quarantined on the spamfilter box, or you can set this to: $virus_quarantine_to = undef; and provided we configure a virus scanner, all caught viruses will disappear, or you can send caught viruses to a regular mailbox: $virus_quarantine_to = "virii\@$mydomain";
You can choose to use "spam-bin" for the quarantine area for all spam, viruses and email with banned attachments, but I recommend you create separate mailboxes for each. |
Next, locate the $banned_quarantine_to line and configure these
three lines in this manner: $banned_quarantine_to = "banned\@$mydomain"; $bad_header_quarantine_to = "banned\@$mydomain"; $spam_quarantine_to = "spam-bin\@$mydomain"; Make sure you have mailboxes for these two addresses on a destination server. This is where you will review quarantined email, and if ham is found, will forward the ham to the proper recipient. |
Locate this block inside the $banned_filename_re = new_RE section:qr'.\.(exe|vbs|pif|scr|bat|cmd|com|cpl)$'i, # banned extension - basic # qr'.\.(ade|adp|app|bas|bat|chm|cmd|com|cpl|crt|emf|exe|fxp|grp|hlp|hta| # inf|ins|isp|js|jse|lnk|mda|mdb|mde|mdw|mdt|mdz|msc|msi|msp|mst| # ops|pcd|pif|prg|reg|scr|sct|shb|shs|vb|vbe|vbs| # wmf|wsc|wsf|wsh)$'ix, # banned ext - long # qr'.\.(mim|b64|bhx|hqx|xxe|uu|uue)$'i, # banned extension - WinZip vulnerab. qr'^\.(exe-ms)$', # banned file(1) types # qr'^\.(exe|lha|tnef|cab|dll)$', # banned file(1) typesIf you would like to greatly extend the types of attachments amavisd-new bans, you might want to comment out, and uncomment some lines like so: # qr'.\.(exe|vbs|pif|scr|bat|cmd|com|cpl)$'i, # banned extension - basic qr'.\.(ade|adp|app|bas|bat|chm|cmd|com|cpl|crt|emf|exe|fxp|grp|hlp|hta| inf|ins|isp|js|jse|lnk|mda|mdb|mde|mdw|mdt|mdz|msc|msi|msp|mst| ops|pcd|pif|prg|reg|scr|sct|shb|shs|vb|vbe|vbs| wmf|wsc|wsf|wsh)$'ix, # banned ext - long qr'.\.(mim|b64|bhx|hqx|xxe|uu|uue)$'i, # banned extension - WinZip vulnerab. qr'^\.(exe-ms)$', # banned file(1) types qr'^\.(exe|lha|tnef|cab|dll)$', # banned file(1) typesJust edit out the attachment types you would like to receive or edit in any others you would like to ban. Each vertical bar means "or". I would add bin|drv|mht|ocx|ovl| If you receive
mail from people using Outlook in Rich Text mode, you may need to
remove |tnef When an email that has one of these attachments comes into the system, the entire message gets placed in quarantine and the sender and postmaster get notified. Using this feature of amavisd-new goes a very long way toward preventing email borne viruses from entering your network. This method should not be your only line of defense however, just another tool in your arsenal. |
Next, locate the # ENVELOPE SENDER SOFT-WHITELISTING / SOFT-BLACKLISTING section. |
Save the file with [Esc]:wq and exit vi. Then
make a backup:cp /etc/amavis/amavisd.conf /etc/amavis/amavisd.conf-09apr06 I have a habit of using the date for my backups. |
$max_servers = 2;
$max_servers = 4;
smtp-amavis unix - - - - 2 smtp
smtp-amavis unix - - - - 4 smtp
Optionally disable logging to /var/log/mail.info:vi /etc/syslog.conf
and comment out the mail.info line, like so: #mail.info -/var/log/mail.info |
Optional: If you would like to enable the external template files so you may customize them in the future (English only): vi /etc/amavis/amavisd.conf
and uncomment the line: # read_l10n_templates('en_US', '/etc/amavis');
Then replace the outdated files with more recent ones, begin by making a backup copy of the old ones: cp -r /etc/amavis/en_US /etc/amavis/backup-en_US
Then remove the old files and install new files that I have created:
cd /etc/amavis/en_US
|
amavisd-new stop amavisd-new debug |
Use the [Ctrl]+c key combination to exit (kill) amavisd-new debug. |
chmod -R a+rX /usr/share/doc/pyzor /usr/bin/pyzor
/usr/bin/pyzord This next line will have to be modified if you have a different version of python. Try locate pyzor (may need to run
updatedb first)chmod -R a+rX /usr/lib/python2.3/site-packages/pyzor
(It might be):
chmod -R a+rX /usr/lib/site-python/pyzor
Here we supply the IP address of the Pyzor server to Pyzor (for both the 'root'
and 'amavis' users). This will create a .pyzor directory in both user's
home directories, and place the server's IP address in a 'servers' file therein:
pyzor discover
Test the pyzor server for a response: pyzor ping su amavis -c 'pyzor ping' If in the future the IP address of the server changes, you will need to run the two 'pyzor discover' commands again. I suggest you subscribe to http://lists.sourceforge.net/lists/listinfo/pyzor-announce |
amavisd-new debug-sa
you would notice that amavis expects to
find programs and configuration files in certain places. If you were to run
spamassassin --lint -D
as root you would notice that
root expects to find the same things, but it expects to find them
somewhere other than where the amavis user expects. SpamAssassin is designed to enable each
user to have their own settings and data. This section will make both users happy,
and the reason we want to do this is because if we are debugging SpamAssassin
or Razor or Pyzor or DCC, we want to be able to do so with
spamassassin --lint -D
rather than amavisd-new debug-sa
because we don't want to shut amavisd-new down every time we need to debug one of
those programs. A better way to debug SpamAssassin is to run the program as the
amavis user like so: su amavis -c 'spamassassin --lint -D'
spamassassin --lint -D |
cp -ir /root/.spamassassin /root/.spamassassin-backup
Please answer 'n' to "overwrite?": cp -ir /root/.spamassassin /var/lib/amavis
|
rm /root/.spamassassin/user_prefs ln -s /var/lib/amavis/.spamassassin/user_prefs /root/.spamassassin/user_prefs |
sa-learn --force-expire
or spamassassin --lint -D
from the root
account, SpamAssassin may change the owner of the Bayes files to 'root'.
If it does, amavis will no longer be able to read those files.
You would need to run
chown -R amavis:amavis /var/lib/amavis
to regain ownership.
In general, if you do any spamassassin maintenance from the
command prompt as root, the best thing to do is run
chown -R amavis:amavis /var/lib/amavis
afterwards;
just to make sure.
You can avoid these problems by remembering to run
spamassassin commands as the amavis user. For example
su amavis -c 'sa-learn --sync --force-expire'
cd rm /etc/razor/razor-agent.conf razor-admin -create razor-admin -register
If you get an error, you may need to run these razor-admin commands more than once. Don't worry about it if /etc/razor/razor-agent.conf does not exist. Now edit root's razor configuration file: vi /root/.razor/razor-agent.conf
and change the line:
debuglevel = 3
to:
debuglevel = 0
Obviously -zero- not -oh-; Save and exit the file. OK, now copy root's .razor directory and files to the amavis user's home directory: cp -r /root/.razor /var/lib/amavis chown -R amavis:amavis /var/lib/amavis |
vi /etc/spamassassin/local.cf And insert the lines:
bayes_path /var/lib/amavis/.spamassassin/bayes This insures both the root and amavis users use the same files and do not have to guess where they are, and whitelists our spam-bin. lock_method flock is used
when the Bayes data resides on the local hard disk and is non NFS.
Optional: Since there is a script that runs each day to --force-expire old Bayes tokens "/etc/cron.daily/amavisd-new" (make sure there is if you use this setting!), we can set: bayes_auto_expire 0 Optional: Some people believe auto-whitelist is more of a liability than an asset: use_auto_whitelist 0 Possibly optional: Depending on your setup, it might be necessary to explicitly set internal_networks and trusted_networks. The trust path tells spamassassin which clients are not trusted. See http://wiki.apache.org/spamassassin/TrustPath and this thread:
# explicitly set our internal_networks (might be the same or similar to mynetworks)
|
dns_available yes
. You also might want
to purchase this book.
If you have installed SpamAssassin version 3.1, additional configuration is needed:vi /etc/spamassassin/v310.pre To enable the ability to use DCC and Razor, uncomment the lines:
#loadplugin Mail::SpamAssassin::Plugin::DCC
To enable the ability to use auto whitelisting (if desired), uncomment the line:
#loadplugin Mail::SpamAssassin::Plugin::AWL
|
Important note. If you are using SpamAssassin 3.1.1 or greater (I recommend 3.1.3 over 3.1.1 because I'm not convinced sa-update works properly on 3.1.1), and you wish to use the new sa-update feature, it is imperative you use the correct '--updatedir' or amavisd-new will not be able to find SpamAssassin rule sets. If you want to run it without using GPG, run:
sa-update --updatedir /usr/share/spamassassin --nogpg
Optionally, you may first import the gpg key (you may need to install gnupg if gpg is not found):
cd /etc/spamassassin
Then simply run: sa-update --updatedir /usr/share/spamassassin
You should find no subdirectories in /var/lib/spamassassin. If you do, you should remove them. You should also not find (and amavisd-new should not be using) a /usr/local/share/spamassassin directory full of rule sets. If you do, that should be removed also. You should also run 'amavisd-new debug-sa' and verify SpamAssassin is locating all of its rule sets (in /usr/share/spamassassin and /usr/share/spamassassin/updates_spamassassin_org). You should also run:
su amavis -c 'spamassassin --lint'
after an update, and you should be aware you must reload amavisd-new after the update in order for the new rules to be used. sa-update can make a mess if not done correctly. |
chown -R amavis:amavis /var/lib/amavis |
cd /etc/cron.daily
|
--lint
option checks our rules.
su amavis -c 'spamassassin --lint -D' |
chown -R amavis:amavis /var/lib/amavis |
sa-learn --ham /path/to/hamfiles
works on files that reside on the spamfilter. We don't keep mail on the spamfilter
however. This problem can be solved by using your email client (MUA) to individually
save messages in .EML format. Look for this option among the menu choices or 'Save As'. Edit
a sample .EML file to insure the file looks like plain text. If it is full of
garbage characters, then it cannot be used. Use WinSCP to copy your ham collection to
an empty folder on your spamfilter. Then run sa-learn. Pick messages that
have some substance to them so the database has something to work with. Use this
especially when you receive a message that is tagged as spam, but is in fact ham.
Autolearning (bayes_auto_learn) is turned on by default so the system will have no problem gathering
plenty of spam. I suggest you only feed it additional examples of ham.
cd /usr/local/src wget http://www.dcc-servers.net/dcc/source/dcc-dccproc.tar.Z tar xzvf dcc-dccproc.tar.Z
Change to the dcc subdirectory by using the [tab] key command completion shortcut as shown, then ./configure: cd dcc-dccproc- [tab]./configure --with-uid=amavis && make && make install
The double ampersands let you run those 3 commands on one line. You will see 'done' if all goes well. We are not running a DCC server, so we don't need to waste time checking ourselves: If you are a large organization (100,000 messages per day), you should investigate running your own server. cdcc "delete 127.0.0.1" cdcc "delete 127.0.0.1 Greylist"
Place a link to cron-dccd in our path: cd
Test our installation with: cdcc info
We should get 'requests ok' from the servers. The instructions say to run cron-dccd each day to clean things up, so we will do that. crontab -e
and insert (at the top): 43 11 * * * /usr/bin/cron-dccd
Make sure you have a carriage return at the end of the line, then save the file (same command as vi) |
su amavis -c 'spamassassin --lint -D' |
/etc/spamassassin/local.cf
and disable the offending party
as needed: amavisd-new stop amavisd-new debug-sa |
Optional to enable dccifd:vi /etc/spamassassin/local.cf and insert: dcc_home /var/dcc save and exit, then: vi /var/dcc/dcc_conf and change DCCIFD_ENABLE=off to: DCCIFD_ENABLE=on Then change: DBCLEAN_LOGDAYS=14 to: DBCLEAN_LOGDAYS=1 save and exit. If you choose to allow logging, cron-dccd should delete old log files when it runs. Keep your eye on the files that accumulate in the /var/dcc/log directory. It's your choice, but I personally don't want to monitor the DCC logs, so I turn off logging altogether by deleting the log directory and commenting out the logdir entry in dcc_conf: rm -r /var/dcc/log vi /var/dcc/dcc_conf and comment out: DCCIFD_LOGDIR="$DCCM_LOGDIR" We will use a supplied script (rcDCC) to automatically start dccifd when we boot up: cp /var/dcc/libexec/rcDCC /etc/init.d/adcc update-rc.d adcc defaults There is a bug in DCC version 1.3.31 or older. We can work around the problem by editing /etc/init.d/adcc and commenting out one line (that we don't need). This file is read only so when you save it, you will have to save it using [Esc]wq! : vi /etc/init.d/adcc
Then comment out this line: # $DCC_LIBEXEC/start-dccm $DEBUG
Save and exit the file, then update file permissions: chown -R amavis:amavis /var/dcc Because we enabled dccifd in dcc_conf, we can start up dccifd by running the script: /etc/init.d/adcc start If you deleted the log directory, you can expect an error message: "log thresholds set with -t but no -l directory". Now test that SpamAssassin finds dccifd: su amavis -c 'spamassassin --lint -D' You should see debug: DCCifd: got response: |
/etc/resolv.conf
. If you
choose not to use a local DNS cache then at
least use a real DNS server as your primary. I have seen
SpamAssassin time out on RBL lookups if it cannot perform DNS queries quickly
enough. This can have a big effect on the final spam score.
I will not pretend that I understand the intricacies of the bind9
program that we will install. We will configure bind9 to be a caching only
name server with the option of forwarding requests to another server.
You may also consider providing the service we install on this machine
to other machines on your network. Note that you will need to modify
our local firewall (iptables) if you choose to provide this service to
other machines:iptables -A FIREWALL -p udp -m udp --dport 53 -j ACCEPT
iptables -A FIREWALL -p tcp -m tcp --dport 53 -j ACCEPT
iptables -A FIREWALL -p udp -m udp -s 222.222.222.222/24 --dport 53 -j ACCEPT
iptables -A FIREWALL -p tcp -m tcp -s 222.222.222.222/24 --dport 53 -j ACCEPT
Please read the notes above to determine if a local caching DNS server is required.
If this is not the first time you have used this document and you are
currently using djbdns (dnscache), it MUST first be disabled
and our nameserver configuration must be changed so it no longer uses 127.0.0.1
as a nameserver entry before we can install bind9. Obviously you can only have
one type of nameserver daemon running. If you do not have djbdns installed, and you
are not running any other type of name server daemon on this machine, you can skip
the instructions in this particular box. The first thing we need to do is edit /etc/resolv.conf and change the nameserver entries to point to valid name servers (either on our network, or at our ISP): vi /etc/resolv.conf and change the nameserver entries(s):
nameserver 444.444.444.444
Test that we are able to resolve host names: dig yahoo.com
You should see valid data, and the output will also tell you which name server was used to find the information: ;; SERVER: 444.444.444.444#53(444.444.444.444) Make sure this is your primary name server as configured in /etc/resolv.conf. Once this is working, we must tell Postfix to use the new name servers: LINUX2
You can see that dnscache is currently running a name server service by running: lsof -i | grep :domain
Now we will get rid of djbdns: rm /service/dnscache
Wait about 5 seconds, then make sure dnscache is no longer running: lsof -i | grep :domain
You can also run dig yahoo.com again if you
would like to make sure you are still able to resolve host names. If for some
reason you want to undo these changes and continue to use djbdns, you can
reinstall it using the original instructions located at
http://verchick.com/mecham/public_html/spam/djbdns.html You would want to start from
the line with the command "build-djbdns"
|
For consistency, we will install version 9.2.4 of bind9:
apt-get -t stable install bind9
For security reasons we want to run BIND chrooted so we will perform the following steps: /etc/init.d/bind9 stop
Edit the file /etc/default/bind9 so that the daemon will run as the unprivileged user 'bind', chrooted to /var/lib/named: vi /etc/default/bind9
Modify the line: OPTS="-u bind" so that it reads: OPTIONS="-u bind -t /var/lib/named"
Create the necessary directories under /var/lib: mkdir -p /var/lib/named/etc
Then move the config directory from /etc to /var/lib/named/etc: mv /etc/bind /var/lib/named/etc
Create a symlink to the new config directory from the old location (to avoid problems if bind is upgraded in the future): ln -s /var/lib/named/etc/bind /etc/bind
Make null and random devices, and fix permissions of the directories: mknod /var/lib/named/dev/null c 1 3
We need to modify the startup script /etc/init.d/sysklogd of sysklogd so we can get important messages logged to the system logs: vi /etc/init.d/sysklogd
and replace: SYSLOGD=""
with: SYSLOGD="-a /var/lib/named/dev/log"
Save and exit the file, then restart the logging daemon: /etc/init.d/sysklogd restart
We can start up bind9 at this point: /etc/init.d/bind9 start
Let's see if the service is running: lsof -i | grep :domain
It is also imperative that after each change we make, we look in our syslog to see if bind9 reported any errors. Here we use less
to view syslog. Once we are viewing the file, use an uppercase 'G'
to go to the bottom of the file (and a lowercase 'q' to quit):less /var/log/syslog
We are setting up bind9 as a local caching only name server (later we will optionally configure it as a forwarding server). Here we add some additional security measures that prevent unauthorized machines from using our name server: vi /etc/bind/named.conf.options
On the line below "directory" we want to add a line that restricts use of our name server to the network our spamfilter is on. Place a [Tab] in front of the entry so it lines up with the other entries. You can add more than one network here if you like. Place a ";" (semicolon) after each network. Note that if you actually want to allow other clients to connect to our name server, as explained in the notes above you would also have to modify IP tables to allow this. allow-query {222.222.222.222/24;};
Save and exit the file, then I would restart bind9 and check that it is running: /etc/init.d/bind9 restart
Optionally configure bind9 as a forwarding server. Bind9 as we have it configured now will first query the root servers for hints when needed. I prefer to forward queries to another name server instead. There are advantages and disadvantages in doing this, but I prefer it. It is absolutely imperative that any name servers listed here are known to work from our spamfilter. These will almost certainly be the primary and secondary servers you currently have configured in /etc/resolv.conf (not 127.0.0.1, and not the IP address of the local machine). Add the 'forwarders' entry just below the 'allow-query' entry we just made: vi /etc/bind/named.conf.options
and add: forwarders {444.444.444.444; 555.555.555.555;};
To never query the root servers, optionally add (personally I do add this): forward only;
Save and exit the file, then once again I would restart bind9 and check that it is running: /etc/init.d/bind9 restart
And once again, check for errors: less /var/log/syslog
Once it is determined bind9 is functioning, you can change the primary nameserver in /etc/resolv.conf: vi /etc/resolv.conf
and replace the entry for the primary nameserver (the first one listed): nameserver 444.444.444.444
to the IP address of this machine (our real IP address, not 127.0.0.1): nameserver 111.111.111.111
Save and exit the file, then test that we are able to resolve host names: dig yahoo.com
You should see valid data, and the output will also tell you which name server was used to find the information: ;; SERVER: 111.111.111.111#53(111.111.111.111) Make sure this is shows our IP address as configured in /etc/resolv.conf. Now we can tell Postfix to use the new name server: LINUX2
|
reboot
logout |
less /var/log/mail.log
tail -f /var/log/mail.log
amavisd-new stop
amavisd-new debug-sa
cd /var/mail
less
any files you may find there. There may be a file
or two that ended up there before Postfix was configured.
Also try the commands mailq
and qshape
(and qshape deferred
) to see if there is
mail stuck in the queue. Use amavisd-new debug
while you are sending mail through the system to help provide clues to the problem.
Open another terminal window and run mailq
while the
other window is running amavisd-new debug
. If you
made changes to configuration files and want to flush the queue, try
postconf -f
and if that does not work try
postsuper -r ALL
. See
http://www.postfix.org/postsuper.1.html. Insure that the relay_domains parameter
has been configured correctly. Inspect the /etc/postfix/transport
file for errors, and make sure you run
postmap /etc/postfix/transport
every time you make changes.
LINUX2 postfix check |
We need to install a Debian Volatile source in our sources.list:vi /etc/apt/sources.list
And insert: deb http://volatile.debian.net/debian-volatile sarge/volatile main
Save and exit the file. Note: you may want to choose a source that may be closer to you, look here. As usual, you must run 'apt-get update': apt-get update
Then install clamav, and clamav-daemon from Volatile: apt-get -t sarge install clamav clamav-daemon
You will be asked 4 questions: Virus database update method: Choose [daemon] or [cron] (either is fine) Download mirrors: Choose a mirror that matches your country code or accept the default. Enter http proxy information or leave blank for none. Do so if needed, or leave blank. Should clamd be notified after updates: [Yes] Now, very important, add the clamav user to the amavis group: gpasswd -a clamav amavis
|
vi /etc/amavis/amavisd.conf
To enable virus scanning, comment out the line: @bypass_virus_checks_maps = (1); # uncomment to DISABLE anti-virus code
Locate and uncomment the line: #$first_infected_stops_scan = 1;
Locate the line: @av_scanners = (
Uncomment these 4 lines, then make sure the value after CONTSCAN reads as follows: ['ClamAV-clamd', \&ask_daemon, ["CONTSCAN {}\n", '/var/run/clamav/clamd.ctl'], qr/\bOK$/, qr/\bFOUND$/, qr/^.*?: (?!Infected Archive)(.*) FOUND$/ ],While you are at it, if you would like to clean up amavisd.conf a little, you may optionally delete all the virus scanners between ClamAV and BitDefender. We want to keep BitDefender. It would be a very good idea to make a backup copy of amavisd.conf before you do this. |
/var/run/clamav/clamd.ctl
value shown above must match the LocalSocket
parameter in /etc/clamav/clamd.conf
Change it here if necessary to match what is in /etc/clamav/clamd.conf.
/etc/clamav/clamd.conf
.
The freshclam daemon (or cron job) is set to check for, and download if necessary,
new virus definitions 12 times per day.
The configuration file
for freshclam is /etc/clamav/freshclam.conf
You can check the log files at
/var/log/clamav/freshclam.log
and
/var/log/clamav/clamav.log
The startup script for freshclam is
/etc/init.d/clamav-freshclam
and for clamd it's /etc/init.d/clamav-daemon
If you chose cron for database updates, the file is
/etc/cron.d/clamav-freshclam.
You can also research
additional clamd.conf configuration options by running man clamd.conf
Let's reboot (it might make a difference), and then test the system:
reboot logout
As an alternate to rebooting, you can stop and start clamd and amavisd-new: amavisd-new stop
Once the system comes back up, we need to test ClamAV. To do so, we can simply watch the mail.log go by as we send the Eicar test virus through the system: tail -f /var/log/mail.log
Send the Eicar test virus through as described below. After you are finished sending the virus through, use [Ctrl]+c to return to the shell prompt. |
tail -f /var/log/mail.log
so you can see what happens.
apt-get --purge remove clamav clamav-base clamav-daemon clamav-freshclam libclamav1
@bypass_virus_checks_maps
in /etc/amavis/amavisd.conf
to disable virus scanning
(then maybe go shopping for another antivirus vendor).
Also: make sure everything works AFTER you reboot. Don't leave ClamAV in a
non-functional state if you have virus scanning enabled. Amavisd-new will not work properly.
Keep an eye on /var/log/clamav/freshclam.log
and /var/log/clamav/clamav.log.
You need
to look for error messages in these files. You may have an error or two when the
program is first installed; this is probably OK and may be due to things happening
out of sequence. Check the logs for a couple days and make sure the database
updates do not fail and that Clamd is notified of updates.
Optionally remove most comments from amavisd.conf:cp /etc/amavis/amavisd.conf /etc/amavis/amavisd.conf-verbose
grep -vE '^$|^#' /etc/amavis/amavisd.conf > /etc/amavis/amavisd.conf-temp
cp /etc/amavis/amavisd.conf-temp /etc/amavis/amavisd.conf
|
$virus_quarantine_to = undef;.
Create the mount point:
mkdir /floppy
Format the floppy: fdformat /dev/fd0u1722 |
Create a file system on the floppy (we need one that accepts long file
names):mke2fs /dev/fd0u1722 |
Mount the floppy:mount /dev/fd0u1722 /floppy
Yes I know, working with floppies in *nix is a pain. |
And copy all these files to it: (Yes you can copy and paste this whole
section).
cp /etc/fstab /floppy cp /etc/aliases /floppy cp /etc/postfix/main.cf /floppy cp /etc/postfix/master.cf /floppy cp /etc/postfix/sender_access /floppy cp /etc/postfix/transport /floppy cp /etc/postfix/virtual /floppy cp /etc/postfix/relay_recipients /floppy cp /etc/postfix/body_checks /floppy cp /etc/postfix/header_checks /floppy cp /etc/amavis/amavisd.conf /floppy cp /etc/spamassassin/local.cf /floppy cp /var/lib/amavis/.spamassassin/user_prefs /floppy cp /var/lib/amavis/.razor/razor-agent.conf /floppy cp /etc/apt/sources.list /floppy cp /etc/apt/preferences /floppy cp /etc/clamav/clamd.conf /floppy cp /etc/clamav/freshclam.conf /floppy
|
ls -l /floppy This floppy will not be readable by a Windows machine. I can't repeat this enough: Always unmount the floppy before you remove it: I suggest you have the monitor on at the console so you can see the mess you make if you don't. umount /floppy Remove it, label it and store it in a safe place. |
mount /dev/fd0u1722 /floppy
cp /floppy/aliases /etc/aliases
newaliases
cp /floppy/main.cf /etc/postfix/main.cf
cp /floppy/master.cf /etc/postfix/master.cf
cp /floppy/sender_access /etc/postfix/sender_access
postmap /etc/postfix/sender_access
cp /floppy/transport /etc/postfix/transport
postmap /etc/postfix/transport
cp /floppy/virtual /etc/postfix/virtual
postmap /etc/postfix/virtual
cp /floppy/relay_recipients /etc/postfix/relay_recipients
postmap /etc/postfix/relay_recipients
cp /floppy/body_checks /etc/postfix/body_checks
cp /floppy/header_checks /etc/postfix/header_checks
cp /floppy/amavisd.conf /etc/amavis/amavisd.conf
cp /floppy/user_prefs /var/lib/amavis/.spamassassin/user_prefs
cp /floppy/local.cf /etc/spamassassin/local.cf
cp /floppy/razor-agent.conf /var/lib/amavis/.razor/razor-agent.conf
cp /floppy/clamd.conf /etc/clamav/clamd.conf
cp /floppy/freshclam.conf /etc/clamav/freshclam.conf
cp /floppy/sources.list /etc/apt/sources.list
cp /floppy/preferences /etc/apt/preferences
apt-get update
umount /floppy
then shutdown and restart amavisd-new and Postfix as needed.
Note that we do not restore /etc/fstab, it is just a real good idea to have a copy of
to refer to. It describes our partition layout.
Stop Postfix and amavisd-new so the bayes files are not written to during the backup:
postfix stop
amavisd-new stop
su amavis -c 'sa-learn --sync'
Start your ftp session (substituting your settings): ftp -p server.domain.tld
Enter your user name and password as requested, and then make a directory to place our files: ftp> mkdir sfa (only necessary the first time you do this)
Change to that directory: ftp> cd sfa
Then simply copy and paste this entire section:
ascii
|
get
instead of put
to restore a file.
For example: get clamd.conf /etc/clamav/clamd.conf
logcheck
apt-get install logcheck
Read the message that comes up. If you would like to change any settings: vi /etc/logcheck/logcheck.conf |
su -s /bin/bash -c "/usr/sbin/logcheck" logcheck
at the command
prompt, wait a minute, and then check the
mailbox of the address you configured logcheck to send email. You should get a
message indicating the security violation. Logcheck looks for suspicious
activity and is scheduled to run once each hour. You will only get a message if
it finds something suspicious, but this is configurable. Don't set it to
"paranoid", there would be an entry for every email that passed through the
system.
Read more about logcheck by using less /usr/share/doc/logcheck/README.logcheck
/etc/logcheck/ignore.d.server/logcheck
and insert
a regular expression of the text you wish logcheck to ignore. For example, I
insertedCRON.*: \(pam_unix\) session opened for user
CRON.*: \(pam_unix\) session closed for user
You most likely will not want to be annoyed by every message amavisd-new Blocks,
so edit this file using vi or the WinSCP editor: vi /etc/logcheck/ignore.d.server/amavisd-new
At the bottom, you will find the text: amavis\[[0-9]+\]: +(\([-0-9]+\) +)?(SPAM|Not-Delivered|Passed|BANNED|INFECTED)
Change this to: amavis\[[0-9]+\]: +(\([-0-9]+\) +)?(Blocked|SPAM|Not-Delivered|Passed|BANNED|INFECTED)
Logcheck will also look for keywords (like "attack") contained in the /etc/logcheck/cracking.d/logcheck file. We can tell logcheck to ignore log entries that contain a hostname such as "attackingthedevil.co.uk" by creating a new file in the appropriate logcheck "ignore" directory and placing that text in it. We create a file because none exist at this point: echo "attackingthedevil.co.uk" >> /etc/logcheck/cracking.ignore.d/logcheck-postfix
If you removed the DCC log directory as I suggested, dccifd will log an error every time it is called. We want logcheck to ignore those log entries (this is a single command): echo "stat\(log directory /var/dcc/log\): No such file or directory" >> /etc/logcheck/ignore.d.server/dcc
While we are at it, there is another dcc message we don't care about: echo ": missing message body" >> /etc/logcheck/ignore.d.server/dcc
|
vi -R /usr/share/doc/logcheck-database/README.logcheck-database.gz
su -s /bin/bash -c "/usr/sbin/logcheck -otd" logcheck
which [program name]
or whatis [program name]
or dpkg -l [package name]
cd Use dpkg and grep to send the list of installed program
files to a file called "progs":dpkg -l '*' | grep '^i' > /root/progs Then use less to view the file:less /root/progs Or send it in an email to root: cat /root/progs | mail -s "sfa installed programs" root |
crontab -e And insert: 30 7 * * * /usr/bin/mailq |/usr/bin/tail |/usr/bin/mail -s "mailq sfa" root
While we are editing crontab, let's also sync our CMOS clock once each day, and for the forgetful type (forgot that you are not supposed to run 'sa-learn' as root) we will make sure 'amavis' still owns the Bayes and AWL files: 10 10 * * * /sbin/hwclock --systohc 30 17 * * * /bin/chown -R amavis:amavis /var/lib/amavis/.spamassassin
Save and exit |
mailq
(or as an alternate) you may wish to use qshape
vi /etc/cron.d/qshape-cron And insert (2 lines): PATH=/usr/sbin
31 7 * * * postfix /usr/sbin/qshape incoming active deferred 2>&1 |/usr/bin/mail -s "qshape sfa" root
Save and exit. Logcheck will now complain each day, so we need to shut it up: vi /etc/logcheck/ignore.d.server/postfix
and insert (1 line): ^\w{3} [ :0-9]{11} [._[:alnum:]-]+ postfix/pickup\[[0-9]+\]: [[:alnum:]]+: uid=[0-4]+ from=<postfix>
|
For consistency, we are not using the most current version of AIDE:cd /usr/local/src wget http://verchick.com/mecham/public_html/spam/aide_0.10-4_i386.deb dpkg -i aide_0.10-4_i386.deb The installation will have three input screens, answer them as follows: Daily reports are mailed to root by default. [Ok] Initialize aide database? [No] Before AIDE can be used, you will have to initialize a database. [Ok] |
/usr/bin/aide
= the executable program file/etc/aide/aide.conf
= the configuration file/etc/cron.daily/aide
= a nice script that runs the report
Make a new directory, a convenient place to store the files we
want:mkdir /root/aide
Then copy the files, note that we will rename the report script "report": cp /usr/bin/aide /root/aide cp /etc/aide/aide.conf /root/aide cp /etc/cron.daily/aide /root/aide/report
Then we uninstall aide: apt-get --purge remove aide We will need recreate the directory that AIDE uses for its logs: mkdir /var/log/aide
|
vi /root/aide/aide.conf Change: database=file:/var/lib/aide/aide.db To: database=file:/floppy/aide.db Change: database_out=file:/var/lib/aide/aide.db.new To: database_out=file:/root/aide/aide.db.new Under Custom Rules, edit Binlib, and remove: +m +c Edit Devices, and remove: +i +g +c Comment out the entire section under # Log Files
Under # Check crontabs add:/etc/cron.d Databases Save and exit. |
vi /root/aide/report Change: PATH="/bin:/usr/bin" To: PATH="/floppy:/bin" Change: CONFFILE="/etc/aide/aide.conf" To: CONFFILE="/floppy/aide.conf" Change: [ -f /usr/bin/aide ] || exit 0 To: [ -f /floppy/aide ] || exit 0 If you would like to send the report to someone other than root, optionally change: MAILTO="${MAILTO:-root}" To something like: MAILTO="${MAILTO:-someuser@example.com}" Change: DATABASE="${DATABASE:-/var/lib/aide/aide.db}" To: DATABASE="${DATABASE:-/floppy/aide.db}" Change: COMMAND="${COMMAND:-check}" To: COMMAND="${COMMAND:-update}"
Optional: If you would like to see more detail in the report (recommended), change: AIDEARGS="-V4" To: AIDEARGS="-V5"
Change: aide $AIDEARGS --$COMMAND >"$LOGDIR/$LOGFILE" 2>"$ERRORTMP" To: aide $AIDEARGS --config=/floppy/aide.conf --$COMMAND >"$LOGDIR/$LOGFILE"
2>"$ERRORTMP" Save and exit. |
umount /floppy
)
then remove it.
Insert a floppy in the drive. We are going to format it, create
an ext2 file system on it, mount it, and then copy the AIDE files to it.
Make sure we have a mount point:
mkdir /floppy
Run these one at a time and wait for each command to finish: fdformat /dev/fd0u1722
mke2fs /dev/fd0u1722
fsck /dev/fd0u1722
mount /dev/fd0u1722 /floppy
|
cp /root/aide/aide /floppy |
/floppy/aide --config=/floppy/aide.conf --init |
cp /root/aide/aide.db.new /floppy/aide.db |
/floppy/report |
cat /var/log/aide/error.log
Now you have to write protect the floppy disk. This is the most important part.
umount /floppy Then pull out the disk and push up the write protect tab. Reinsert the floppy, and mount it again: mount /dev/fd0u1722 /floppy
This floppy should remain in the drive all the time. (Unless we need to use the drive for a moment) |
/floppy/report
from the command line and
you inspect the report just prior to copying it over to the floppy. If you
left the write protection off the floppy drive for any length of time, it's possible you
can no longer rely on the database. Be paranoid.
crontab -e And insert: 25 7 * * * /floppy/report Save and exit |
Change to our home directory:cd Unmount the floppy, but leave it in the drive: umount /floppy Create an image of the floppy and store it to a file: dd if=/dev/fd0u1722 of=floppy.img dd stands for `Copy and Convert' and was renamed to `dd` only because `cc' was reserved for the C compiler. if= input file, of= output file Remove the source disk, insert the destination disk: First, format the new floppy: fdformat /dev/fd0u1722
Then copy the image to the new floppy: dd if=floppy.img of=/dev/fd0u1722
Simply use the new disk now. Turn write protect on, then mount the floppy: mount /dev/fd0u1722 /floppy |
vi /etc/init.d/startflop And insert the following text just as it is listed here (Hint: use the [tab] key, not a bunch of spaces) Note that this will not paste well using the right-click method. Try [Shift]+[Insert] to paste: |
#! /bin/sh # # very simple startup script case "$1" in start) /bin/mount /dev/fd0u1722 /floppy ;; stop) /bin/umount /floppy ;; esac exit 0 |
Save and exit the file, then make the file executable:chmod +x /etc/init.d/startflop Now use this command to enable it and prioritize it: update-rc.d startflop defaults 80 Now make a symbolic link to it, I will explain why in a moment: ln -s /etc/init.d/startflop /usr/bin/floppy |
floppy start
floppy stop
df /floppy |
cpan>
prompt, enter o conf
init
vi /etc/libnet.cfg And change: ftp_ext_passive => 0, to: ftp_ext_passive => 1, |
Start a CPAN session:perl -MCPAN -e shell Accept the default of "yes" at the: Are you ready for manual configuration? [yes] Accept all the defaults, eventually you will need to (and this may take some time to come up): Select your continent Select your country After you have selected these, hit [space][enter] a few times until you see some http servers. Do not pick any ftp servers. Select a couple of the http servers. Hit [enter] to get back to the cpan> prompt. |
At the cpan> prompt type these commands in exactly:install File::MMagic If you are asked any questions, accept the defaults. Back at the cpan> prompt: install Date::Calc If you are asked any questions, accept the defaults. When it finishes, exit cpan with: q |
cd /usr/bin wget http://verchick.com/mecham/public_html/debian/mailgrep_pl.txt mv mailgrep_pl.txt mailgrep.pl chmod +x mailgrep.pl wget http://verchick.com/mecham/public_html/debian/openlogfile_pl.txt mv openlogfile_pl.txt openlogfile.pl chmod +x openlogfile.pl cd
|
mailgrep.pl
mailgrep.pl -s someuser@somedomain.com /var/log/mail.log
mailgrep.pl -s someuser@somedomain.com /var/log/mail.log.0
grep -i someuser@somedomain.com /var/log/mail.log
Go to:
http://jimsun.linxnet.com/postfix_contrib.html And by looking at the link to the program, edit these next lines if necessary to reflect the latest production version: cd /usr/local/src wget http://jimsun.linxnet.com/downloads/pflogsumm-1.1.0.tar.gz tar xzvf pflogsumm-1.1.0.tar.gz cd pflogsumm-1.1.0 cp pflogsumm.pl /usr/sbin chmod +x /usr/sbin/pflogsumm.pl cd
|
cd /etc/cron.daily wget http://verchick.com/mecham/public_html/spam/pflogsumm chmod +x pflogsumm You may need to edit the script and change the hostname just after the word "DAILY" to reflect your system's hostname. You may also want to change to whom the report gets mailed: vi /etc/cron.daily/pflogsumm |
less /usr/local/src/pflogsumm-1.1.0/pflogsumm-faq.txt
|
/etc/crontab
controls when the scripts in /etc/cron.daily
/etc/cron.weekly and /etc/cron.monthly run.
One of the scripts in /etc/cron.weekly
is sysklogd. sysklogd reads its configuration from /etc/syslog.conf. You can see
what logs should get rotated weekly by sysklogd by using the command
syslogd-listfiles --weekly
/var/lib/amavis/.spamassassin/auto-whitelist
file will grow to a rather large size. The SpamAssassin source code comes with a utility
called check_whitelist
that can be used to trim the size down.
Run perldoc check_whitelist
to see how it is used. There is a
modified version of check_whitelist called trim_whitelist we are going to use to
reduce the size of the auto-whitelist file. This utility is explained here:
http://article.gmane.org/gmane.mail.spam.spamassassin.general/59651.
Download trim_whitelist:cd /usr/sbin wget http://www.deepnet.cx/~kdeugau/spamtools/trim_whitelist
Make it executable: chmod +x /usr/sbin/trim_whitelist
List our SpamAssassin directory: ls -l /var/lib/amavis/.spamassassin
Run the program in order to test it: su amavis -c '/usr/sbin/trim_whitelist'
List our SpamAssassin directory again: ls -l /var/lib/amavis/.spamassassin
If the test is successful, the program will have created a new file: auto-whitelist-old
Now we will create a cron job so trim_whitelist will run once each week: cd /etc/cron.weekly wget http://verchick.com/mecham/public_html/debian/trim_whitelist_weekly chmod +x trim_whitelist_weekly cd
|
/etc/postfix/sender_access
that can be used to blacklist senders. We created
/etc/postfix/header_checks
and /etc/postfix/body_checks
that can be used for content filtering and I provided links to some examples.
The files themselves also provide examples. When we were editing
/etc/amavis/amavisd.conf
you noticed sections that dealt with
whitelisting and blacklisting. It is recommended you do "soft" whitelisting
and blacklisting by adding entries to the @score_sender_maps section of amavisd.conf.
Add your entries in the same section that 'nobody@cert.org' => -3.0,
is
listed. Negative scores will be subtracted from the overall spam score, and positive
scores will be added.
postfix reload
/etc/init.d/postfix restart
postfix stop
postfix start
/etc/init.d/amavis stop
/etc/init.d/amavis start
amavisd-new stop
amavisd-new start
postsuper -r ALL
.
top
to see what's using memory;
then change the sort order with >
and <
perldoc Mail::SpamAssassin::Conf
bayes_path /var/lib/amavis/.spamassassin/bayes auto_whitelist_path /var/lib/amavis/.spamassassin/auto-whitelist lock_method flock # # We need stuff from these senders, and they tend to get marked as spam. # We want to whitelist our close business partners. # We subscribe to industry specific newsletters and whitelist them also. # Later we manually feed these to Bayes as ham. whitelist_from spam-bin@example.com whitelist_from *@generalmotors.com whitelist_from *.usanewstoday.com # # We need stuff from autonetamerica and the Lottery and it always gets marked as spam. # So we will create custom rules that let these particular subject lines reduce the score. header AUTONETAMERICA Subject =~ /Auto Net America/ score AUTONETAMERICA -5.000 header YOURLOTTERY Subject =~ /Your Lottery Results!/ score YOURLOTTERY -5.000 # # We change the scores on a few standard tests score BAYES_00 -2.500 score BAYES_05 -2.000 score BAYES_20 -1.700 score BAYES_40 -0.600 score BAYES_60 1.000 score BAYES_80 1.900 score BAYES_95 2.500 score BAYES_99 3.000 score RAZOR2_CF_RANGE_51_100 0.500 score URIBL_WS_SURBL 2.000 score URIBL_PH_SURBL 2.500 score RCVD_IN_SORBS_HTTP 1.000 score RCVD_IN_SBL 1.000 score RCVD_IN_NJABL_PROXY 1.000 score RCVD_IN_SORBS_MISC 0.500 score RCVD_IN_BL_SPAMCOP_NET 2.000 score RCVD_IN_NJABL_SPAM 2.200 score HTML_WEB_BUGS 1.500 # # use_auto_whitelist 0 # uncomment to disable auto-whitelist - a number of people recommend NOT using auto-whitelist.
spamassassin --lint
after adding any new rules.
/etc/spamassassin/local.cf
file is used to
configure SpamAssassin site wide but in our case,
editing /var/lib/amavis/.spamassassin/user_prefs
would have the same effect. However, certain global SpamAssassin settings will
have no effect if placed in user_prefs, therefore you only need to maintain local.cf.
If you have not already done so, browse to:
http://uranus.it.swin.edu.au/~jn/linux/rawwrite.htm |
Browse to: http://mirrors.kernel.org/debian/dists/woody/main/disks-i386/3.0.23-2002-05-21/images-1.44/bf2.4/ |
Right-click these next 2 links and "Save Target as" or "Save Link
Target as" and save them to the debian folder. http://verchick.com/mecham/public_html/debian-test1/message.txt http://verchick.com/mecham/public_html/debian-test1/syslinux.cfg |
/sbin/grub-install /dev/hda
umount /floppy
Now it's safe to remove the floppy currently in the drive. Please check http://ftp.sunsite.utk.edu/ftp/pub/mini-linux/tomsrtbt/ for version changes and edit if necessary: Insert a blank floppy. Then: cd /usr/local/src
wget http://ftp.sunsite.utk.edu/ftp/pub/mini-linux/tomsrtbt/tomsrtbt-2.0.103.tar.gz
tar xzvf tomsrtbt-2.0.103.tar.gz
rm toms*.gz
cd tomsrtbt-2.0.103
./install.s
|
mount /dev/fd0u1722 /floppy cd |
mkdir /hardroot
mount /dev/hda6 /hardroot
chroot /hardroot
(If you have a separate boot partition, this would need to be mounted too):
mount /dev/hda1 /boot
cp /etc/lilo.conf /etc/lilo.conf-original
/sbin/lilo
shutdown -r -F now
/sbin/grub-install /dev/hda
/etc/aliases
/etc/postfix/main.cf
/etc/postfix/master.cf
/etc/postfix/sender_access
/etc/postfix/transport
/etc/postfix/virtual
/etc/postfix/relay_recipients
/etc/postfix/body_checks
/etc/postfix/header_checks
/etc/amavis/amavisd.conf
/var/lib/amavis/.spamassassin/user_prefs
/etc/spamassassin/local.cf
/var/lib/amavis/.razor/razor-agent.conf
/etc/clamav/clamd.conf
/etc/apt/preferences
/etc/apt/sources.list
postmap /etc/postfix/sender_access |
df
fdisk -l /dev/hda
or /dev/sda
postsuper -d <ID number>
postsuper -d ALL deferred
This website was created for the author's personal use and entertainment. There is absolutely no warranty. Use entirely at your own risk. Any information contained herein is freely available elsewhere and simply reinterpreted, or more likely misinterpreted, and cannot be assumed to be accurate. There are mistakes in this website and there may or may not be any effort to correct those mistakes in the future. The author accepts no responsibility for any loss or damage caused by the use, lack of use, or misuse, of information contained in this website. Where links are provided to other websites, the author accepts no responsibility and shall not be liable, either directly or indirectly for the content, legality, accuracy, reliability, suitability, quality or decency of content, information, product, advice or services provided by and contained in those sites. Downloading any information from the Internet is done at your own risk, and the risk can be substantial. You knew that, right? All trademarks are the property of their respective owners.
Buy your next car at:![]() Salt Lake City As we say in Utah: pre-shayt-cha (I appreciate you) |