Throttle Windows Updates

Hi

I,m trying to throttle windows updates.

Any ideas

I use a address list (doesn't work because updates.windows.com changes ip)
Mark the connection
Use a simple queue to limit connection

ip firewall address-list print
Flags: X - disabled, D - dynamic

LIST ADDRESS

0 Updates 65.55.200.156
1 Updates 80.239.201.155

ip firewall mangle print
Flags: X - disabled, I - invalid, D - dynamic
0 chain=prerouting action=mark-packet new-packet-mark=Update passthrough=yes
protocol=tcp dst-address-list=Updates

/queue> simple print
Flags: X - disabled, I - invalid, D - dynamic
0 name="Updates" target-addresses=0.0.0.0/0 dst-address=0.0.0.0/0
interface=all parent=none packet-marks=Update direction=both priority=8
queue=default-small/default-small limit-at=64k/64k max-limit=64k/64k
burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s
total-queue=default-small

I tried to use this script to update the ip

this script just add another address in the address list, in a few days i will fill my HDD wit the address list.

Any good ideas welcome



:foreach i in=[/ip dns cache find] do={
:local bNew "true";
:local cacheName [/ip dns cache all get $i name] ;

:put $cacheName;

:if (([:find $cacheName "update.microsoft.com"] != 0) || ([:find $cacheName "update.microsoft.com.nsatc.net"] != 0)) do={

:local tmpAddress [/ip dns cache get $i address] ;

:put $tmpAddress;

if address list is empty do not check

:if ( [/ip firewall address-list find ] = "") do={
:log info ("added entry: $[/ip dns cache get $i name] IP $tmpAddress");
/ip firewall address-list add address=$tmpAddress list=Updates comment=$cacheName;
} else={
:foreach j in=[/ip firewall address-list find ] do={
:if ( [/ip firewall address-list get $j address] = $tmpAddress ) do={
:set bNew "false";
}
}
:if ( $bNew = "true" ) do={
:log info ("added entry: $[/ip dns cache get $i name] IP $tmpAddress");
/ip firewall address-list add address=$tmpAddress list=Updates comment=$cacheName;
}
}
}
}

Is there any way i can mark packets in the proxy server?
I added these websites

ip proxy access print
Flags: X - disabled

DST-PORT DST-HOST PATH METHOD ACTION HITS

0 windowsupdate.microsoft.com allow 0
1 download.windowsupdate.com allow 14
2 www.update.microsoft.com allow 32
3 download.microsoft.com allow 0
4 wustat.windows.com allow 0
5 ntservicepack.microsoft.com allow 0
6 stats.microsoft.com allow 0
7 *.download.windowsupdate.com allow 0
8 *.update.microsoft.com allow 0
9 *.windowsupdate.com allow 0
10 *.windowsupdate.microsoft... allow 0
11 *.windowsupdate.microsoft... allow 0

Ok need an expert on this

created a l7 rule

/ip firewall layer7-protocol print

NAME REGEXP

0 .msu ^.get.+.msu.$

Mark packet using Mangle


/ip firewall mangle print
Flags: X - disabled, I - invalid, D - dynamic
0 ;;; msu files
chain=prerouting action=mark-packet new-packet-mark=msu passthrough=yes protocol=tcp layer7-protocol=.msu

Use queue to throttle

Will keep you updated to see if this works

I use this solution

force users to use mikrotik dns

/ip firewall nat
add action=redirect chain=dstnat comment=“DNS Dictator” dst-port=53 in-interface=!ether1-WAN protocol=udp

Schedule to get ip’s from dns using:

/system schedule
add interval=2m name=microsoft on-event=“:foreach i in=[/ip dns cache all find where (name~"update.microsoft"
|| name~"windowsupdate" || name~"download.microsoft" || name~"wustat" || name~"ntservicepack")
&& (type="A") ] do={\r
\n :local tmpAddress [/ip dns cache get $i address];\r
\ndelay delay-time=10ms\r
\n#prevent script from using all cpu time\r
\n :if ( [/ip firewall address-list find where address=$tmpAddress] = "") do={ \r
\n :local cacheName [/ip dns cache get $i name] ;\r
\n :log info ("added entry: $cacheName $tmpAddress");\r
\n /ip firewall address-list add address=$tmpAddress list=MS timeout=23:59:59 comment=$cacheName;\r
\n\r
\n}\r
\n\r
\n}” policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive start-date=jan/01/2016 start-time=
00:01:00

Then mark connection

/ip firewall mangle
add action=mark-packet chain=prerouting comment=“ms list dst” dst-address-list=MS new-packet-mark=ms passthrough=no
add action=mark-packet chain=prerouting comment=“ms list src” new-packet-mark=ms passthrough=no src-address-list=MS

Then queue

/queue simple
add max-limit=1M/1M name=MS packet-marks=ms target=ether1-WAN time=6h-23h59m59s,sun,mon,tue,wed,thu,fri,sat

I would like to try this method to throttle Windows updates – thanks for sharing a way to address this critical need.

I cannot get the /system schedule portion of your solution to add IP addresses to address lists (and I do have many cached DNS entries matching the criteria). Can you provide code that I could paste into the Source: field in the Winbox GUI for a new script?

I’m talking about translating this part into a script.

:foreach i in=[/ip dns cache all find where (name~\"update.microsoft\" \
|| name~\"windowsupdate\" || name~\"download.microsoft\" || name~\"wustat\" || name~\"ntservicepack\") \
&& (type=\"A\") ] do={\r\
\n :local tmpAddress [/ip dns cache get \$i address];\r\
\ndelay delay-time=10ms\r\
\n#prevent script from using all cpu time\r\
\n :if ( [/ip firewall address-list find where address=\$tmpAddress] = \"\") do={ \r\
\n :local cacheName [/ip dns cache get \$i name] ;\r\
\n :log info (\"added entry: \$cacheName \$tmpAddress\");\r\
\n /ip firewall address-list add address=\$tmpAddress list=MS timeout=23:59:59 comment=\$cacheName;\r\
\n\r\
\n}\r\
\n\r\
\n}

Thanks, and sorry for my RouterOS scripting ignorance.

Have you tried using the dynamic address feature in IP/firewall/address-list? Put the http address in the address field, instead of the numeric ip address. Then Mtik dynamically creates entries in the address list. @ZeroByte mentioned this in another post, and it proved very helpful to me. Hope it helps you too. It was a new feature recently introduced, 6.3x, can’t remember exactly which version, so check the change logs and make sure your version supports it. You of course need to know the text addresses that windows update uses …

Kind regards,

Why would anybody want to throttle Windows Updates ?

If you are doing it because of network issues, then how about fixing the bigger problem - the network.
If you are throttling updates to paying customers, then you are opening yourself up to a law suite from customers.
If you need to throttle, then use a policy/queue that treats all sites on the internet and customers fairly.
Keep in mind that you can throttle customers down to a rate of speed for which they are purchasing.

North Idaho Tom Jones

We throttle WU because

In SA our internet is SLOW and windows takes all the bandwith.

I’m doing this so that i can continue using the web if windows is updating, i couldn’t care if WU takes 2 hours to complete as log as it doesn’t affect the rest.

Wolter


/ip firewall nat
add action=redirect chain=dstnat comment="DNS Dictator" dst-port=53 in-interface=!ether1-WAN protocol=udp
/system scheduler
add interval=2m name=microsoft on-event=":foreach i in=[/ip dns cache all find where (name~\"update.microsoft\" ||  name~\"windowsupdate\" ||  name~\"\
    download.microsoft\" ||  name~\"wustat\" ||   name~\"ntservicepack\") && (type=\"A\") ] do={\r\
    \n     :local tmpAddress [/ip dns cache get \$i address];\r\
    \ndelay delay-time=10ms\r\
    \n#prevent script from using all cpu time\r\
    \n    :if ( [/ip firewall address-list find where address=\$tmpAddress] = \"\") do={         \r\
    \n     :local cacheName [/ip dns cache get \$i name] ;\r\
    \n     :log info (\"added entry: \$cacheName  \$tmpAddress\");\r\
    \n     /ip firewall address-list add address=\$tmpAddress list=MS timeout=23:59:59 comment=\$cacheName;\r\
    \n\r\
    \n}\r\
    \n\r\
    \n}" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive start-date=jan/01/2016 start-time=00:01:00
    
/ip firewall mangle
add action=mark-packet chain=prerouting comment="ms list dst" dst-address-list=MS new-packet-mark=ms passthrough=no
add action=mark-packet chain=prerouting comment="ms list src" new-packet-mark=ms passthrough=no src-address-list=MS


/queue simple
add max-limit=1M/1M name=MS packet-marks=ms target=ether1-WAN time=6h-23h59m59s,sun,mon,tue,wed,thu,fri,sat

does it work for windows 10 updates? yes windows 10 updates hog all the bandwidth when downloading and you cant even surf.
instead of script couldnt this work with address list ?
Capture.JPG

Works with my Windows 10

No windows update servers are dymnamic, thats why i give it a timeout of 24hours


You may have a point

Will try this method and will get back to you

Wolter

yes because in latert ROS address list are dynamic too if you place a name instead of ip
i cant remember from which version and after this feature was added.

update. …
i found it 6.36

firewall - allow to add domain name to address-lists (dynamic entries for resolved addresses will be added to specified list);

6.36.1

address-list - allow DNS names with “_” symbol;

doesn’t seem to work

you would need to be able to add something like this

~.update.microsoft.com

doesn’t accept ~. or *.

Wolter

Another solution would be Layer 7

change ether1-WAN to your internet port

REMEMBER to disable the defconf:fasttrack in the firewall, else the queue will not work

/ip firewall layer7-protocol
add name=MicrosoftUpdates regexp="^.+(update.microsoft|windowsupdate|download.microsoft|wustat|ntservicepack).*\$"
/ip firewall mangle
add action=mark-packet chain=prerouting comment="ms list dst" layer7-protocol=MicrosoftUpdates new-packet-mark=ms passthrough=no
/queue simple
add max-limit=1M/1M name=MS packet-marks=ms target=ether1-WAN time=6h-23h59m59s,sun,mon,tue,wed,thu,fri,sat

another example here.


/ip firewall layer7-protocol
add name=WINUPDATE regexp=“^.*(download.*windowsupdate|l.windowsupdate|.*delivery.*mp.*microsoft)”

/ip firewall mangle
add action=add-dst-to-address-list address-list=A9-WinUpdate address-list-timeout=15m chain=postrouting comment=WinUpdate
dst-address-list=!A9-WinUpdate layer7-protocol=WINUPDATE out-interface=ether1 protocol=tcp
add action=mark-connection chain=postrouting dst-address-list=A9-WinUpdate new-connection-mark=WinUpdate-CON out-interface=ether1 passthrough=yes
add action=mark-packet chain=prerouting connection-mark=WinUpdate-CON in-interface=ether1 new-packet-mark=WinUpdate_IN passthrough=no
add action=mark-packet chain=postrouting connection-mark=WinUpdate-CON new-packet-mark=WinUpdate_OUT out-interface=ether1 passthrough=no


/queue tree
add comment=Up limit-at=29M max-limit=29M name=Up parent=global queue=default
add comment=Down limit-at=198M max-limit=198M name=Down parent=global queue=default
add name=WindowsUpdate packet-mark=WinUpdate_IN parent=Down queue=default
add name=WindowsUpdate_U packet-mark=WinUpdate_OUT parent=Up queue=default

Ok - so the network is dead/saturated slow.
If you can’t fix the network, then you may want to consider building a Squid caching proxy server.
A correctly configured Squid server can burst up to full Ethernet interface speeds on cache hits thus saving Internet WAN bandwidth.
A Squid cache miss can go into cache so that the next person doing the same thing ends up with a cache hit.

North Idaho Tom Jones

Point taken. With a squid you can also throttle WU. Been there done that, got the T-Shirt

Proxy doesn’t solve the saturated line problem, it only elevates the traffic after its been cached.The first time its downloaded you still want to throttle the line speed. To configure squid to act as a WSUS is a fine art. (and doesn’t always work). Windows 10 updates are distributed between Win10 machines on the LAN, thus using a proxy server to cache win10 updates doesn’t make sense.

In fact, with so many sites moving to https (443) not a lot get cached,

Wolter

in the place i leave we have adsl and vdsl. there are hotels with 5mbps download and 1mbps upload and i have to share this line to customer free internet. yes windows update is a bandwidth hog after all. customers didnt come to hotel to upgrade their laptop or pc lol

This is working perfectly for me; thanks! I was able to use the layer 7 protocol to mark packets and fit them into my queue tree. Now I can browse the web and check email on my $100/month 500 Kbps Internet connection (yes, that’s about 0.5 Mbps – buying my way out of this performance problem is not in my budget). Windows updates will still get installed – as they must – but their multitude of TCP connections will have limited impact on my foreground tasks instead of making the Internet unusable.

/ip firewall layer7-protocol
add name=MicrosoftUpdates regexp="^.+(update.microsoft|windowsupdate|download.microsoft|wustat|ntservicepack).*\$"

[/quote][/quote]

yes this is working also for me. when my w10 pc at home starts downloading updates even internet radio stops playing. i make a simple queue with half my total bandwidth and it works. nice