z-x-f / mosdns-lxc-deploy

Deploy mosdns in Proxmox LXC Container

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mosdns LXC Deploy

Deploy mosdns in Proxmox LXC Container

License Docker Docker lastcommit

Project Owner

CopyRight 2021-2022 @TechProber. All rights reserved.

Maintainer: Kevin Yu (@yqlbu)

Related Projects

  • IrineSistiana/mosdns - A self-hosted DNS resolver
  • tteck/Proxmox - Proxmox Helper Scripts
  • Loyalsoldier/v2ray-rules-dat - Enhanced edition of V2Ray rules dat files, compatible with Xray-core, Shadowsocks-windows, Trojan-Go and leaf.
  • Loyalsoldier/geoip - Enhanced edition of GeoIP files for V2Ray, Xray-core, Trojan-Go, Clash and Leaf, with replaced CN IPv4 CIDR available from ipip.net, appended CIDR lists and more.

Documentation

Mosdns Official Wiki: https://irine-sistiana.gitbook.io/mosdns-wiki/

Know DNS Providers: https://adguard-dns.io/kb/general/dns-providers/

How to Use

Create a new directory for mosdns:

mkdir -p /etc/mosdns

Preparation

Make sure you have the following file structure present on your host:

# /etc/mosdns
./
|-- cache.dump
|-- config.yml
|-- custom
|-- domains
|-- downloads
`-- ips

4 directories, 2 files

create sub directories

mkdir -p /etc/mosdns/{ips,domains,downloads,custom}
touch cache.dump

Note There is a dedicated bootstrap playbook to automate this, check it out.

Download Binary

Download the latest mosdns binary from the GitHub Release Page

wget https://github.com/IrineSistiana/mosdns/releases/download/{VERSION}/mosdns-{PLATFORM}-{ARCH}.zip
# e.g
# wget https://github.com/IrineSistiana/mosdns/releases/download/v5.1.3/mosdns-linux-amd64.zip
unzip mosdns-linux-amd64.zip
sudo install -Dm755 mosdns /usr/bin

Download Rules

Available Rules - https://github.com/techprober/v2ray-rules-dat/releases

Download and unzip the geoip.zip and geosite.zip files to ./ips/ and ./domains respectively.

MOSDNS_PATH=/etc/mosdns
LATEST_TAG=$(curl https://api.github.com/repos/techprober/v2ray-rules-dat/releases/latest --silent |  jq -r ".tag_name)
wget -O $MOSDNS_PATH/downloads/geoip.zip https://github.com/techprober/v2ray-rules-dat/releases/download/$LATEST_TAG/geoip.zip
wget -O $MOSDNS_PATH/downloads/geosite.zip https://github.com/techprober/v2ray-rules-dat/releases/download/$LATEST_TAG/geosite.zip
unzip $MOSDNS_PATH/downloads/geoip.zip -d ./ips
unzip $MOSDNS_PATH/downloads/geosite.zip -d ./domains

Reset Port 53

mkdir -p /etc/systemd/resolved.conf.d

# /etc/systemd/resolved.conf.d/mosdns.conf
[Resolve]
DNS=127.0.0.1
DNSStubListener=no

Specifying 127.0.0.1 as DNS server address is necessary because otherwise the nameserver will be 127.0.0.53 which doesn’t work without DNSStubListener.

Activate another resolv.conf file:

sudo mv /etc/resolv.conf /etc/resolv.conf.backup
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

Restart DNSStubListener:

systemctl daemon-reload
systemctl restart systemd-resolved

Update Configuration

Get the latest config file, namely config-{VERSION}.yml, from ./mosdns folder in this repository, copy it to /etc/mosdns, and update params to fit your need.

Run as Systemd Service

sudo tee /etc/systemd/system/mosdns.service <<EOF
[Unit]
Description=A DNS forwarder
ConditionFileIsExecutable=/usr/bin/mosdns

[Service]
StartLimitInterval=5
StartLimitBurst=10
ExecStart=/usr/bin/mosdns "start" "--as-service" "-d" "/etc/mosdns" "-c" "/etc/mosdns/config.yml"

Restart=always

RestartSec=120
EnvironmentFile=-/etc/sysconfig/mosdns

[Install]
WantedBy=multi-user.target
EOF

sudo systemctl daemon-reload
sudo systemctl enable mosdns --now

CN Users

To enhance the ad-free feature, we've added additional AdBlockList to our self-managed geoip.dat and geosite.dat

Please check out more details in TechProber/v2ray-rules-dat.

Appendix

About

Deploy mosdns in Proxmox LXC Container

License:MIT License