Pages

Monday, March 24, 2008

Cause of default aliases to MTA-postfix

In the setup of two mail exchangers and a mail server using postfix ( MTA - mail transfer agent ). As per DNS mx record mails flow from mail exchangers to mail server vice versa.

okay. see what this /etc/aliases file does with postfix.

vi /etc/aliases
####sample of aliases ############
# Basic system aliases -- these MUST be present.
mailer-daemon: postmaster
postmaster: root
# General redirections for pseudo accounts.
bin: root
daemon: root
adm: root
lp: root
########### end ################

above file gives daemon and related aliases details. take a example, system daemons generates a log mail to aliases uid. interesting by default system daemons mails go to local machine . but postfix appends domain to name and mail exchangers keep a transport record that used to rely mail to subdomains. in above scenario system local mails are route between mail exchanger and mail server and this is pile up mail queue and slow down delivery. following changes will make local mail to delivery to local only.


modified aliases file to avoid piling of mail queue.
vi /etc/aliases
#########sample of aliases ########
# Basic system aliases -- these MUST be present.
mailer-daemon: postmaster@localhost
postmaster: root@localhost
# General redirections for pseudo accounts.
bin: root@localhost
daemon: root@localhost
adm: root@localhost
lp: root@localhost
############## end ###############

vi/vim Editor Commands

When First time dealt with Linux OS, it was Red hat 6.0 something I guess. After struggling to install Red Hat on hardware 32 MB RAM and 4 GB of hard disk. First Programming instruction started writing a HELLO foot print using vi. Vi is a text editor, it can be used to edit all kinds of plain text. It is especially useful for editing programs. You might thinking why am I writing this details in this posting...just because still I prefer vi and know beginners problems dealing with vi. here we go to make it simple.

General Startup
To use vi: vi filename
To exit vi and save changes: ZZ or :wq
To exit vi without saving changes: :q!
To enter vi command mode: [esc]
To Replace string [esc] : %s!root!root@localhost!cg

Other

http://www.cs.colostate.edu/helpdocs/vi.html

Tuesday, March 18, 2008

Postfix client restrction and SMTP reverse domain lookup

Add following line to main.cf file.

% vi /etc/postfix/main.cf

################start####################
#reject unless the hostname has valid syntax.
#reject unless the host has a valid MX or A record in DNS.
#reject unless the host is fully qualified.
#Postfix will allow dotted quads that are not wrapped in square brackets (à la [
127.28.29.1]) even though it violates the RFC.
# look up the hostname in the file mapname and reject or accept as appropriate.

smtpd_helo_required = yes

smtpd_helo_restrictions = reject_invalid_hostname, reject_unknown_hostname, reje
ct_non_fqdn_hostname, permit_mynetworks


######reverse dns lookup ##############

smtpd_client_restrictions = hash:/etc/postfix/client_restrictions, reject_unknow
n_client, reject_maps_rbl
maps_rbl_domains = bl.spamcop.net, rbl-plus.mail-abuse.org
################end####################



%vi /etc/postfix/client_restrictions
################start####################
# Whoops, we need to talk to these machines
# but they has no reverse DNS set up:
10.0.10.1 OK
10.0.10.5 OK

# Reject these guys, they keep sending us junk mail
# and won't take us off their lists
spam_central.com REJECT

################end####################


% Test postfix for changes

[leo@linux]$ telnet 192.164.1.30 25
Trying 192.168.1.30...
Connected to test.domain.org (192.168.1.30).
Escape character is '^]'.
220 *******************************2*****
MAIL FROM:leo@anilinux.org
250 2.1.0 Ok
RCPT TO: user@domain.org
250 2.1.5 Ok
DATA
354 End data with .
test data
.
250 2.0.0 Ok: queued as CE6F53A4084
Quit
221 2.0.0 Bye
Connection closed by foreign host.



[leo@linux]$ telnet 192.164.1.30 25
Trying 192.168.1.30...
Connected to test.domain.org (192.168.1.30).
Escape character is '^]'.
220 *******************************2*****
MAIL FROM:leo@anilinux.org
250 2.1.0 Ok
RCPT TO: user@domain.org
450 4.7.1 Client host rejected: cannot find your hostname, [domain.org]
quit
221 2.0.0 Bye
Connection closed by foreign host.

Controlling Jobs in Linux

% Stop and restart a Job
If you find your Linux machine is slow due to lots of daemons running on it and want some process to get more CPU time to finish up fast. here we go to controlling jobs.
leo@gnu:~$ kill -s STOP 5846 ###5846 is PID of the running process
leo@gnu:~$ ps x | grep daemon_wallpapoz
5846 ? Tl 0:14 python /usr/bin/daemon_wallpapoz
leo@gnu:~$ kill -s CONT 5846
leo@gnu:~$ ps x | grep wall
5846 ? Sl 0:14 python /usr/bin/daemon_wallpapoz

% Starting a Job in the Background
Attaching an ampersand to the end of a command will cause that command to run in the background.
For example:
leo@gnu# xcalc &
This command causes the xcalculator to run, also it frees up the bash prompt so you can perform other tasks.
You can also use this method when starting X-Windows
leo@gnu# startx &
This will start X-Windows, but it will also free up that console that was used to start X-Windows.

% Stopping (Pausing) a Job
Press CTRL+z to stop a job.

% Listing Jobs
You may list jobs and their status by running the "jobs" command.
[leo@gnu]# jobs
[1]+ Stopped less /etc/lilo.conf
[leo@gnu]#

% Resuming a Stopped Job [%1]
You may resume a stopped job by typing %jobnumber as follows:
[leo@gnu]# %1
An alternate method :
[leo@gnu]# fg %1

% Placing a Job in the Background [%1 &]
You may place a stopped job in the background by typing %jobnumber & as follows:
[leo@gnu]# %1 &
An alternate method :
[root@server /root]# bg %1

% Killing a stopped Job [kill %1]
You may kill a stopped job by typing kill %jobnumber as follows:
[leo@gnu]# kill %1

% The nohup Utility [nohup cmd &]
The nohup utility will run as a process that is detached from your console. If you close your console, the nohup process will keep running in the background.
[leo@gnu]# nohup scan_ip.sh &

% Capturing Output [script]
The "script" command will put you into a new shell and it will log all the output for you into the file called "typescript". When you are done collecting data, you may type "exit" to get out of this script shell.