maza-ad-blocking/README.md

232 lines
4.3 KiB
Markdown
Raw Normal View History

2020-03-30 08:47:49 +02:00
## 🥇 Maza was Top 1 in Hacker News
Comments: https://news.ycombinator.com/item?id=22717650
2020-03-21 21:41:22 +01:00
# Maza ad blocking - Like Pi-hole but local and using your operating system
2020-01-03 17:21:55 +01:00
2020-03-29 11:29:38 +02:00
<img alt="demo" src="media/demo.gif">
2020-04-04 10:09:50 +02:00
Simple, native and efficient local advertising blocker. Compatible with macOS and Linux.
2020-01-03 17:21:55 +01:00
2020-03-30 08:52:57 +02:00
<table>
<tr>
<td>
<img alt="maza logo" src="media/maza.png" width="500">
</td>
<td>
<ul>
<li>You <strong>don't have to install any browser extensions or applications</strong>, you just use the tools of your operating system.</li>
<li>You update the list of DNS to be blocked with a <strong>single command</strong>.</li>
<li><strong>Opensource</strong>.</li>
<li>Just <strong>bash</strong>.</li>
</ul>
</td>
</tr>
</table>
2020-01-03 18:03:22 +01:00
2020-01-03 18:31:45 +01:00
2020-01-03 17:37:07 +01:00
## 🏃Run
2020-01-03 17:29:15 +01:00
2020-01-03 17:37:07 +01:00
### 📡 Update database
2020-01-03 17:29:15 +01:00
``` bash
maza update
```
2020-01-03 17:37:07 +01:00
### 🔨 Start
2020-01-03 17:29:15 +01:00
``` bash
sudo maza start
```
2020-01-03 17:37:07 +01:00
### 🛠 Stop
2020-01-03 17:29:15 +01:00
``` bash
2020-02-22 07:50:03 +01:00
sudo maza stop
2020-01-03 17:29:15 +01:00
```
2020-01-03 17:37:07 +01:00
### ⚖️ Status
2020-01-03 17:29:15 +01:00
``` bash
maza status
```
2020-01-03 17:37:07 +01:00
## ⚙️ Install
2020-01-03 17:29:15 +01:00
2020-01-03 17:37:07 +01:00
### 👀 Requirements
2020-01-03 17:29:15 +01:00
2020-03-22 09:42:54 +01:00
- **bash** 4.0 or higher
- **curl**
2020-04-04 10:09:50 +02:00
- Only macOS users, **gsed**: `brew install gnu-sed`
2020-01-03 17:29:15 +01:00
Then you do this.
``` bash
2020-02-05 23:18:52 +01:00
curl -o maza https://raw.githubusercontent.com/tanrax/maza-ad-blocking/master/maza && chmod +x maza && sudo mv maza /usr/local/bin
2020-01-03 17:29:15 +01:00
```
2020-03-29 13:33:51 +02:00
Optional but recommended, make a backup of your hosts file.
``` bash
sudo cp /etc/hosts /etc/hosts.backup
```
2020-03-21 20:42:02 +01:00
## 🔪 Uninstall
2020-03-21 20:29:29 +01:00
``` bash
2020-03-21 21:05:11 +01:00
sudo rm /usr/local/bin/maza && sudo rm -r ~/.maza
2020-03-21 20:29:29 +01:00
```
2020-01-04 08:53:35 +01:00
## DNSMASQ
2020-08-23 19:07:44 +02:00
Unfortunately the hosts file does **not support sub-domains (wildcards)**, which is necessary to correctly filter all DNS. You will **need to install locally a server** for that purpose, Maza supports the **Dnsmasq** format.
2020-01-04 08:53:35 +01:00
2020-08-23 19:07:44 +02:00
### MacOS
#### 1 Install
2020-01-04 08:53:35 +01:00
```bash
brew install dnsmasq
```
2020-08-23 19:07:44 +02:00
#### 2 Configure
2020-01-04 08:53:35 +01:00
Edit the file.
```
/usr/local/etc/dnsmasq.conf
```
2020-08-23 19:07:44 +02:00
Add the following line at the end.
2020-01-04 08:53:35 +01:00
```
conf-file=(your user path)/.maza/dnsmasq.conf
```
2020-08-23 19:07:44 +02:00
Example
```
conf-file=/Users/myuser/.maza/dnsmasq.conf
```
2020-01-04 08:53:35 +01:00
Start DNSMASQ.
```bash
sudo brew services stop dnsmasq
sudo brew services start dnsmasq
```
2020-08-23 19:07:44 +02:00
#### 3 Tell your OS to use your DNS server
2020-01-04 08:53:35 +01:00
2020-04-04 10:09:50 +02:00
Delete the list of macOS DNS servers and add the 3 addresses. The first one will be your local server, and the other 2 belong to OpenDNS, which you can use any other.
2020-01-04 08:53:35 +01:00
```bash
127.0.0.1
208.67.222.222
208.67.220.220
```
2020-04-04 10:09:50 +02:00
<img alt="network macos" src="media/network-osx.jpg" width="500">
2020-03-30 09:00:31 +02:00
2020-01-04 08:53:35 +01:00
Refresh your DNS cache
```bash
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
```
2020-08-23 19:07:44 +02:00
#### 4 Restart/Start Maza
```bash
sudo maza stop
sudo maza start
```
### Debian/Ubuntu with Gnome Shell
#### 1 Install
```bash
sudo apt update
sudo apt install dnsmasq
```
#### 2 Configure
Edit file in path.
```
/etc/dnsmasq.conf
```
Add the following line at the end.
```
conf-file=(your user path)/.maza/dnsmasq.conf
```
Example
```
conf-file=/home/myuser/.maza/dnsmasq.conf
```
Start DNSMASQ.
```bash
sudo systemctl stop dnsmasq
sudo systemctl start dnsmasq
sudo systemctl enable dnsmasq
```
#### 3 Tell your OS to use your DNS server
In Gnome Shell, open `Settings->Nework`. Click in the sprocket of your connection.
<img alt="network macos" src="media/network-gnome.png" width="500">
Add your local server (dnsmasq), and the other 2 belong to OpenDNS, which you can use any other.
```bash
127.0.0.1,208.67.222.222,208.67.220.220
```
<img alt="network macos" src="media/dns-gnome.png" width="500">
#### 4 Restart/Start Maza
```bash
sudo maza stop
sudo maza start
```
2020-03-22 09:41:05 +01:00
### Bonus: dnsmasq is in charge of solving all DNS
2020-01-05 08:45:25 +01:00
2020-05-09 16:38:13 +02:00
Add in configure file: `/usr/local/etc/dnsmasq.conf`
2020-01-05 08:45:25 +01:00
```
no-resolv
server=208.67.222.222
server=208.67.220.220
```
2020-08-23 19:07:44 +02:00
### Bonus: dnsmasq have `localhost` domains
2020-01-05 08:45:25 +01:00
2020-08-23 19:07:44 +02:00
If you want all your `.localhost` domains, for example, point to localhost add in configure file: `/usr/local/etc/dnsmasq.conf` or `/etc/dnsmasq.conf`.
2020-01-05 08:45:25 +01:00
```
address=/.localhost/127.0.0.1
```
2020-01-03 17:37:07 +01:00
## ⚠️ CAUTION
2020-01-03 17:21:55 +01:00
2020-04-04 10:09:50 +02:00
- Only compatible with Linux and macOS operating systems.
2020-01-03 17:21:55 +01:00
- Remember to make a backup copy of `/etc/hosts` in case of unforeseen circumstances, neither the project nor its author will be responsible for any possible repercussions derived from not carrying out this action.
2020-04-10 14:01:51 +02:00
## 🧑‍🎨 Credits
<a target="_blank" class="text-yellow" href="https://programadorwebvalencia.com/">Andros Fenollosa</a>