thảo luận Cài đặt Adguard Home - Chặn quảng cáo trên VPS

Con 4/24 Tokyo speedtets.
Screenshot 2021-09-02 180228.png
 
Cách chặn từng quốc gia quá phiền phức, phải chọn từng quốc gia một. Nên áp dụng cách chỉ cho IP VN kết nối vào, còn lại chặn hết, như thế triệt để hơn. Để làm việc này thì cần làm 2 bước chính:

  • Chỉnh IP VN vào Source IP của zone public (default source IP của zone public là any)
  • Chuyển interface (card mạng của server) đang nằm default ở zone public sang zone drop

Khi 1 kết nối từ ngoài Internet đến server, FirewallD sẽ kiểm tra:

  • Source IP là bao nhiêu, nếu là IP VN => vào zone public, truy cập HTTP, DNS, SSH v.v...
  • Source IP khác IP VN => interface đang tiếp nhận kết nối thuộc zone nào, đang nằm ở zone drop => loại bỏ kết nối.

Loại bỏ cấu hình cũ, đưa FirewallD về default:

sudo su
rm -f /etc/firewalld/zones/*
firewall-cmd --complete-reload

Thêm các rule cho các dịch vụ hoạt động:

firewall-cmd --zone=public --add-port=3000/tcp --permanent
firewall-cmd --zone=public --add-port=53/udp --permanent
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=443/tcp --permanent
firewall-cmd --zone=public --add-port=853/tcp --permanent

Download list IP VN:

wget https://www.ipdeny.com/ipblocks/data/countries/vn.zone

Thêm IP VN vào Whitelist:

firewall-cmd --new-ipset=whitelist --type=hash:net --option=family=inet --option=hashsize=4096 --option=maxelem=200000 --permanent
firewall-cmd --ipset=whitelist --add-entries-from-file=./vn.zone --permanent

Chỉnh Whitelist vào Source của zone Public:

firewall-cmd --zone=public --add-source=ipset:whitelist --permanent

Kiểm tra các zone :

firewall-cmd --get-active-zones

=> Lưu ý zone public (default), xem interface nào đang nằm trong zone public, ví dụ eth0

Move interface (ví dụ eth0) vào zone drop:


firewall-cmd --zone=drop --change-interface=eth0 --permanent

Khởi động lại FirewallD để áp dụng các cấu hình vừa chỉnh:

firewall-cmd --reload

Tổng hợp cấu hình FirewallD:

firewall-cmd --zone=public --add-port=3000/tcp --permanent
firewall-cmd --zone=public --add-port=53/udp --permanent
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --zone=public --add-port=443/tcp --permanent
firewall-cmd --zone=public --add-port=853/tcp --permanent
firewall-cmd --ipset=whitelist --add-entries-from-file=./vn.zone --permanent
firewall-cmd --zone=public --add-source=ipset:whitelist --permanent
firewall-cmd --zone=drop --change-interface=eth0 --permanent
Xin cách cấu hình này cho server ubuntu bác ơi
 
Em đang tính thử cái Wire Guard mà đang lười :LOL:)
Cài L2TP tại nó không cần dùng thêm app để kết nối, có thể setup thủ công (bỏ qua yêu cầu về bảo mật - cái này mình nghĩ cũng bảo mật rồi :D). Hôm trước cài thử trên con 1/1- 0,48Gbs thì test tốc độ tầm 30-40Mbs. Hơi chậm

Sent from Xiaomi M2007J3SG via nextVOZ
 
Code:
[HEADING=2]Set public key value[/HEADING]
In order to have secure shell (SSH) access to the instance you need to have a keypair, e.g. ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub. Second one (public key) filename should be provided to a command below. The are plenty of tutorials on how to do that, we won't cover this part here.

Change the string variable $sshKey - paste the contents of your public key ~/.ssh/id_rsa.pub (or you won't be able to login into the newly created instance).

Cái đoạn này là sao các bác nhỉ. Đến đây e tịt không sao step tiếp đc, run php index.php toàn lỗi :D
 
Code:
[HEADING=2]Set public key value[/HEADING]
In order to have secure shell (SSH) access to the instance you need to have a keypair, e.g. ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub. Second one (public key) filename should be provided to a command below. The are plenty of tutorials on how to do that, we won't cover this part here.

Change the string variable $sshKey - paste the contents of your public key ~/.ssh/id_rsa.pub (or you won't be able to login into the newly created instance).

Cái đoạn này là sao các bác nhỉ. Đến đây e tịt không sao step tiếp đc, run php index.php toàn lỗi :D
Ngay #1 bac oi

1630601437681.png
 
Back
Top