Blocking Advertising

Internet advertising is one of the biggest risks to your security and privacy so it’s important to block it if you value these things, some might argue it’s wrong to block advertising but when it puts you and your computer at risk there is no other option.

Internet advertising can be blocked by three main methods:

  • Hosts file
  • DNS filter
  • Browser plugins

Most people these days use browser plugins such as AdBlock, Adblock Plus or my personal preference and recommendation uBlock Origin, these in general do a very good job at blocking advertising but don’t work outside the web browser, they can also be used to remove unwanted elements from a web page giving you a cleaner browsing experience.

Hosts File

The hosts file is a little more complicated to explain, when you go to a website such as your computer needs to lookup the domain name to obtain the internet address such as, this is done by contacting a DNS server which is typically provided by your ISP, however in the early days of the internet there was no DNS servers, instead it looked in a hosts file which manually maps domain names to ip addresses, for example:

The hosts file typically has priority over the DNS server so you can use it to override the domain name resolution, this is usually done by redirecting the domain to the local loopback address which is or, this effectivly blocks the domain.

On windows the hosts file can be found at C:\Windows\System32\drivers\etc\hosts
On Linux and most other UNIX based systems it can be found at /etc/hosts

To make things easier you can find hosts files online that already block the majority of advertising providers and other unsafe domains, I’m currently using Steven Black’s hosts file which is compiled from several different reliable sources.

This applies to all applications on your system but I still recommend it be combined with a browser plugin for maximum coverage.

DNS Filter

Rather than at the hosts file the blocking can also be done at the DNS server level, you can either do this by setting up your own DNS server or by using a public DNS service such as OpenDNS.

Personally I don’t use these public services out of privacy concerns but if you want a very simple method that needs no maintenence this might be for you, one big advantage of this is that it works on devices where you cannot typically access the hosts file.

If you have a Raspberry Pi laying around consider installing pi-hole on it for a super simple hardware DNS server.

Advanced Blocking

Sometimes you may run in to an advert that is not blocked by any of your installed methods, in a web browser it’s easy to add new blocking rules but outside you may need to find which domain it’s coming from.

This is easily done by tools such as Process Explorer or Wireshark which can show all HTTP connections, with a little effort this is usually able to locate the offending domain, for cases where the connection is made directly by IP address you can block it using a firewall such as TinyWall or Windows Firewall.

Installing Gentoo Linux Tips


Gentoo is a very popular source based distribution primarily intended for more experienced Linux users, although really it’s not as hard as people make it seem, certainly you should have experience using Linux and be comfortable using the terminal.

Since it would be a waste of my time to repeat the excellent Gentoo handbook I’m going to just cover the bits that may cause your first time user trouble, it’s recommend you do your first install in a virtual machine rather than on a physical machine so you can get a feel for it.


  • Around 40GB free disk space for a decent install
  • A reasonably fast CPU
  • Access to the Gentoo handbook throughout the install
  • 1GB of RAM or more

The fast CPU is so you can get it installed in a short amount of time, compiling is an intensive task that can take days on a slower machine, for comparison a 1.8GHz Intel Celeron took me around 40 hours for a full desktop install, so I recommend at least a dual core processor, of course if you’re not in a hurry that’s fine.

It’s important you do your research before proceeding with the install, some thing you really need to know are:

  • What hardware do you have, use lspci and lsusb or other tools
  • Is your hardware supported in the kernel

The easiest way to check this is to run a Linux distribution, the Gentoo desktop live cd will work fine for this, if all your hardware works then your good to go, although you should note down the loaded modules so you can optimize your kernel to just what you need.

Finally it’s a good idea to note down your network configuration, particularly if you’re not used to setting up your network from the terminal.

Base System

For this install I’m going to assume you’re installing x86_64 (64 bit), most of this will apply to x86 (32 bit) as well.

First get the Gentoo minimal install cd from here, once it’s downloaded you can burn it to a cd, or as I’d recommend instead a flash memory stick with unetbootin since the image is updated very frequently.

When booting you should be asked to select your keyboard key map, if for some reason you can’t select it or need to change it later use loadkeys.


Wireless in general is a pain in the ass when it comes to Linux in my opinion, mainly due to highly variable support, it’s often easier to buy a well supported adapter than try get a poorly supported one working.

To connect to a WPA-PSK secured network, as most are these days you need wpa_supplicant which is included on the install cd, you first need to make a configuration file for your network:

wpa_passphrase [ssid] [passphrase] > /etc/wpa_supplicant.conf

The ssid is the network ID you wish to connect to, the output is stored for later use, if you don’t know which is your network you can use the either of the following commands to scan:

iwlist [interface] scan
iw dev [interface] scan

The interface is the name of your wireless interface which should be displayed if you type iwconfig, if you don’t see anything it usually means the driver is not loaded or not available.

Once you have your configuration file you can connect to the network with:

wpa_supplicant -i  [interface] -c /etc/wpa_supplicant.conf -B -D [driver]

The -B option runs the wpa_supplicant daemon in the background so you may want to omit it the first time you run so you can check for errors, for the driver wext or nl80211 are the most common, nl80211 is preferable if supported.

Once it’s connected run the DHCP daemon to auto configure the network:


If all goes well your wireless network should now be working.


For a wired ethernet connection this will usually work right away without any configuration, if your network adapter appears when you type ifconfig you’re generally good to go, run dhcpcd if needed or perform a manual configuration, check the ifconfig man pages for more info.

Setting up disks

The most basic partition scheme you can really go with is:

Partition    Usage       Size    Filesystem
/dev/sda1    BIOS Boot   2MB     none
/dev/sda2    Swap        4GB     swap
/dev/sda3    /boot       128MB   vfat
/dev/sda4    /           ~       ext4

I strongly recommend you carefully read the difference between MBR and GPT, if in doubt go for GPT, the above partition scheme should work in either case.

I generally recommend that if you’re dual booting with Windows that you put your Linux install on a different disk, this helps to avoid any problems with the Windows bootloader.

Setting up compile and USE flags

This is one of the more important bits to get right, for compile options you should not go over the top, -O2 -pipe -mtune=native is good enough 99.9% of the time, for 1GB of memory and below do not use -pipe, for the USE flags you really need to think ahead about what you want your system to do, in particular if you ever want to run 32 bit applications put in the multilib USE flag right away, also make sure you set MAKEOPTS=”-j9″ as well since it speeds up compilation a huge amount, the number you use should be the total number of logical CPU cores plus 1.

If you run in to segmentation faults when compiling, as can happen if you don’t have enough memory, put the following in /etc/portage/make.conf


Remove it when no longer needed.

When it comes to setting your profile you should generally go for Desktop, otherwise you’ll need to add a whole bunch of USE flags, finally when you emerge a package always use –ask and look at the flags in blue, consider if you may need the features those flags provide now or in future.

Kernel Configuration

This is a really critical step, not getting this right can in certain cases cause serious issues (like forgetting wifi support), other minor problem can be fixed by reconfiguring the kernel.

Take a good amount of time to read through all the configuration options, some may not make any sense but it general you don’t have to worry too much as the defaults are mostly sensible, if you have any doubts use genkernel, you can always tweak things later.

Only thing I would really change always is to increase the scroll back buffer as the default is tiny in my opinion.

For driver support save the configuration and open the .config file in nano, have a search through and you should find your needed drivers if they’re available in the kernel.

Network Configuration

This is one place where the handbook failed me, in the end I had to put the needed commands to launch wpa_supplicant in a script in /etc/init.d in any case this isn’t difficult to do but keep it in mind if you run in to the same problem as me.

If you’re using wifi make sure you emerge these packages before you reboot otherwise you are screwed:

  • net-wireless/wpa_supplicant
  • net-wireless/iw

After Installation

Once you’ve rebooted in to your new Gentoo installation you can start installing more packages, Gentoo for a source distribution is very easy to use, during the months that I’ve been using it I only had one minor package issue.

If you made a serious mistake during the installation all is not lost, you can boot the install disk again, once you’ve mounted the partitions and chrooted you can fix whatever problem there is without doing a full reinstall.

If you do run into trouble make sure you visit the Gentoo IRC channel which has a lot of helpful people, or if the problem is with a specific package post on the forum.