mosdns-lxc-deploy
mosdns-lxc-deploy copied to clipboard
A generic guide to deploy mosdns in Proxmox LXC Container
mosdns-lxc-deploy
A generic guide to deploy mosdns in Proxmox LXC Container
Project Owner
CopyRight 2021-2023 @TechProber. All rights reserved.
Maintainer: Kev (@piyoki)
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.
Table of contents
- Documentation
- How to Use
- Preparation
- Download Binary
- Download Rules
- Reset Port 53
- Update Configuration
- Run as Systemd Service
- CN Users
- Appendix
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
Preparation
Create a new directory for mosdns
mkdir -p /etc/mosdns
Create sub directories
mkdir -p /etc/mosdns/{ips,domains,downloads,custom,scripts}
touch 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 playbookto automate this, check it out.
Download Binary
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
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
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
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
[!WARNING] Please take a look at the content of
config-{VERSION}.ymlbefore 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.
Run as Systemd Service
sudo tee /etc/systemd/system/mosdns.service <<EOF
[Unit]
Description=A DNS forwarder
ConditionFileIsExecutable=/usr/bin/mosdns
[Service]
WorkingDirectory=/etc/mosdns
Type==notify
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
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
-
Auto generate
geoip.txt,geosites.txt(since*.datare 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