Skip to content

techprober/mosdns-lxc-deploy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mosdns-lxc-deploy

A generic guide to deploy mosdns in Proxmox LXC Container

License version lastcommit

Project Owner

CopyRight 2021-2023 @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.

Table of contents

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 playbook to 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}.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.

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