What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Editing the Hosts file to prevent Youtube ads

GregariousJB

New Around Here
Though I've been entrenched in the computer world for over 20 years, router configuration remains one of my few weak areas of expertise.

My interest is in preventing YouTube ads on my Android device much like Adblock on my desktop (or the newer, apparently better uBlock).

I followed the How to use Adblock Plus filter subscriptions to provide advertisement filtering to devices, which was a nightmare to get through since it required Entware, connecting to the router via Putty, reformatting a USB drive into Ent2/3, etc - all things I've never done before.

However, when I was finished, my phone was blocking ALL websites but still showing the damn ads on the Youtube app. So, I deleted my firewall-start and set off to find a new solution.

I have some Linux experience and so found the hosts file itself via Putty (I actually use mRemoteNG, which is just a nice GUI for Putty). I've been using the Amalgamated hosts file from StevenBlack on my desktop and it's been working fine, so I figure why not use it for the router's hosts file?

I realize now I'm probably doing it the slow way, but I ended up opening my router's hosts file in VIM and copy/pasting all 30,631 lines into it. It took several hours to complete (for reasons unknown - it's just text - but it was pasting one line per second towards the end), but it's done nonetheless.

Alas, websites are no longer blocked, but Youtube ads are STILL SHOWING.

My next step is to root my Android phone (Moto G) and edit the hosts file within it, but I'd prefer to avoid that in order to retain the warranty.

Any words of wisdom for me?

Edit: Windows 7 64bit, AsusWRT-Merlin 376.49_5
 
Last edited:
Congrats with getting through the Entware, putty, ext2/3, etc stuff. Learning and successfully applying all those bits of newfound knowledge is no easy task. :)


I suspect that the hosts file might have been corrupted or something during the alarmingly long, several hour paste into vim. If you were using Linux I would say to use netcat/nc to transfer files. My Windows knowledge is severely lacking.


Can you not enable FTP on the router (through the GUI), then upload the hosts file and move/copy (mv/cp in Putty) to where you want it?
 
Last edited:
Congrats with getting through the Entware, putty, ext2/3, etc stuff. Learning and successfully applying all those bits of newfound knowledge is no easy task. :)


I suspect that the hosts file might have been corrupted or something during the alarmingly long, several hour paste into vim. If you were using Linux I would say to use netcat/nc to transfer files. My Windows knowledge is severely lacking.


Can you not enable FTP on the router (through the GUI), then upload the hosts file and move/copy (mv/cp in Putty) to where you want it?

Thanks for the quick response.

That was my hope (using FTP). I got it connectable, but I'm only able to see the /tmp/home/root/Ext3 folder:

Cj3waYt.png


...whereas the /etc/hosts file is back a ways from that. I'm not entirely... hmm. Maybe a symlink? One sec.

EDIT: Oh. It seems the hosts file that I waited hours to create is gone, along with the hosts.backup file I made beforehand. My best guess is that the router reverted everything after I rebooted it, which I think I've seen mentioned amongst the guides I've read about the procedure. Apparently editing the router's hosts file directly won't help me. I assume I need to fall back to Custom config files.

EDIT2: Ok, so it seems the only thing I need help with is accessing my /jffs/configs folder via FTP. I'm not strong enough in Linux to know what commands or which files to edit to do so.
 
Last edited:
Thanks for the quick response.

That was my hope (using FTP). I got it connectable, but I'm only able to see the /tmp/home/root/Ext3 folder:

Cj3waYt.png


...whereas the /etc/hosts file is back a ways from that. I'm not entirely... hmm. Maybe a symlink? One sec.

Use Putty to move the file once it is uploaded.

Use a command like "cp /tmp/home/root/Ext3/hosts /move/file/here"

PS - I use AdAway on my Nexus 7, which replaces the hosts file, and I still see YouTube ads. I assumed that blocking YouTube ads was more complex than manipulating DNS records (hosts file).
 
Ok, so it seems the only thing I need help with is accessing my /jffs/configs folder via FTP. I'm not strong enough in Linux to know what commands or which files to edit to do so.

By default (probably for security and/or safety reasons) FTP cannot access those folders.

You must use Putty (or whatever SSH client you prefer). Use the "cp" (copy) or "mv" (move) commands. Google can give you more information about the commands. The general idea is "cp /from/here.file /to/folder".
 
I bet that's it. I feel a little foolish for not thinking of that myself. I'll try it, thanks!

EDIT: It works!!!

1. $ cp mnt/Ext3/entware/tmp/hosts.add jffs/configs/hosts.add
2. Reboot router and phone
3. ???
4. Profit!

No more YouTube ads! Thanks!
 
Last edited:
You can use WinSCP to transfer files between router and PC. You MUST use SCP file protocol, and you can browse and copy your routers internal files like in ftp.
 

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Back
Top