Easiest way to relay mail through GMail using Postfix and Debian

There are times when you need need to send E-Mail from your Linux server.  The reason that I had to set up E-Mail was because I had a php script that E-Mailed me once some one filled out their information on the website.  The easiest way to get your server sending mail is using GMail to send the mail.  This tutorial will describe how to set it up on Ubuntu / Debian.

sudo aptitude install postfix libsasl2 ca-certificate libsasl2-modules

You want to add the fowling lines to your /etc/postfix/main.cf

relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/
gmail_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes

You need to edit /etc/postfix/gmail_passwd and add the fowling information below, edit it to fit your needs.

[smtp.gmail.com]:587    UserMame@gmail.com:PassWord

Next you need to turn the gmai_passwd file into something that postfix can understand, you can use the command below to accomplish that.

sudo chmod 400 /etc/postfix/sasl_passwd
sudo postmap /etc/postfix/sasl_passwd

Now you can restart postfix but it will complain about not being able to authenticate the certificate.  In order to fix the problem we will use the ca-certificate package we installed earlier to tell it where it can validate the certificate.

cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | sudo tee -a /etc/postfix/cacert.pem

Now restart postfix for the final time.

/etc/init.d/postfix

Comments

How to mirror ZFS root disk on a sparc system.

First we look to see that everything looks good on our current drive that we are booted off of.  I would also like to note that there is no UFS on this system at all.  We are booting entirely off of the ZFS pool rpool.

# zpool status
pool: rpool
state: ONLINE
scrub: none requested
config:

NAME        STATE     READ WRITE CKSUM
rpool       ONLINE       0     0     0
c0t0d0s0  ONLINE       0     0     0

errors: No known data errors

Now verify that the two disks that you want to mirror looks the same at the slave level.

# format
Searching for disks…done

AVAILABLE DISK SELECTIONS:
0. c0t0d0 <ST320011A cyl 38790 alt 2 hd 16 sec 63>
/pci@1f,0/ide@d/dad@0,0
1. c0t2d0 <DEFAULT cyl 38790 alt 2 hd 16 sec 63>
/pci@1f,0/ide@d/dad@2,0
Specify disk (enter its number): 0
selecting c0t0d0
[disk formatted, no defect list found]
/dev/dsk/c0t0d0s0 is part of active ZFS pool rpool. Please see zpool(1M).
/dev/dsk/c0t0d0s2 is part of active ZFS pool rpool. Please see zpool(1M).

FORMAT MENU:
disk       – select a disk
type       – select (define) a disk type
partition  – select (define) a partition table
current    – describe the current disk
format     – format and analyze the disk
repair     – repair a defective sector
show       – translate a disk address
label      – write label to the disk
analyze    – surface analysis
defect     – defect list management
backup     – search for backup labels
verify     – read and display labels
save       – save new disk/partition definitions
volname    – set 8-character volume name
!<cmd>     – execute <cmd>, then return
quit
format> ver

Primary label contents:

Volume name = <        >
ascii name  = <ST320011A cyl 38790 alt 2 hd 16 sec 63>
pcyl        = 38792
ncyl        = 38790
acyl        =    2
nhead       =   16
nsect       =   63
Part      Tag    Flag     Cylinders         Size            Blocks
0       root    wm       0 – 38789       18.64GB    (38790/0/0) 39100320
1 unassigned    wm       0                0         (0/0/0)            0
2     backup    wm       0 – 38789       18.64GB    (38790/0/0) 39100320
3 unassigned    wm       0                0         (0/0/0)            0
4 unassigned    wm       0                0         (0/0/0)            0
5 unassigned    wm       0                0         (0/0/0)            0
6 unassigned    wm       0                0         (0/0/0)            0
7 unassigned    wm       0                0         (0/0/0)            0

format> disk 1
selecting c0t2d0
[disk formatted, no defect list found]
format>

Notice that both disks have 0 – 38789 Cylinders.  So the disks look good, now we can attach the second disk.

# zpool attach rpool c0t0d0s0 c0t2d0s0
#
# zpool status
pool: rpool
state: ONLINE
status: One or more devices is currently being resilvered.  The pool will
continue to function, possibly in a degraded state.
action: Wait for the resilver to complete.
scrub: resilver in progress for 0h0m, 3.28% done, 0h24m to go
config:

NAME          STATE     READ WRITE CKSUM
rpool         ONLINE       0     0     0
mirror      ONLINE       0     0     0
c0t0d0s0  ONLINE       0     0     0
c0t2d0s0  ONLINE       0     0     0

errors: No known data errors

WoW that was easy to mirror two disks with ZFS.  No need to set up data stores or anything like that.  The fact that the zpool status output specify “mirror” means the disks are mirrored and not striped.  If you have multiple zfs pools you can specify zpool status POOLNAME.

Now to try to distroy the disk, ha, ha, ha!

# dd if=/dev/random of=/dev/rdsk/c0t2d0s0
969+0 records in
969+0 records out

Now if that disk was on a normal RAID utility stuch as solstice disk suite SDS or even hardware raid then both disks would be destroyed because they operate at the block level, and will copy the random blocks back do c0t0d0s0

# zpool status
pool: rpool
state: DEGRADED
status: One or more devices could not be opened.  Sufficient replicas exist for
the pool to continue functioning in a degraded state.
action: Attach the missing device and online it using ‘zpool online’.
see: http://www.sun.com/msg/ZFS-8000-2Q
scrub: resilver in progress for 0h1m, 10.52% done, 0h12m to go
config:

NAME          STATE     READ WRITE CKSUM
rpool         DEGRADED     0     0     0
mirror      DEGRADED     0     0     0
c0t0d0s0  ONLINE       0     0     0
c0t2d0s0  UNAVAIL      0     0     0  cannot open

errors: No known data errors

Oha happy ZFS is already working on fixing or resilvering the disk that was written to with random data.

# zpool status
pool: rpool
state: DEGRADED
status: One or more devices could not be opened.  Sufficient replicas exist for
the pool to continue functioning in a degraded state.
action: Attach the missing device and online it using ‘zpool online’.
see: http://www.sun.com/msg/ZFS-8000-2Q
scrub: resilver completed after 0h0m with 0 errors on Tue Apr 14 12:55:48 2009
config:

NAME          STATE     READ WRITE CKSUM
rpool         DEGRADED     0     0     0
mirror      DEGRADED     0     0     0
c0t0d0s0  ONLINE       0     0     0
c0t2d0s0  UNAVAIL      0     0     0  cannot open

errors: No known data errors

Now ZFS is angry because we wrote random data to the disk.

# zpool online  rpool  c0t2d0s0

# installboot -F zfs /usr/platform/`uname -i`/lib/fs/zfs/bootblk /dev/rdsk/c0t2d0s0

Comments

force dhcpd to log to it’s own file with syslog-ng

So I did not want my dhcpd messages to be lumped in with all the other /var/log/syslog messages.  I am running Debian 5 with comes running with syslog-ng.  While syslog-ng is much more customizable then plain syslog, it can also be very confusing.  Below is a example of all that I had to add to make syslog send all dhcpd messages to /var/log/dhcpd.log.  All I had to do was add those lines to the end of the /etc/syslog-ng/syslog-ng.conf configuration file, and then restart syslog-ng with /etc/init.d/syslog-ng  restart.  Did not even have to touch /var/log/dhcpd.log, syslog-ng took care of creating that while writing the first log entry.

filter f_daemon     {facility(daemon); };
filter f_dhcpd       {match(“dhcpd”); };
destination dhcpmessages { file(“/var/log/dhcpd.log”); };
log { source(s_all); filter(f_daemon);  filter(f_dhcpd); destination(dhcpmessages); };

Comments

« Previous entries Next Page » Next Page »