GL-inet router adblock via hosts file

Why use ad-blocking?

  • User Experience: Ads can disrupt browsing, taking up screen space, auto-playing videos, or redirecting users.
  • Performance: Ads and tracking scripts slow down page load times.
  • Data Usage: Ads consume extra data, which can be costly or slow down browsing.
  • Privacy: Ads with trackers invade user privacy.
  • Security: Blocking ads reduces the risk of encountering malware.

Using the /etc/hosts file for ad-blocking:

  • Redirect requests for ad servers to a non-routable IP address.
  • Blocked content from a domain will not load.


  • System-wide blocking, not limited to a specific browser or app.
  • Lightweight, no additional software installation required.


  • Limited granularity, cannot block specific elements on a page.
  • Maintenance required to update the /etc/hosts file.
  • Some websites detect ad-blockers and restrict content.

For users who prefer not to manually update the /etc/hosts file, there are projects and communities that maintain curated lists of ad-serving domains.

In summary, while the /etc/hosts method is a simple and effective way to block ads system-wide, dedicated ad-blocking software or browser extensions offer more control and flexibility.

Download from OISD source

# One line script execute in your router ~ 

  cat <<-EOF
nameserver ::1
} > /etc/resolv.conf

  cat <<-EOF localhost
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
  curl | grep -v '^#' | grep -v '^[[:space:]]*$' | sed 's/^/ /'
} > /etc/hosts.tmp && mv /etc/hosts.tmp /etc/hosts && echo "Hosts file updated." && \
/etc/init.d/dnsmasq restart && echo "dnsmasq restarted successfully. && Hosts is updated" || \
(echo "An error occurred. Please check the commands and try again." && exit 1)

Replace the first line with regex ^ to this format and save file. localhost
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Upload and replace router default hosts file via SCP

## Install SCP first 
opkg update
opkg install openssh-sftp-server nano bind-dig

# Upload file
scp -P 22 oisd_big_domainswild2.txt [email protected]:/etc/hosts

Restart dnsmasq service

/etc/init.d/dnsmasq restart

/etc/init.d/dnsmasq status

Check local resolv is okay

## Test will return
dig +short

# Dig command not found then install
opkg install bind-dig

Check default resolver

root@GL-AX1800:~# cat /tmp/resolv.conf
search lan
nameserver ::1