स्मार्ट टीवी - शायद नहीं देख रहा। लेकिन फिर भी ...

SmartTV . , IP , DNLA , youtube skype.

( , ) , .. «» — , -…

.

Mikrotik, , dns .
, .

.

:
  • , — .

    "msecnd.net";

    *
    "*.adform.net";
  • NameAddressList — AddressList firewall


— 1 .

firewall , SmartTV ( , NameAddressList)
chain=forward action=reject reject-with=icmp-network-unreachable src-address=192.168.100.123 dst-address-list=BlockSpySmartTV log=no log-prefix="BlockSpySmartTV: " 

192.168.100.123 — .

:
  • — ip Mikrotik
  • IP TTL . TTL=0, TTL=59 .
  • firewall IP .

, 1 ( ) — IP .

— IP . .

:


— — .

:local NameAddressList "BlockSpySmartTV"

#  
:local DNSDomains {
	"*.samsungelectronics.com";
	"*.samsungcloudsolution.com";
	"*.samsungcloudsolution.net";
	"*.samsungcloudsolution.com";
	"*.samsungrm.net";
	"*.samsungotn.net";
	"*.samsungosp.com";
	"*.internetat.tv";
	"*.samsungyosemite.com";
	"*.cloudfront.net";
	"*.google-analytics.com";
	"*.googletagservices.com";
	"*.googlesyndication.com";
	"*.amazonaws.com";
	"*.krxd.net";
	"*.cloudapp.net";
	"*.doubleclick.net";
	"*.xiti.com";
	"*.pavv.co.kr";
	"*.adform.net";
# youtube
#"*.ytimg.com";
#
	"msecnd.net";
}

#  
:local QuantDNSDomains [:len $DNSDomains]

:for iDNSDomain from=0 to=($QuantDNSDomains-1) do={ 

#  
	:local CurrentDNSDomain (:put ($DNSDomains->($iDNSDomain)))
	:log debug " CurrentDNSDomain:'$CurrentDNSDomain'"

	:local prfx [:pick $CurrentDNSDomain 0 1];
	:log debug " prfx:'$prfx'"
	:if ($prfx != "*") do={

#  dns     dns
		:foreach i in=[/ip dns cache all find where (name~$CurrentDNSDomain ) ] do={
#   dns   ip  
			:local cacheName [/ip dns cache get $i name] ;
			:local tmpAddress [:resolve $cacheName]
			:log debug " cacheName :'$cacheName' tmpAddress:'$tmpAddress'"

#prevent script from using all cpu time
			delay delay-time=10ms

#      
			:if ( [/ip firewall address-list find where address=$tmpAddress] = "") do={ 
				:local cacheName [/ip dns cache get $i name] ;
				:local cacheNameTTL [/ip dns cache get $i ttl] ;

#  ttl<1m,  ttl=1m
				:log debug " cacheNameTTL: $cacheNameTTL "
				:if ( $cacheNameTTL < "00:00:59" ) do={
					:set cacheNameTTL "00:00:59"
					:log debug " SET cacheNameTTL: $cacheNameTTL "
				}

				:log warning (" added entry: dns-name: $cacheName ip-addr:$tmpAddress ttl:$cacheNameTTL ");
				/ip firewall address-list add address=$tmpAddress list=$NameAddressList comment=$cacheName timeout=$cacheNameTTL ;
			}
		}
	} else {
#   - 
		:set CurrentDNSDomain [:pick $CurrentDNSDomain 1 [:len $CurrentDNSDomain] ];

#  dns     dns
		:foreach i in=[/ip dns cache all find where (name~$CurrentDNSDomain ) ] do={
#   dns   ip  
			:local cacheName [/ip dns cache get $i name] ;
			:local tmpAddress [:resolve $cacheName]
			:log debug " cacheName :'$cacheName' tmpAddress:'$tmpAddress'"

#prevent script from using all cpu time
			delay delay-time=10ms

#      
			:if ( [/ip firewall address-list find where address=$tmpAddress] = "") do={ 
# ttl     dns
				:local cacheNameTTL [/ip dns cache get $i ttl] ;

#  ttl<1m,  ttl=1m
				:log debug " cacheNameTTL: $cacheNameTTL "
				:if ( $cacheNameTTL < "00:00:59" ) do={
					:set cacheNameTTL "00:00:59"
					:log debug " SET cacheNameTTL: $cacheNameTTL "
				}

				:log debug (" CurrentDNSDomain: '$CurrentDNSDomain' added entry: dns-name: $cacheName ip-addr:$tmpAddress ttl:$cacheNameTTL ");
				/ip firewall address-list add address=$tmpAddress list=$NameAddressList comment=$cacheName timeout=$cacheNameTTL ;
			}
		}
	}
}



Update 2017.06.13
RouterOS 6.36 — dns , ip . .

github.com/ErshovSergey/Mikrotik_update_AddressList_ip

Source: https://habr.com/ru/post/hi389821/


All Articles