Wednesday, March 7, 2012

How To Virtualize a Barracuda Spam & Virus Firewall

We just got a brand new 200 series because we have too many users for the 100, and there is no 200Vx, only a 100Vx or a 300Vx with the 200Vx oddly left out of the lineup.  I decided to try and virtualize it just to see if i could.  The answer is yes!  It's pretty easy to virtualize the device for vmware without having to open the case.  You can also use these steps to make a backup (clone) image of the hard drive in case it fails.  Then you could use the image to restore your barracuda to a replacement hard drive

My barracuda does not have the tulip network driver so I was unable to get it working in Hyper-V, but VMware workstation worked great for me.  Some other posts talk about IDE hard drives, USB cd boot in bios, which my device does not support.  I may have a newer revision which is an atom D525 in what looks like a rebranded supermicro 1u chassis and a 250gb Seagate Barracuda hard drive (har har).

I don't recommend it but if you are looking to play around you can unlock many of the features from the higher end models fairly easily.  Look at the last few steps of the post to learn more about how to do that, just note that it requires you to have root access to the machine.

Power it up:

  1. Press p at the bootloader pictured above
  2. The grub bootloader password is bimg
  3. Press e on barracuda
  4. Press e on the second line, scroll to the end, and add init=/bin/bash
  5. Once you get a command prompt, mount –o remount,rw /
  6. Remove the root password in /etc/shadow (I copied shadow to shadow.bak so I could put the box back to factory if i ever needed)
  7. Reboot
  8. Press p at the barracuda boot splash screen (this is a grub boot loader)
  9. Press e on barracuda
  10. Press e on the second line, scroll to the end, and add the word single after the word quiet
  11. Press b for boot
  12. Log in as root (this is why we removed the root pw)
  13. Connect a usb drive that is the same size or larger than your barracuda, mine has a 250gb sata disk (I formatted my external /dev/sdb1 as ext3)
  14. mkdir /mnt/usb
  15. mount /dev/sdb1 /mnt/usb
  16. dd if=/dev/sda of=/mnt/usb/barracuda.img
  17. Now you have a backup image on your USB hard drive. I connected it to another linux server, copied it to my windows server and used starwind v2v to convert the raw image to an expanding virtual machine image. 
  18. If you convert it to a VMWare Virtual Machine it will work just fine, boot it up
  19. Edit the boot loader and add init=/bin/bash to the end of the entry
  20. Once you have a prompt mount the partition read/write: mount -t remount, rw /
  21. Edit /etc/fstab and change all of the sda[x] entries to be hda
  22. Edit /boot/grub/menu.lst and change the sda entries to hda.
  23. Optional: remove the bootloader password in /boot/grub/menu.lst
  24. Optional: allow yourself to SSH to it: iptables -I INPUT -p tcp --dport 22 -s 192.168.0.0/16 -j ACCEPT
    1. To make this persistent add an entry in /etc/sysconfig/iptables
  25. Optional: to SSH in to it you will need a root password, so log in to the box as root and set one
  26. Optional: If you want to add some features that are in the higher end models this post tells you what files to create to unlock them:  http://blog.shiraj.com/index.php/2009/09/barracuda-spam-firewall-root-password/
  27. Optional: If you want to unlock even more than you can find in that post you will need to do a little work.  Look for the file Features_table.pm on the filesystem, and create a blank file in /etc/barracuda/features for each feature you want to enable. Beware, many of the features are meant for higher end models so some features may not work or may have unexpected behaviors.

Friday, March 2, 2012

Barracuda Spam & Virus Firewall 200 Review

Unboxing and configuration:
We've had an old custom postfix/spamassassin/amavis setup for the last several years that has been catching less and less email.  I set it up many years ago and no longer remember how, and was never all that great at tweaking it beyond the basic settings.  With the complexity of spam and the amount that has been getting through we decided it was time to find a new solution and started looking in to our options.  We have 120 users at the moment with another 50-100 distribution groups, so I'm not really interested in any option where I have to go in and enter each user and assign distribution groups to user accounts.  This makes most hosted options difficult, and with 120 users it can get expensive.  We started looking at appliances and ended up getting the Barracuda Spam & Virus Firewall 200 with 1 year of energize updates, which cost us $1,900.  We were looking for a virtual appliance but for some odd reason barracuda only makes a 100vx and a 300vx, but no 200vx.  The cost of the 200 was cheaper than the 300vx and we don't really need the extra features of the 300vx.

Plugging the unit in was quite simple, it fired up in a couple minutes.  The short page it comes with says to hold down the reset button for several seconds to set the IP address to one of the 3 options which was quite handy.  It took a minute but eventually it loaded on the requested address.  I signed in with the default admin/admin and went to change the IP address to a valid one.  This is where I ran in to my first annoyance with the device.  Every section has a save changes button next to it, but you MUST enter all of "required" options or it won't save, it will instead clear everything you entered and make you try again.  This wouldn't be so annoying if the save changes button wasn't under every section, it highlighted what was required, and then didn't reset everything if it didn't like something.  The usability here is very poor, the interface feels like it was built in 1995.
*Update* I talked to Barracuda support and they know the usability of some of the interfaces isn't very good, it's been reported to the engineers but it sounds like they have no inclination to fix it.


With the IP configured I went and set up spam to tag all email as [spam], disabled bouncing messages and disabled the quarantine so we could see how well it is working.  I went to the domains tab, added my domain and then sent a test message.  The barracuda blocked my messages because it was sent to an invalid domain even though I had just added it to the domains list.  After messing with this for a while i eventually rebooted the device, and it started working.  After a while I added another domain I needed and it did the exact same thing.  The only way to add a domain to the device appears to be to add it, and then reboot it.
*Update* I talked to Barracuda support and this is a known bug in the firmware.  Apparently you can hit reload instead of reboot and that will apply the changes.  They have no ETA for a fix.

Features
The Barracuda Spam & Virus Firewall 200 has a lot of features.  If you look at the configuration page (you can see a demo of it here: http://www.barracudanetworks.com/demos.php) there are a lot of options to play with.  One interesting feature is the Exchange Anti-Virus Add-in that installs a virus scanner in your exchange environment so any internal messages get scanned as well.  This is useful if a virus gets in to your network before the barracuda has the definitions to catch it, the exchange server can then catch it if it gets sent to anybody else.  I haven't played with it but if I decide to keep the device I will.

The device can be configured to back up important data to an FTP server or a network share, another useful feature in the event the device fails.  In the case of  FTP you need to make sure any directory you specify exists, as the barracuda will not attempt to create it if it does not exist.  

Barracuda Reputation is Barracuda's shared blacklist with information from all of our devices.  By default messages are blocked, I chose to tag instead of block because I don't want an important message to get blocked because of the BRBL.

Attachment Filtering allows you to have the barracuda handle file types you may not want to accept (.exe for example), they have a predefined list and then you can enter any others you want.

Pattern filtering allows you to have the barracuda watch email for specific things like credit card numbers or other sensitive information you may want to control from coming in our out.  I don't plan to use this feature but I can see how it could be useful.

Another very useful feature is the Reverse DNS tab where you can block entire countries.  If you don't ever correspond with anybody in Russia you can very easily block all email coming from there:


How well it works:
We've only been running it for 24 hours and it's processed 43,184 emails, tagged 6,012, and allowed 2,484.  We have been running this inline with our previous spam filter so we can see how they do relative to each other and the barracuda seems to be catching around 10% more than the old solution, and very rarely fails to tag a message the old system did.  I'd say performance wise once you have it running the device does a pretty good job.  Hopefully it continues to work well in the future!

Wednesday, February 29, 2012

Adventures with Forefront TMG


We wanted to be able to block users from accessing non business related websites, but only wanted the restriction to be in effect when the user was actually clocked in to their project.  Web surfing on breaks and lunch has always been allowed at our company, and we didn’t want to restrict this, just restrict unauthorized use during work.

We decided to look at Microsoft’s Forefront Threat Management Gateway server, or TMG.  This product has the ability to set various filters for web blocking, and might be suitable for our needs.  Just one problem:

How do we make Forefront aware of a specific user’s “status”, as to whether they are clocked in or out?

Forefront can apply its filtering rules based on the IP address or network segment from which the request originates.  It can also filter based on the user name of the person asking for the website.  Unfortunately, there do not seem to be any other external “triggers” that can be used, so we determined that we would try it using AD authentication.

We set up and configured a test TMG environment, and joined it to our domain.  (For a very helpful step-by-step instruction on how to get TMG up and running, take a look at Raihan Al-Beruni’s blog HERE.)

Once it was configured, we did the following:

1.       Created two rules under Firewall Policy in TMG.  One was the “Allow” rule, essentially letting any traffic through.  The other was the “Deny” rule, which restricted users to only accessing sites related to our business
2.       Created two Groups in AD, one called “Filtered” and the other “Non Filtered”
3.       Under the Properties of the Allow rule, we set the Users to be members of the “Non Filtered” group
4.       Under the Deny rule, the “Filtered” group
5.       Apply all the settings, and then add our test user to the “Filtered” group
6.       Test access for the test user.  Success! They could only access the sites allowed by the rule.

Unfortunately, this is where we hit our first snag.  We moved the user from the “Filtered” to the “Non Filtered” group, and… they were still filtered.  A 2nd test user in the “Non Filtered” group had regular access.  Looking at the TMG logs we could see that the rules were being applied. 

TMG appeared to be only pulling the AD group membership information when it encountered a new name.  Eventually, after several hours in some cases, the membership was re-authenticated, and the appropriate rule was applied.  But this was not going to work for someone who was clocking out for a 15 minute break!

Some further experimentation showed that the “TMG Client” software for the desktop was designed to handle some authentication duties.  So, we experimented with adding the Client.

That was the trick!  A change in AD Group membership was reflected instantly on the TMG server, and the client’s access was adjusted accordingly.

Except…it was instant only if the change was applied to the same DC that the TMG server uses.  Otherwise, we had to wait for AD replication, which could take several minutes.

However, we now have a solution.  A TMG Server with the appropriate rules, and the TMG client on the desktop, and we can change a user’s access as often as we wish.  And there can be as many different rules as we have projects.  We have complete flexibility regarding what sites are filtered and what sites are allowed.

Wednesday, February 15, 2012

Outlook Sent and Deleted Items hack

Many of our Outlook users manage “shared” or "additional" email boxes.  Unfortunately, Microsoft’s default actions for email is to store “Sent” or “Deleted” emails in the primary user’s account folders.  Multiple people may be accessing these shared accounts, and it is difficult to track if messages have been sent, or accidentally deleted, if those messages could be stored on one of any number of different user’s email accounts.

However, we have found a way around this problem.  There are registry “hacks” which can be applied which force the Sent and Deleted items to be stored in the email account of their origin.


Fix for Sent Items:

  1.     Click Start, click Run, type regedit, and then click OK.
  2.     Locate and then click the following registry subkey: HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Preferences
  3.     On the Edit menu, point to New, and then click DWORD Value.
  4.     Type DelegateSentItemsStyle, and then press ENTER.
  5.     Right-click DelegateSentItemsStyle, and then click Modify.
  6.     In the Value data box, type 1, and then click OK.

Fix for Deleted Items:


  1.     Click Start, click Run, type regedit, and then click OK.
  2.     Locate and then click the following registry subkey: HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Options
  3.     Look for a subkey called “General”
  4.     If it doesn’t exist, Right-click on Options, select New Key, and name the key "General"
  5.     Navigate to HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Options\General
  6.     On the Edit menu, point to New, and then click DWORD Value.
  7.     Type DelegateWastebasketStyle, and then press ENTER.
  8.     Right-click DelegateWastebasketStyle, and then click Modify.
  9.     In the Value data box, type 4, and then click OK.


These new registry settings have to be set on each individual’s machine.  It would be possible to use a Group Policy to apply this across your organization, if needed.

Tuesday, January 17, 2012

How to Configure an HP EVA 5000 for Windows Server 2008 R2 MPIO

We have an older HP EVA 5000 and we wanted to use it with Windows Server 2008 R2, Hyper-V, Cluster Shared Volumes, and MPIO.  With the newer EVA 5000 active-active firmware, we're running version 4.1 or 4100, we simply had to configure the hosts in the Command View EVA manager.  Set the operating system type to custom, and enter 00000004198009A8 as your custom type [documentation for server 2008 available here].  Your host should look like this in command view:

Then discover MPIO devices on your server and you should see "COMPAQ HSV111 (C)COMPAQ".  I believe with the active-passive firmware you would see "COMPAQ HSV110 (C)COMPAQ".

With the active-passive firmware (something like EVA 3.110) you would need additional configuration for each drive you present.  Each drive on each host would need to be configured to use the paths for just one controller at a time to make the drive accessible / usable on older EVA firmwares.  With the active-active firmware no additional configuration is necessary.

If you have an EVA running firmware 3.110 and you want to do this you will need to track down a copy of the newest firmware and make sure your license supports it.  HP will not give you a license to run your EVA 5000 if you don't have one, although we managed to get them to make us a new license after many days of pestering many different people in many different departments.

As of writing the 4.1 (4100) firmware is available on HP's site here: ftp://ftp.hp.com/pub/softlib/software9/COL21081/co-55464-1/T3588-10019.iso
and the 3.110 (3110) firmware is available here:
ftp://ftp.hp.com/pub/softlib/software8/COL19159/co-49829-1/EVA_GL_CONTROLLER_FIRMWARE_v3110.zip

I can't find a link to it, but the the Command View software is in an ISO named HP_StorageWorks_Command_View_EVA_v9.3_Software_T5494_10022.ISO

How to grant full access permissions to every mailbox in Exchange 2010

I needed to access 75 mailboxes across multiple mailbox databases and didn't want to grant myself full access permissions to them one at a time so i went searching for a solution.  This nifty command granted me access to every mailbox in the company:

Get-MailboxDatabase  | Add-ADPermission -user <myusername> -AccessRights GenericAll -InheritanceType All


I found a variation of this command in a technet forum post available here and modified it to give myself access to all mailboxes, and set inheritance.

HTH

Tuesday, November 22, 2011

How to Dedupe a SQL Database Table

We had some log files get parsed twice this morning and accidentally fed the same data in to our table twice due to a race condition.  Removing the extra records was fairly simple, I started out simply trying to find the duplicate rows and expanded from there to remove the extra records.

calllogid is the primary key in the table
uicallid is a row that _should_ be unique but is not because of data from a legacy system being imported in to the table

The logs that were imported twice were identical in every way except for the calllogid, and I chose to match on uicallid because that is a unique value that should never be duplicated.

I started out trying to get the calllogid of every record that was duplicated and I used a subquery to do this:
SELECT 
count(uicallid) as count,
( SELECT TOP 1 CallLogID from dbo.tablename as sub where sub.uicallid = main.uicallid) as id 
FROM dbo.tablename as main 
group by main.uicallid
having count(main.uicallid) > 1 


Manually checking the output I was able to see how many times each record was duplicated and each record from this morning showed up twice, just as i expected.  Once I was confident I had the correct data selected I asked a coworker for help and I was taught you could do a delete where fieldname IN (<a subquery>).  


Now the final query looks like this:



DELETE FROM dbo.tablename
WHERE CallLogID IN ( select
( SELECT TOP 1 CallLogID from dbo.tablename as sub where sub.uicallid = main.uicallid) as id 
FROM dbo.tablename as main 
group by main.uicallid
having count(main.uicallid) > 1 )



The query to delete the duplicate records ran on the 5.5 million row 1GB table in 15 seconds, and it took 3 seconds to do the select to find them.  Not tooo bad.  If there was more than one duplicate entry this query would only delete one of them, so the query would need to be run multiple times to delete multiple entries.