Tag: ubuntu

  • Squid on Ubuntu

    I want to build a transparent squid proxy for home to play around with wccp configs. First step is to get a working squid proxy:

    cd ~
    wget http://www.squid-cache.org/Versions/v3/3.1/squid-3.1.4.tar.gz
    tar zxf squid-3.1.4.tar.gz
    cd squid-3.1.4

    sudo ./configure –prefix=/usr –localstatedir=/var –libexecdir=/usr/lib/squid –srcdir=. –datadir=/usr/share/squid –sysconfdir=/etc/squid –with-logdir=/var/log –with-pidfile=/var/run/squid.pid –enable-wccp

    make
    make install

    cd /etc/squid
    sudo vi squid.conf

    squid.conf:

    http_port 3128
    hierarchy_stoplist cgi-bin ?
    refresh_pattern ^ftp:           1440    20%     10080
    refresh_pattern ^gopher:        1440    0%      1440
    refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
    refresh_pattern .               0       20%     4320
    acl manager proto cache_object
    acl localhost src 127.0.0.1/32
    acl to_localhost dst 127.0.0.0/8
    acl localnet src 10.0.0.0/8     # RFC 1918 possible internal network
    acl localnet src 172.16.0.0/12  # RFC 1918 possible internal network
    acl localnet src 192.168.0.0/16 # RFC 1918 possible internal network
    acl SSL_ports port 443
    acl Safe_ports port 80          # http
    acl Safe_ports port 21          # ftp
    acl Safe_ports port 443         # https
    acl Safe_ports port 70          # gopher
    acl Safe_ports port 210         # wais
    acl Safe_ports port 1025-65535  # unregistered ports
    acl Safe_ports port 280         # http-mgmt
    acl Safe_ports port 488         # gss-http
    acl Safe_ports port 591         # filemaker
    acl Safe_ports port 777         # multiling http
    acl CONNECT method CONNECT
    http_access allow manager localhost
    http_access deny manager
    http_access deny !Safe_ports
    http_access deny CONNECT !SSL_ports
    http_access allow localhost
    http_access allow localnet
    http_access deny all

    start squid with: sudo squid -z

    check it is running: ps -el | grep squid

    Check the access log: cat /etc/access.log

    Next step is getting WCCP configured:

    http://wiki.squid-cache.org/Features/Wccp  & http://wiki.squid-cache.org/ConfigExamples/Intercept/LinuxDnat

  • Nagios on Ubuntu 8.1

    So I thought I’d try to find oout why my desktop and NAS keep arguing. Nagios. That will help. So I fired-up a spare piece of tin, dropped Ubuntu 8.1 onto it and followed some instructions. The instructions are a bit out of date so I thought I’d record how I actually did it in case it helps somebody else.

    Ubuntu

    I assume you have installed it with LAMP to save a lot of farting around. If not, aptitude yourself to a point where you have then come back here.

    Compilers and Libraries

    sudo apt-get install build-essential

    sudo apt-get install libgd2-xpm-dev

    Nagios

    cd ~

    sudo wget http://downloads.sourceforge.net/nagios/nagios-3.1.0.tar.gz?use_mirror=voxel

    sudo wget http://downloads.sourceforge.net/nagiosplug/nagios-plugins-1.4.13.tar.gz?use_mirror=voxel

    Extract it (If you have a newer build of Nagios, change the path names below):

    sudo tar -zxvf nagios-3.1.0.tar.gz

    cd nagios-3.1.0

    Create a user and Group:
    sudo useradd -m nagios

    sudo passwd nagios

    sudo groupadd nagcmd

    sudo usermod -a -G nagcmd nagios

    sudo usermod -a -G nagcmd www-data

    Now we can install….

    sudo ./configure --with-command-group=nagcmd

    sudo make all

    sudo make install

    sudo make install-init

    sudo make install-config

    sudo make install-commandmode

    sudo make install-webconf

    Create an Apache user we can login as called nagiosadmin:

    sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

    Extract and compile the plugins that were downloaded earlier:

    cd ~

    tar -zxvf nagios-plugins-1.4.13.tar.gz

    cd nagios-plugins-1.4.13

    sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios

    sudo make

    sudo make install

    Create a link to start the service:
    sudo ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios

    Verify the config:
    sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

    Restart Apache:
    sudo /etc/init.d/apache2 restart

    Start Nagios:
    sudo /etc/init.d/nagios start

    You should now be able to log into the Nagios web interface (http://localhost/nagios) using the nagiosadmin user and password.

    Customise your installation…

    sudo vim /usr/local/nagios/etc/nagios.cfg

    I have to credit thedailyadmin.com for helping me out with a lot of the above. I urge you to go visit that site if only to stop me feeling guilty .

  • Shifting to Googlemail

    I run my own mailserver and Store-and-Forward server. But getting an iphone means the pain of getting IMAP working or worse still, using POPand having a split-brain email with the iphone and desktop is just getting old.

    So I’ll dump everything into Googlemail. But…..

    I use a load of aliases for incoming mail on my trusty Mercury server. I’m going to need to redo all my alias entries in Mercury to point to my Googlemail account. The mail server will be running a bit longer.

    I may just retire Mercury if I can remember how postfix aliases or virtual alias domains work. Postfix runs on the S&F box. If I write my aliases out there, it can route my mail for me. It will basically be an MX placeholder and hold no actually mailboxes. Mmmm

    Mercury is GUI. It is stable but needs Windows. I’m tempted to see if there is a hosted alternative or a postfix aliases gui…..

    Uploading mail to Gmail via IMAP just keeps failing. There is a useful tool called GML which just might make this work for me. First though I need to run Thunderbird and add a plug-in to put my mail into an MBox file…..

    But in the end I have dropped all my mail into Thunderbird, created an IMAP account and am shifting messages in blocks of 20. That actually works….

  • Postfix Store-and-forward

    After having a little outage due my my ADSL router deciding to take a couple of hours off, I decided I really really really did need to sort out a secondary MX. I have a little Ubuntu server in a rack offsite that I toyed with for a while but never seriously did anything with once I got distracted with other things.

    Now of course it is going to be my store-and-forward server for when my home mail server disappears off the big scary Internet. A Store-and-forward server is basically a mail server that relays mail for a certain list of known domains. It will also be prepared to hold mail in the queue for a few days until the primary is back to life.

    The best description and config help I found was here. Well worth a look if you want to do this kind of thing yourself for free on old hardware for when that expensive Exchange mail server (or in my case cheap Mercury server) decides it doesn’t want to play any more.

    Postfix is currently not being too helpful and I’m going to rip-and-replace it. It should be a simple config but I couldn’t help trying to refine it. Oops. It also doesn’t help that I seem to fallen foul of the “smtp fixup” provided by the over-eager Cisco ASA sitting in front of it.

    Another good site for novice Postfix admins is here. It lists a verbose config with lots of good little security-conscious snippets.

    One way to achieve a store-and-forward server is to use Postfix aliases. An Alias file will allow your server to be the server listed as the MX in your domain zone file but then incoming mail is redirected to a server with a real mailbox. Here is an extract from my main.cf to show you how I did it:

    # Do not relay anything  
    #relay_domains = $mydestination
    #relay_recipient_maps = hash:/etc/postfix/relay_recipients
    
    # Aliases is what we want to do
    alias_maps = hash:/etc/aliases
    
    # start virtual domains section, list all the domains we receive email for and the file containing the mappings
    virtual_alias_domains = simkin.org, orangeteapot.co.uk
    virtual_alias_maps = hash:/etc/postfix/virtual
    
    # security fixes
    disable_vrfy_command = yes
    smtpd_helo_required = yes
    allow_percent_hack = no
    swap_bangpath = no
    smtpd_sasl_authenticated_header = yes
    smtpd_helo_restrictions = reject_unknown_helo_hostname
    smtpd_client_restrictions = permit_mynetworks,
                                reject_rbl_client zen.spamhaus.org,
                                reject_invalid_hostname,
                                warn_if_reject,
                                reject_unknown_reverse_client_hostname,
                                reject_non_fqdn_helo_hostname,
                                reject_unauth_pipelining,
                                reject_invalid_helo_hostname,
                                permit
    
    smtpd_recipient_restrictions = permit_mynetworks,
                                   check_client_access cidr:/etc/postfix/client_checks,
                                    permit_sasl_authenticated,
                                    reject_unauth_destination,
    
    smtpd_sender_restrictions = reject_unknown_sender_domain
    smtpd_data_restrictions = reject_unauth_pipelining
    # end security fixes
    
    mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
    mailbox_command = procmail -a "$EXTENSION"
    mailbox_size_limit = 0
    recipient_delimiter = +

    For the “Client Checks” section, see this post.

    Then build your alias table to pass incoming mail to a particular email address to go to wherever you want.

     nobody@simkin.org    myrealmailbox@gmail.com

    Save the file to /etc/postfix/virtual and run

    postmap virtual
    /etc/init.d/postfix reload