A generic guide to deploy mosdns in Proxmox LXC Container
CopyRight 2021-2023 @TechProber. All rights reserved.
Maintainer: Kev (@piyoki)
- 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.
Mosdns Official Wiki: https://irine-sistiana.gitbook.io/mosdns-wiki/
Know DNS Providers: https://adguard-dns.io/kb/general/dns-providers/
Create a new directory for mosdns
mkdir -p /etc/mosdns
Create sub directories
sudo mkdir -p /etc/mosdns/{ips,domains,downloads,custom,scripts}
sudo touch /etc/mosdns/cache.dump
Make sure you have the following file structure present on your host:
# /etc/mosdns
./
|-- cache.dump
|-- config.yml
|-- custom
|-- domains
|-- downloads
|-- scripts
`-- ips
5 directories, 2 files
Note
There is a dedicated bootstrap playbook
to automate this, check it out.
Download the latest mosdns binary from the GitHub Release Page
MOSDNS_PATH=/etc/mosdns
curl -o $MOSDNS_PATH/downloads/mosdns.zip 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_PATH/downloads/mosdns.zip
sudo install -Dm755 $MOSDNS_PATH/downloads/mosdns /usr/bin
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
curl --progress-bar -JL -o $MOSDNS_PATH/downloads/geoip.zip https://github.com/techprober/v2ray-rules-dat/raw/release/geoip.zip
curl --progress-bar -JL -o $MOSDNS_PATH/downloads/geosite.zip https://github.com/techprober/v2ray-rules-dat/raw/release/geosite.zip
unzip -o $MOSDNS_PATH/downloads/geoip.zip -d $MOSDNS_PATH/ips
unzip -o $MOSDNS_PATH/downloads/geosite.zip -d $MOSDNS_PATH/domains
Note
Alternatively, you may use a dedicated script to automatically download and extract the geodata artifacts. See ./scripts/geodata-update.sh
curl -L -o /usr/local/etc/mosdns/scripts/geodata-update.sh https://github.com/techprober/mosdns-lxc-deploy/raw/master/scripts/geodata-update.sh
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
Warning
Please take a look at the content of config-{VERSION}.yml
before you copy it to /etc/mosdns
. It is a boilerplate template which intends to provide users a reference to start with customizing their own config.
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.
sudo tee /etc/systemd/system/mosdns.service <<EOF
[Unit]
Description=A DNS forwarder
ConditionFileIsExecutable=/usr/bin/mosdns
[Service]
WorkingDirectory=/etc/mosdns
Type=simple
User=root
StartLimitInterval=5
StartLimitBurst=10
ExecStart=/usr/bin/mosdns start -c config.yml
Restart=abnormal
RestartSec=120
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable mosdns --now
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.
-
Auto generate
geoip.txt
,geosites.txt
(since*.dat
are deprecated in v5) - https://github.com/techprober/v2dat -
CI (automate
*.txt export
) - https://github.com/techprober/v2ray-rules-dat/blob/master/.github/workflows/run.yml -
Available Rules - https://github.com/techprober/v2ray-rules-dat/releases