One of my Linux boxes has a direct cable connection to the internet. I’ve been using Snort in corporate environments for a long time now, but I never had to configure snort to look at interfaces that have a DHCP assigned IP address and actually use that IP address as its HOME_NET.
There’s an easy way (which may not work with an older version of Snort), and there’s a somewhat ‘harder’ way (With a couple of scripts, this can be done as well).
The easy way consists of using a Snort variable that refers to the Ethernet interface. Use the following line in your snort.conf file and you should be fine. var HOME_NET $eth1_ADDRESS
If that doesn’t work, you can use the scripts.
Before going into the details, I need to make some assumptions :
First of all, you need to build the snort.conf file. Just leave out the HOME_NET setting at the top of the script. My snort installation sits under /snortinternet. Put the (incomplete) snort.conf file (the file without the ‘var HOME_NET=’ entry somewhere else (under /root/conf for example)
Create a script called ‘geteth1.sh‘ and put it under /root/bin. This script contains the following commands :
(This script will output the IP address that is assigned to eth1)
Next, create another script called ‘createsnortconf.sh‘ and save it under /root/bin :
echo ‘var HOME_NET [‘`/bin/bash /root/bin/geteth1.sh`’/32]’>/root/conf/snorttop.conf cat /root/conf/snort.conf >>/root/conf/snorttop.conf cp /root/conf/snorttop.conf /snortinternet/snort.conf
This script basically grabs the IP address of eth1, stores it into a temporary file, puts the temporary file and the (incomplete) snort.conf file from /root/bin together and overwrites the /snortinternet/snort.conf file with the new file.
If you keep you snort.conf file somewhere else, just edit the paths in the script and you’ll be fine.
Next, make sure to run the script prior to starting snort. I usually create a ‘runsnort.sh’ script that will fire up snort with the necessary parameters, so that would be a good place to launch the script from.
Note : if you decide to make changes to your snort.conf, make sure to change the snort.conf file under /root/conf and then run the createsnortconf.sh script again to apply the changes to the /snortinternet folder.
Tags:
© Corelan Consulting BV. All rights reserved. The contents of this page may not be reproduced, redistributed, or republished, in whole or in part, for commercial or non-commercial purposes without prior written permission. See the Terms of Use and Privacy Policy for details.