Mikrotik Firewall Address list to BGP Network Script (@SAN-IDC)

#Address List to BGP Network by GamerXP Network
#Exclusive for SAN-IDC
#gamerxp.network@gmail.com
#2016

:local bgpip; :set bgpip ""; :local blacktoholeip; :set blacktoholeip "";

:foreach PREFIXID in [/routing bgp network find disabled=no] do={
	:set bgpip [/routing bgp network get $PREFIXID network];
	:if ( [:typeof [:find $bgpip "/32" 0]] = "num" ) do={
		:if ( [:typeof [:find $bgpip ":/32" 0]] = "nil" ) do={
			:set $bgpip [:pick $bgpip 0 ([:len $bgpip]-3)];
			:if ( [:len [/ip firewall address-list find address=$bgpip list=blackhole-bgp]] = 0 ) do={
				:do {
					/routing bgp network remove $PREFIXID;
				} on-error={};
			}
		}
	}
};

:foreach ADDRID in [/ip firewall address-list find list=blackhole-bgp] do={ 
	:set blacktoholeip [/ip firewall address-list get $ADDRID address]; 
	:do {
		/routing bgp network add network="$blacktoholeip/32" synchronize=no;
	} on-error={};
};

This scripts work with dynamic entries (Address-list expiring will works).

Run this script for every seconds. All address in list named "blackhole-bgp" will be automatically synced to BGP network announce with /32.
Please use filter to add bgp community so your transit will know that you want to blackhole them.