{"id":269,"date":"2009-06-07T08:42:06","date_gmt":"2009-06-07T08:42:06","guid":{"rendered":"http:\/\/g33kinfo.com\/info\/index.php\/?p=269"},"modified":"2009-06-07T08:42:06","modified_gmt":"2009-06-07T08:42:06","slug":"running-your-own-rbl-dns-blacklist","status":"publish","type":"post","link":"https:\/\/g33kinfo.com\/info\/running-your-own-rbl-dns-blacklist\/","title":{"rendered":"Running Your Own RBL DNS Blacklist"},"content":{"rendered":"<p>Ever notice how the public RBL databases aren&#8217;t enough? spamcop and spamhaus are great, but there are spammers still getting through. Did you ever want to do it yourself?<\/p>\n<p>This procedure explains how to run your own RBL DNS Blacklist. It uses a mysql table to store the IP address you want to blacklist and whitelist. Based on this data, it rebuilds a flatfile that the dns server uses on a regular basis. I prefer every 5 minutes. I run it on a Blue Quartz server which is CentOS Linux (Red Hat EL4) based. You will need a local mysql server.<br \/>\nStep 1:Download the RBL DNS Daemon<\/p>\n<p>We use rbldnsd from here<br \/>\nDownload the rbldns server:<br \/>\nRHEL 4 \/ CentOS 4 rbldnsd RPM ver. 0.995<br \/>\nRHEL 5 \/ CentOS 5 rbldnsd RPM ver 0.995<br \/>\nSource rbldnsd RPM ver 0.996b<br \/>\nStep 2: Turn off any existing DNS server<\/p>\n<p>Make sure you are not already running a DNS server on this machine. Turn off &#8220;named&#8221; if its on.<\/p>\n<p>service named stop<\/p>\n<p>Step 3:Install the RPM<\/p>\n<p>useradd rbldns<br \/>\nrpm -Uvh rbldnsd*.rpm<\/p>\n<p>Step 4: Create a mysql table<br \/>\nMake sure the MySQL server is running.<\/p>\n<p>CREATE TABLE `ips` (<br \/>\n  `ipaddress` varchar(15) NOT NULL default &#8221;,<br \/>\n  `dateadded` datetime NOT NULL default &#8216;0000-00-00 00:00:00&#8217;,<br \/>\n  `reportedby` varchar(40) default NULL,<br \/>\n  `updated` datetime default NULL,<br \/>\n  `attacknotes` text,<br \/>\n  `b_or_w` char(1) NOT NULL default &#8216;b&#8217;,<br \/>\n  PRIMARY KEY  (`ipaddress`),<br \/>\n  KEY `dateadded` (`dateadded`),<br \/>\n  KEY `b_or_w` (`b_or_w`)<br \/>\n) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT=&#8217;spammer list&#8217;;<\/p>\n<p>You may want to create a mysql user just for this purpose with limited permissions.<br \/>\nStep 5: Download the perl script that rebuilds the flat file from a mysql database<br \/>\nrebuild_rbldns.pl script<br \/>\nPut this script in \/usr\/local\/bin<\/p>\n<p>wget -O \/usr\/local\/bin\/rebuild_rbldns.pl http:\/\/www.blue-quartz.com\/rbl\/rebuild_rbldns.txt<br \/>\nchmod 750 \/usr\/local\/bin\/rebuild_rbldns.pl<\/p>\n<p>You will want to put this in the root cron and run it every 5 minutes<\/p>\n<p>crontab -e<br \/>\n*\/5    *       *       *       *       \/usr\/local\/bin\/rebuild_rbldns.pl<\/p>\n<p>Please edit lines 25-27 of this perl script to change your mysql user and password.<br \/>\nStep 6: Edit the \/etc\/sysconfig\/rbldnsd config file<\/p>\n<p># My boot rbldnsd options<br \/>\n# &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n# TTL 35m, check files every 60s for changes, -f = smooth reloads<br \/>\n# -l logfilepath<br \/>\n# Please change 101.102.103.104 to your real public IP that you want the dns daemon to listen on<br \/>\n# Please change mydomain.com to your real domain name.<br \/>\n#<br \/>\nRBLDNSD=&#8221;dsbl -l \/var\/lib\/rbldns\/log\/rbl.log -f -r\/var\/lib\/rbldns\/dsbl -b 101.102.103.104 \\<br \/>\n   rbl.mydomain.com:ip4set:spammerlist,whitelist \\<br \/>\n   rbl.mydomain.com:generic:forward<br \/>\n&#8221;<\/p>\n<p>Step 7: Create directory structure for flat file<\/p>\n<p>mkdir \/var\/lib\/rbldns\/dsbl<br \/>\ntouch \/var\/lib\/rbldns\/dsbl\/forward<br \/>\ntouch \/var\/lib\/rbldns\/dsbl\/spammerlist<br \/>\ntouch \/var\/lib\/rbldns\/dsbl\/whitelist<br \/>\ntouch \/var\/lib\/rbldns\/dsbl\/rbl.log<br \/>\nchown -R rbldns:rbldns dsbl<\/p>\n<p>Step 8: Add some records to the MySQL database you have of known spammers<\/p>\n<p>INSERT INTO ips SET<br \/>\nipaddress=&#8217;123.456.789.1&#8242;,<br \/>\nreportedby=&#8217;101.102.103.104&#8242;,<br \/>\nattacknotes=&#8217;dictionary attack from badboy.com&#8217;,<br \/>\nb_or_w=&#8217;b&#8217;,<br \/>\ndateadded=now(),<br \/>\nupdated=now();<\/p>\n<p>To help in diagnosing problems, add these entries in the &#8220;\/var\/lib\/rbldns\/dsbl\/forward&#8221; file:<\/p>\n<p>@ A 1.2.3.4<br \/>\ntest A 1.2.3.4<\/p>\n<p>And please replace 1.2.3.4 with the ip address of your rbl server.<\/p>\n<p>Step 9: Run the script to build the flat file<br \/>\n\/usr\/local\/bin\/rebuild_rbldns.pl and if you want to see if it actually created the file type this:<\/p>\n<p>cat \/var\/lib\/rbldns\/dsbl\/spammerlist<\/p>\n<p>Step 10: Start the rbldns service<\/p>\n<p>service rbldnsd start<\/p>\n<p>Step 11: Create a DNS subdomain zone for rbl.mydomain.com<br \/>\nYou must create a DNS zone (subdomain) in your main DNS server for rbl.mydomain.com and point it to your rbldnsd server.<\/p>\n<p>; subdomain delegation<br \/>\nrbl.mydomain.com.  in ns rbl.mydomain.com.<br \/>\nrbl.mydomain.com.  in a 101.102.103.104<\/p>\n<p>Step 12: test rbl.mydomain.com lookups<br \/>\nIf a blacklisted IP address is in your rbl database it will &#8220;exist&#8221; in the DNS system.<\/p>\n<p>For example:<\/p>\n<p>if you blacklisted IP 89.40.1.32<br \/>\nthen doing a regular DNS lookup like this:<\/p>\n<p>nslookup test.rbl.mydomain.com<br \/>\nnslookup 32.1.40.89.rbl.mydomain.com<\/p>\n<p>should result in a match of 127.0.0.2<\/p>\n<p>nslookup test.rbl.mydomain.com<\/p>\n<p>should result in a match for 1.2.3.4 (your public ip address of your rbl server). If this works then the file \/var\/lib\/rbldns\/dsbl\/forward is working.<\/p>\n<p>Every entry in your RBL database will return a match of 127.0.0.2<\/p>\n<p>If an IP address is not in your RBL database it will fail to find an entry. This is how mail servers know how to block relays of email from known spammers.<br \/>\nStep 13: Having Your Mail Servers Use This RBL database<br \/>\nIf you are using sendmail, and want it to use this database, do this:<\/p>\n<p>cd \/etc\/mail<br \/>\nvi sendmail.mc<br \/>\nmake<\/p>\n<p>add this line right below the &#8220;blacklist_recipients&#8221; line:<\/p>\n<p>FEATURE(dnsbl, `rbl.mydomain.com&#8217;, `Rejected &#8211; known spammer&#8217;)dnl<\/p>\n<p>Now sendmail will reject messages from bad IP addresses in your database. You can monitor your \/var\/log\/maillog file to see if sendmail really did block a specific IP.<br \/>\nStep 14: Filling your database with known spammers<br \/>\nNow you need to decide how you are going to add records to your MySQL table. I suggest you write a script that monitors mailboxes or mail server logs. This is a great way to discover those spammers that are getting through the system.<\/p>\n<p>I also wrote some PHP web pages with forms to allow me to quickly add IP&#8217;s to my blacklist. You might want to try that.<\/p>\n<p>In my dictionary attack monitoring scripts, I use this command to update the rbl database:<\/p>\n<p>wget -q -O \/dev\/null &#8216;http:\/\/rbl.domain.com\/drop.php?ipaddress=133.25.2.1&#038;blackorwhite=b&#038;notes=dictionary attack&#8217;<\/p>\n<p>This way all my servers can add to the database. Of course, only approved IPs in my network are allowed to submit rbl data. I ignore all others.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ever notice how the public RBL databases aren&#8217;t enough? spamcop and spamhaus are great, but there are spammers still getting through. Did you ever want to do it yourself? This procedure explains how to run your own RBL DNS Blacklist. It uses a mysql table to store the IP address you want to blacklist and&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/g33kinfo.com\/info\/running-your-own-rbl-dns-blacklist\/\">Read More<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-269","post","type-post","status-publish","format-standard","hentry","category-info"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Running Your Own RBL DNS Blacklist - Linux Shtuff<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/g33kinfo.com\/info\/running-your-own-rbl-dns-blacklist\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Running Your Own RBL DNS Blacklist - Linux Shtuff\" \/>\n<meta property=\"og:description\" content=\"Ever notice how the public RBL databases aren&#8217;t enough? spamcop and spamhaus are great, but there are spammers still getting through. Did you ever want to do it yourself? This procedure explains how to run your own RBL DNS Blacklist. It uses a mysql table to store the IP address you want to blacklist and... Read More\" \/>\n<meta property=\"og:url\" content=\"https:\/\/g33kinfo.com\/info\/running-your-own-rbl-dns-blacklist\/\" \/>\n<meta property=\"og:site_name\" content=\"Linux Shtuff\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/fb.me\/g33kinf0\" \/>\n<meta property=\"article:author\" content=\"https:\/\/fb.me\/g33kinf0\" \/>\n<meta property=\"article:published_time\" content=\"2009-06-07T08:42:06+00:00\" \/>\n<meta name=\"author\" content=\"g33kadmin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/drsinger1111\" \/>\n<meta name=\"twitter:site\" content=\"@drsinger1111\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/running-your-own-rbl-dns-blacklist\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/running-your-own-rbl-dns-blacklist\\\/\"},\"author\":{\"name\":\"g33kadmin\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"headline\":\"Running Your Own RBL DNS Blacklist\",\"datePublished\":\"2009-06-07T08:42:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/running-your-own-rbl-dns-blacklist\\\/\"},\"wordCount\":961,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"articleSection\":[\"General Info\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/g33kinfo.com\\\/info\\\/running-your-own-rbl-dns-blacklist\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/running-your-own-rbl-dns-blacklist\\\/\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/running-your-own-rbl-dns-blacklist\\\/\",\"name\":\"Running Your Own RBL DNS Blacklist - Linux Shtuff\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#website\"},\"datePublished\":\"2009-06-07T08:42:06+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/running-your-own-rbl-dns-blacklist\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/g33kinfo.com\\\/info\\\/running-your-own-rbl-dns-blacklist\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/running-your-own-rbl-dns-blacklist\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Running Your Own RBL DNS Blacklist\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#website\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/\",\"name\":\"Linux Shtuff\",\"description\":\"Because I have CRS Syndrome...\",\"publisher\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\",\"name\":\"g33kadmin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"contentUrl\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"width\":512,\"height\":512,\"caption\":\"g33kadmin\"},\"logo\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\"},\"description\":\"I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com\\\/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....\",\"sameAs\":[\"https:\\\/\\\/thelinuxreport.com\",\"https:\\\/\\\/fb.me\\\/g33kinf0\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/drsinger1111\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Running Your Own RBL DNS Blacklist - Linux Shtuff","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/g33kinfo.com\/info\/running-your-own-rbl-dns-blacklist\/","og_locale":"en_US","og_type":"article","og_title":"Running Your Own RBL DNS Blacklist - Linux Shtuff","og_description":"Ever notice how the public RBL databases aren&#8217;t enough? spamcop and spamhaus are great, but there are spammers still getting through. Did you ever want to do it yourself? This procedure explains how to run your own RBL DNS Blacklist. It uses a mysql table to store the IP address you want to blacklist and... Read More","og_url":"https:\/\/g33kinfo.com\/info\/running-your-own-rbl-dns-blacklist\/","og_site_name":"Linux Shtuff","article_publisher":"https:\/\/fb.me\/g33kinf0","article_author":"https:\/\/fb.me\/g33kinf0","article_published_time":"2009-06-07T08:42:06+00:00","author":"g33kadmin","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/drsinger1111","twitter_site":"@drsinger1111","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/g33kinfo.com\/info\/running-your-own-rbl-dns-blacklist\/#article","isPartOf":{"@id":"https:\/\/g33kinfo.com\/info\/running-your-own-rbl-dns-blacklist\/"},"author":{"name":"g33kadmin","@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"headline":"Running Your Own RBL DNS Blacklist","datePublished":"2009-06-07T08:42:06+00:00","mainEntityOfPage":{"@id":"https:\/\/g33kinfo.com\/info\/running-your-own-rbl-dns-blacklist\/"},"wordCount":961,"commentCount":0,"publisher":{"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"articleSection":["General Info"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/g33kinfo.com\/info\/running-your-own-rbl-dns-blacklist\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/g33kinfo.com\/info\/running-your-own-rbl-dns-blacklist\/","url":"https:\/\/g33kinfo.com\/info\/running-your-own-rbl-dns-blacklist\/","name":"Running Your Own RBL DNS Blacklist - Linux Shtuff","isPartOf":{"@id":"https:\/\/g33kinfo.com\/info\/#website"},"datePublished":"2009-06-07T08:42:06+00:00","breadcrumb":{"@id":"https:\/\/g33kinfo.com\/info\/running-your-own-rbl-dns-blacklist\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/g33kinfo.com\/info\/running-your-own-rbl-dns-blacklist\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/g33kinfo.com\/info\/running-your-own-rbl-dns-blacklist\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/g33kinfo.com\/info\/"},{"@type":"ListItem","position":2,"name":"Running Your Own RBL DNS Blacklist"}]},{"@type":"WebSite","@id":"https:\/\/g33kinfo.com\/info\/#website","url":"https:\/\/g33kinfo.com\/info\/","name":"Linux Shtuff","description":"Because I have CRS Syndrome...","publisher":{"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/g33kinfo.com\/info\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547","name":"g33kadmin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","url":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","contentUrl":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","width":512,"height":512,"caption":"g33kadmin"},"logo":{"@id":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif"},"description":"I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com\/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....","sameAs":["https:\/\/thelinuxreport.com","https:\/\/fb.me\/g33kinf0","https:\/\/x.com\/https:\/\/twitter.com\/drsinger1111"]}]}},"_links":{"self":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts\/269","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/comments?post=269"}],"version-history":[{"count":0,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts\/269\/revisions"}],"wp:attachment":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/media?parent=269"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/categories?post=269"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/tags?post=269"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}