cma*_*.fr 14 network-manager dns dnsmasq systemd-resolved
我想使用 dnsmasq 获得快速的 dns 解析并保持默认的 systemd-resolved。
寻找一种优雅的方式来做到这一点
cma*_*.fr 12
我想使用 dnsmasq 获得快速的 dns 解析,并保持默认的 systemd-resolved/NetworkManager 设置不变以备将来使用。是的,dnsmasq 的巨大 dns 缓存可以提高浏览速度。是的,目标是保留 18.04 的默认特色 dns 设置
1 - 使用 sudo
apt-get -y install dnsmasq
Run Code Online (Sandbox Code Playgroud)
2 - 使用 sudo
tee -a /etc/dnsmasq.conf << ENDdm
interface=lo
bind-interfaces
listen-address=127.0.0.1
# DNS server from OpenDns. Use yours...
server=208.67.222.222
server=208.67.220.220
ENDdm
systemctl restart dnsmasq
systemctl enable dnsmasq
Run Code Online (Sandbox Code Playgroud)
3 - 使用 USER,配置 NetworkManager
# Get NM first active profile name
NetManProfile=$(nmcli -t connection show --active | cut -f 01 -d ':')
# remove, if exists, current dns servers
nmcli con mod "$NetManProfile" ipv4.dns ""
# set 'manual' dns server
nmcli con mod "$NetManProfile" ipv4.ignore-auto-dns yes
# set dnsmasq as manually set dns server
nmcli con mod "$NetManProfile" ipv4.dns 127.0.0.1
# i also disabled ip6, do what u want
nmcli con mod "$NetManProfile" ipv6.method ignore
# reconnect to take effect
nmcli connection down "$NetManProfile"
nmcli connection up "$NetManProfile"
Run Code Online (Sandbox Code Playgroud)
4 - 检查验证
Run Code Online (Sandbox Code Playgroud)netstat -antup Proto Recv-Q Send-Q Adresse locale Adresse distante Etat PID/Program name tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 1036/dnsmasq tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 766/systemd-resolve cat /run/systemd/resolve/resolv.conf nameserver 127.0.0.1
归档时间: |
|
查看次数: |
19074 次 |
最近记录: |