Cách dùng Raspberry Pi + Pi-hole để chặn quảng cáo cho tất cả thiết bị trong nhà
Pi-hole là một công cụ biến con Raspberry Pi của bạn thành một bộ chặn quảng cáo có tác dụng trên toàn bộ mạng trong nhà. Bạn không cần phải cài adblock, bạn không cần phải chỉnh DNS trên từng thiết bị, tất cả đã có Pi-hole lo. Cái này rất hữu ích với cả những thiết bị mà bạn không thể can thiệp để chặn quảng cáo, như Smart TV chẳng hạn. Bạn có thể tưởng tượng lúc đó chiếc Raspberry Pi sẽ đóng vai trò lọc hết mọi mẩu quảng cáo trước khi chúng kịp đến với điện thoại, máy tính của bạn. Cách làm cũng cực kì dễ, và bạn có thể dùng gần như mọi chiếc Raspberry Pi từ đó đến nay để chạy Pi-hole do nó không đòi hỏi cấu hình cao.
Lợi ích của việc dùng Pi-hole
- Dễ cài đặt
- Chặn được quảng cáo trên mọi thiết bị, mọi ứng dụng (kể cả các thiết bị không cho phép cài adblock)
- Tốc độ cao, nhẹ nhàng
- Dễ dàng kiểm soát nhờ giao diện đồ họa
- Có thể chặn cả IPv4 và IPv6 của các trang quảng cáo
- Miễn phí
Nguyên tắc hoạt động của nó như sau:
Để thực hiện, bạn cần có
- Một chiếc Raspberry Pi, thẻ microSD, đã cài đặt hệ điều Raspbian Lite
- Không bắt buộc, nhưng nên có: dây mạng LAN, để nối Pi với router bằng mạng có dây thì sẽ ổn định hơn
- Bạn cũng phải làm quen với việc gõ lệnh trên Raspberry Pi, có thể làm trực tiếp trên Pi khi đã nối ra màn hình, bàn phím… hoặc dùng SSH cũng được (SSH thì tiện hơn, nhưng nếu chưa quen thì có thể hơi phức tạp.
Các bước cài Pi hole lên Raspberry Pi
Bạn truy cập vào Raspberry Pi của nhà bạn, có thể mở Pi ra, kết nối với màn hình, bàn phím, sau đó tìm ứng dụng tên là Terminal.
Chạy nó lên, gõ lệnh sau:
curl -sSL https://install.pi-hole.net | bash
Từ đây về sau thì bạn chỉ cần nhấn Enter để đồng ý mà thôi, không cần tùy chỉnh gì thêm vì những cái mà đã được chọn sẵn đều tốt cả. Sơ lược quá trình cài đặt thì câu lệnh trên sẽ làm những thứ như thế này:
- Cài đặt Pi hole
- Thiết lập IP tĩnh cho Raspberry Pi (vì phải có IP tĩnh trong mạng nội bộ thì router mới biết 1 chỗ cố định nhằm lọc link của các nhà quảng cáo)
- Cài đặt giao diện web quản lý lưu lượng và theo dõi các chỉ số
Ở bước gần cuối, bạn sẽ thấy một màn hình tóm tắt của Raspberry Pi hiển thị địa chỉ IP của máy (mục IPv4). Nhớ ghi số này lại vì bạn sẽ cần cập nhật nó lên router của nhà mình. Như trong hình bên dưới, con Pi của mình có địa chỉ là 192.168.3.109.
Khi đã cài xong, bạn cần vào router của nhà mình để chỉnh lại DNS, còn gọi là máy chủ phân giải tên miền (ví dụ, gõ tinhte.vn -> trình duyệt biết địa chỉ thực sự là 123.223.14.15). Vì Pi hole sẽ can thiệp vào giai đoạn phân giải này nên nó có thể phát hiện được tên miền của các hãng quảng cáo, lấy đại 1 ví dụ như ads.google.com, vậy là nó sẽ block cái địa chỉ này lại và mẫu quảng cáo không thể hiển thị lên máy tính, di động, iPad hay Smart TV của bạn.
Mỗi router sẽ có cách chỉnh DNS khác nhau, nhưng về cơ bản thì bạn cứ tìm chỗ nào có chữ DNS hoặc chữ DHCP và DNS thì chỉnh ở đó, chuyển sang Set DNS Manually. Như hình minh họa bên dưới là mình chỉ trên con router nhà mình. Sau khi chỉnh xong thì lưu lại và khởi động lại router để nó bắt đầu có hiệu lực.
Sau khi đã cài đặt DNS cho router và khởi động lại, kể từ lần truy cập sau đó bạn sẽ thấy các mẫu quảng cáo không thể hiện thị được, một số trang sẽ bị trống vài chỗ, đó thực chất là chỗ quảng cáo nhưng banner, link và các thông tin đã bị Pi hole chặn rồi.
Pi hole có một trang điều khiển, quản lý, theo dõi thông số về việc truy cập và chặn quảng cáo, bạn có thể truy cập vào nó bằng link http://<địa chỉ IP của Raspberry Pi>/admin/index.php. Phần này thì mấy bạn tự mò nhé, cũng không có gì phức tạp và cần giới thiệu.
Một số lưu ý
Nếu ở lần đầu tiên cài đặt Pi-hole qua SSH (cài trực tiếp trên Pi không qua SSH thì sẽ không bị) mà bạn thấy Pi bị đứng, không thể SSH, không thể làm gì, thì khả năng cao là bạn chỉ bị mất lệnh SSH thôi chứ chặn quảng cáo thì vẫn chạy.
Trong trường hợp này, bạn làm như sau:
- Chờ khoảng 10p
- Nếu vẫn còn đơ, hãy rút điện, bật lại Pi
- Chạy lại dòng lệnh ở trên thêm 1 lần nữa, lần này bạn sẽ thành công
Lưu ý từ việc chặn quảng cáo
Một số trang hoạt động không thu phí, do đó họ cần nguồn thu từ các đơn vị quảng cáo như Google, Facebook, các hệ thống quảng cáo trong nước… để có kinh phí hoạt động. Trước khi chặn quảng cáo, hãy nghĩ về điều đó nhé. Hiện tại doanh thu từ các quảng cáo kiểu banner này không phải là phần quan trọng của Tinh tế, nhưng nhiều web khác thì có, nên bạn hãy chịu khó xem ads một chút để có động lực cho họ tạo nội dung cho bạn xem.







I blog frequently and I really appreciate your content. Your article has truly peaked my interest. I’m going to take a note of your site and keep checking for new information about once a week. I opted in for your Feed as well.
This site certainly has all of the information I wanted concerning this subject and didn’t know who to ask.
Everything is very open with a really clear clarification of the challenges. It was truly informative. Your website is very helpful. Many thanks for sharing!
Howdy, There’s no doubt that your web site could be having web browser compatibility issues. When I take a look at your blog in Safari, it looks fine however, when opening in I.E., it has some overlapping issues. I simply wanted to give you a quick heads up! Besides that, fantastic website!
It’s hard to come by experienced people in this particular subject, but you sound like you know what you’re talking about! Thanks
After looking into a few of the blog posts on your blog, I honestly appreciate your technique of writing a blog. I book marked it to my bookmark site list and will be checking back in the near future. Please visit my web site too and let me know your opinion.
An impressive share! I have just forwarded this onto a coworker who was doing a little research on this. And he in fact bought me breakfast because I stumbled upon it for him… lol. So allow me to reword this…. Thank YOU for the meal!! But yeah, thanx for spending time to talk about this matter here on your website.
That is a really good tip particularly to those fresh to the blogosphere. Simple but very accurate information… Many thanks for sharing this one. A must read article.
What is the Recipe for the Gelatin Trick to Lose Weight
This is the right site for anyone who hopes to understand this topic. You know so much its almost hard to argue with you (not that I personally would want to…HaHa). You certainly put a new spin on a topic that has been discussed for many years. Great stuff, just great.
https://shorturl.fm/Z0CPf
The very next time I read a blog, Hopefully it won’t fail me as much as this one. I mean, I know it was my choice to read, however I actually believed you would have something helpful to say. All I hear is a bunch of moaning about something that you could fix if you were not too busy searching for attention.
You can definitely see your expertise in the work you write. The world hopes for even more passionate writers like you who are not afraid to say how they believe. Always go after your heart.
Having read this I thought it was rather informative. I appreciate you spending some time and energy to put this content together. I once again find myself spending way too much time both reading and leaving comments. But so what, it was still worthwhile.
I’m amazed, I have to admit. Seldom do I encounter a blog that’s equally educative and interesting, and without a doubt, you have hit the nail on the head. The problem is something which too few folks are speaking intelligently about. Now i’m very happy I stumbled across this in my search for something regarding this.
https://shorturl.fm/d7mfY
There is definately a lot to learn about this issue. I love all of the points you made.
https://shorturl.fm/YNvxL
I?m impressed, I must say. Actually not often do I encounter a weblog that?s each educative and entertaining, and let me let you know, you’ve got hit the nail on the head. Your idea is excellent; the difficulty is something that not enough persons are talking intelligently about. I am very comfortable that I stumbled throughout this in my seek for one thing relating to this.
https://shorturl.fm/2eNhK
I adore your wp template, exactly where would you get a hold of it through?
https://shorturl.fm/zjmBP
you are in point of fact a good webmaster. The web site loading pace is amazing. It kind of feels that you’re doing any unique trick. Moreover, The contents are masterwork. you’ve done a fantastic activity on this subject!
https://shorturl.fm/dqGH7
https://shorturl.fm/XG7D4
Can I just say what a reduction to seek out somebody who really knows what theyre speaking about on the internet. You undoubtedly know how to carry a difficulty to mild and make it important. Extra individuals have to read this and understand this facet of the story. I cant believe youre not more popular because you positively have the gift.
I needed to thank you for this very good read!! I definitely enjoyed every bit of it. I have you bookmarked to look at new stuff you post…
I was very pleased to find this web-site.I wished to thanks on your time for this wonderful read!! I undoubtedly enjoying every little bit of it and I have you bookmarked to check out new stuff you weblog post.
I quite like looking through an article that can make men and women think. Also, many thanks for permitting me to comment.
Thanks for these pointers. One thing I additionally believe is the fact credit cards featuring a 0 monthly interest often lure consumers with zero monthly interest, instant authorization and easy internet balance transfers, nonetheless beware of the main factor that will void the 0 easy neighborhood annual percentage rate as well as throw one out into the terrible house quick.
Hello! I could have sworn I’ve visited your blog before but after going through many of the articles I realized it’s new to me. Nonetheless, I’m definitely pleased I found it and I’ll be book-marking it and checking back often.
My coder is trying to convince me to move to .net from PHP. I have always disliked the idea because of the costs. But he’s tryiong none the less. I’ve been using Movable-type on a number of websites for about a year and am nervous about switching to another platform. I have heard good things about blogengine.net. Is there a way I can transfer all my wordpress content into it? Any help would be greatly appreciated!
You ought to be a part of a contest for one of the highest quality websites on the web. I most certainly will highly recommend this website!
Good web site! I really love how it is simple on my eyes and the data are well written. I am wondering how I could be notified whenever a new post has been made. I have subscribed to your RSS which must do the trick! Have a great day!
Please let me know if you’re looking for a author for your site. You have some really good articles and I believe I would be a good asset. If you ever want to take some of the load off, I’d love to write some content for your blog in exchange for a link back to mine. Please blast me an e-mail if interested. Thank you!
Hmm it appears like your blog ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog. I as well am an aspiring blog blogger but I’m still new to everything. Do you have any points for first-time blog writers? I’d definitely appreciate it.
Pretty! This has been a really wonderful article. Thanks for providing this info.
Everything is very open with a precise clarification of the issues. It was truly informative. Your website is very useful. Many thanks for sharing.
Howdy, I do believe your site may be having internet browser compatibility issues. Whenever I look at your site in Safari, it looks fine however, when opening in IE, it has some overlapping issues. I just wanted to provide you with a quick heads up! Other than that, wonderful site!
Hey just wanted to give you a quick heads up. The words in your content seem to be running off the screen in Firefox. I’m not sure if this is a formatting issue or something to do with web browser compatibility but I figured I’d post to let you know. The style and design look great though! Hope you get the problem fixed soon. Cheers
Aw, this was a very nice post. Spending some time and actual effort to produce a superb article… but what can I say… I hesitate a lot and never manage to get anything done.
I want to to thank you for this excellent read!! I definitely loved every bit of it. I have you book-marked to check out new stuff you post…
You should take part in a contest for one of the best blogs on the web. I’ll recommend this website!