I am configuring an /etc/hosts file on my router, and have a list of over 135,000 domains that I need to block via this file, which takes up nearly 5MB of space. As it turns out, the available RAM on my router is extremely limited, so dnsmasq cannot load this file into memory without crashing.
At the moment, the host file looks something like this:
0.0.0.0 a.triggit.com 0.0.0.0 a.twiago.com 0.0.0.0 a.visualrevenue.com 0.0.0.0 a.websponsors.com 0.0.0.0 a.webwise.org 0.0.0.0 a15172379.alturo-server.de 0.0.0.0 a2.mediagra.com 0.0.0.0 a3.suntimes.com 0.0.0.0 a7cleaner.com 0.0.0.0 aa.agkn.com 0.0.0.0 aa.tweakers.nl 0.0.0.0 aaa-architecten.nl 0.0.0.0 aaa-arcobaleno.it 0.0.0.0 aads.treehugger.com 0.0.0.0 aan.amazon.com 0.0.0.0 aarth.net 0.0.0.0 aax-cpm.amazon-adsystem.com 0.0.0.0 aax-us-east.amazon-adsystem.com 0.0.0.0 aax-us-pdx.amazon-adsystem.com 0.0.0.0 aax.amazon-adsystem.com 0.0.0.0 ab.5.p2l.info 0.0.0.0 ab.tweakers.nl 0.0.0.0 ab913aa797e78b3.com 0.0.0.0 abclnks.com 0.0.0.0 abetterinternet.com 0.0.0.0 abi83-schramberg.de 0.0.0.0 aboardamusement.com However, I would like to change it to become this:
0.0.0.0 a.triggit.com a.twiago.com a.visualrevenue.com a.websponsors.com a.webwise.org a15172379.alturo-server.de a2.mediagra.com a3.suntimes.com a7cleaner.com aa.agkn.com aa.tweakers.nl aaa-architecten.nl aaa-arcobaleno.it aads.treehugger.com 0.0.0.0 aan.amazon.com aarth.net aax-cpm.amazon-adsystem.com aax-us-east.amazon-adsystem.com aax-us-pdx.amazon-adsystem.com aax.amazon-adsystem.com ab.5.p2l.info ab.tweakers.nl ab913aa797e78b3.com abclnks.com abetterinternet.com abi83-schramberg.de 0.0.0.0 aboardamusement.com None of these lines exceed 256-characters, and each domain from the original does list does not get broken into two (i.e. the 256-th character is not carried onto the new line).
How can I read the original hosts file, and create longer single-line expressions, which are at maximum 256-characters, but do not "eat up" some results (i.e. breaking on the last domain before the 256-character limit)?
0.0.0.0 a.kerg.net