-
Notifications
You must be signed in to change notification settings - Fork 4
/
iptables-reject-slow-akaimai-bloomberg-tv
executable file
·76 lines (66 loc) · 4.69 KB
/
iptables-reject-slow-akaimai-bloomberg-tv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python
import subprocess
# For streaming video clips from http://www.bloomberg.com/video from Taipei using
# a Hinet DSL connection. "LIVE TV" seems to route differently
# Bad: mtr a23-59-6-218.deploy.akamaitechnologies.com
#
#Host Loss% Snt Last Avg Best Wrst StDev
#1. 192.168.1.1 0.0% 70 0.2 0.2 0.1 0.3 0.0
#2. h254.s98.ts.hinet.net 0.0% 70 19.2 26.2 19.1 46.8 8.5
#3. tpdt-3308.hinet.net 0.0% 70 19.1 27.5 18.9 68.0 9.4
#4. TPDT-3011.hinet.net 0.0% 70 22.1 29.8 19.8 64.6 9.9
#5. r4104-s2.tp.hinet.net 1.4% 70 20.7 24.8 19.2 67.0 9.0
#6. r4004-s2.tp.hinet.net 1.4% 70 29.8 27.2 19.2 56.9 9.1
#7. p16-7-1-3.r22.tokyjp01.jp.bb.gin.ntt.net 1.4% 70 52.4 60.5 52.3 86.1 9.8
#8. ae-3.r24.tokyjp01.jp.bb.gin.ntt.net 44.9% 70 62.2 74.7 50.0 147.0 24.7
# ae-3.r25.tokyjp01.jp.bb.gin.ntt.net
#9. ae-3.r23.osakjp01.jp.bb.gin.ntt.net 0.0% 69 83.1 74.9 58.4 161.1 20.9
# ae-3.r22.osakjp01.jp.bb.gin.ntt.net
#10. ae-1.a20.osakjp01.jp.ra.gin.ntt.net 1.4% 69 83.1 74.8 58.3 137.0 16.6
# ae-2.a20.osakjp01.jp.ra.gin.ntt.net
#11. a23-59-6-218.deploy.akamaitechnologies.com 0.0% 69 58.7 67.8 57.9 98.3 9.9
# Bad: mtr a124-40.41-172.deploy.akamaitechnologies.com
#
#Packets Pings
#Host Loss% Snt Last Avg Best Wrst StDev
#1. 192.168.1.1 0.0% 17 0.2 0.2 0.1 0.3 0.0
#2. h254.s98.ts.hinet.net 11.8% 17 19.2 21.9 19.0 42.4 6.7
#3. tpdt-3307.hinet.net 0.0% 17 19.6 27.0 19.0 73.4 15.4
#4. TPDT-3011.hinet.net 0.0% 17 20.4 27.6 20.4 56.8 8.4
#5. r4104-s2.tp.hinet.net 0.0% 17 20.3 20.2 19.2 23.9 1.7
#6. 220-128-6-229.HINET-IP.hinet.net 0.0% 17 19.4 21.4 19.4 32.4 4.1
#7. ntt-jp-gw.hinet.net 0.0% 16 57.4 72.1 57.4 144.8 22.8
#8. ae-3.r24.tokyjp01.jp.bb.gin.ntt.net 0.0% 16 97.4 70.0 53.6 116.2 18.4
# ae-3.r25.tokyjp01.jp.bb.gin.ntt.net
#9. ae-3.r23.osakjp01.jp.bb.gin.ntt.net 0.0% 16 91.3 81.6 61.8 150.7 23.5
# ae-3.r22.osakjp01.jp.bb.gin.ntt.net
#10. ae-1.a20.osakjp01.jp.ra.gin.ntt.net 0.0% 16 85.9 80.0 62.7 114.4 14.5
# ae-2.a20.osakjp01.jp.ra.gin.ntt.net
#11. a124-40.41-172.deploy.akamaitechnologies.com 0.0% 16 75.7 74.8 62.0 90.9 10.5
# Good: mtr a72-246-189-100.deploy.akamaitechnologies.com
#
#Host Loss% Snt Last Avg Best Wrst StDev
#1. 192.168.1.1 62.2% 511 0.2 0.1 0.1 0.8 0.1
#2. h254.s98.ts.hinet.net 19.2% 510 19.6 24.4 19.0 56.1 7.8
#3. tpdt-3307.hinet.net 0.6% 510 19.2 26.1 18.9 115.2 11.9
#4. TPDT-3012.hinet.net 1.0% 510 25.7 30.6 20.0 63.1 8.3
#5. r4103-s2.tp.hinet.net 1.6% 510 26.7 25.0 19.0 95.1 9.1
#6. r4003-s2.tp.hinet.net 0.2% 510 19.5 25.0 19.1 60.6 8.5
#7. 211-72-233-69.HINET-IP.hinet.net 0.4% 510 54.2 57.9 49.2 170.0 14.2
#8. ae-4.r24.tokyjp01.jp.bb.gin.ntt.net 19.8% 510 62.8 69.4 52.7 159.9 23.0
#9. ae-4.a21.tokyjp01.jp.ra.gin.ntt.net 1.0% 510 51.0 58.9 49.2 170.3 15.9
#10. ae-10.a21.tokyjp01.jp.ra.gin.ntt.net 1.2% 510 50.4 56.1 49.9 96.1 8.9
#11. a72-246-189-100.deploy.akamaitechnologies.com 1.0% 510 50.0 58.1 49.6 97.8 9.0
BAD_HOSTS = [
'a23-59-6-218.deploy.akamaitechnologies.com',
'124.40.41.172', # a124-40.41-172.deploy.akamaitechnologies.com
]
chain = 'MY_AKAMAI_BLACKLIST'
r = subprocess.call(['iptables', '--new-chain', chain], stderr=open('/dev/null'))
if r != 0:
subprocess.check_call(['iptables', '--flush', chain])
for i in BAD_HOSTS:
subprocess.check_call(['iptables', '-A', chain, '-d', i, '-j', 'REJECT'])
r = subprocess.call(['iptables', '--check', 'OUTPUT', '-j', chain], stderr=open('/dev/null'))
if r != 0:
subprocess.check_call(['iptables', '--insert', 'OUTPUT', '1', '-j', chain])