首页 > 系统相关 >ubuntu22.04 部署 dnsmasq

ubuntu22.04 部署 dnsmasq

时间:2023-04-14 20:44:43浏览次数:49  
标签:14 部署 18 ubuntu22.04 2.89 dnsmasq usr local

禁用systemd-resolved

# sudo systemctl disable systemd-resolved
# sudo systemctl stop systemd-resolved

安装依赖

# apt -y install make gcc

下载dnsmasq

# wget https://thekelleys.org.uk/dnsmasq/dnsmasq-2.89.tar.gz

安装dnsmasq

创建dnsmasq用户

# groupadd -r dnsmasq && useradd -M -N -g dnsmasq -d /usr/local/dnsmasq  -r  -s /bin/false -c "DNSmasq Server"  dnsmasq

解压dnsmasq

# tar xf dnsmasq-2.89.tar.gz
# cd dnsmasq-2.89

修改安装路径

# grep PREFIX Makefile 
PREFIX        = /usr/local/dnsmasq-2.89     # 按需修改
BINDIR        = $(PREFIX)/sbin
MANDIR        = $(PREFIX)/share/man
LOCALEDIR     = $(PREFIX)/share/locale

安装dnsmasq

# make install
make[1]: Entering directory '/root/dnsmasq-2.89/src'
.....
cc  -o dnsmasq cache.o rfc1035.o util.o option.o forward.o network.o dnsmasq.o dhcp.o lease.o rfc2131.o netlink.o dbus.o bpf.o helper.o tftp.o log.o conntrack.o dhcp6.o rfc3315.o dhcp-common.o outpacket.o radv.o slaac.o auth.o ipset.o pattern.o domain.o dnssec.o blockdata.o tables.o loop.o inotify.o poll.o rrfilter.o edns0.o arp.o crypto.o dump.o ubus.o metrics.o hash-questions.o domain-match.o nftset.o   
make[1]: Leaving directory '/root/dnsmasq-2.89/src'
install -d /usr/local/dnsmasq-2.89/sbin
install -d /usr/local/dnsmasq-2.89/share/man/man8
install -m 644 man/dnsmasq.8 /usr/local/dnsmasq-2.89/share/man/man8 
install -m 755 src/dnsmasq /usr/local/dnsmasq-2.89/sbin

创建软连接

# ln -svf /usr/local/dnsmasq-2.89/ /usr/local/dnsmasq
'/usr/local/dnsmasq' -> '/usr/local/dnsmasq-2.89/'

复制配置文件

# cp dnsmasq-2.89/dnsmasq.conf.example /usr/local/dnsmasq/dnsmasq.conf

dnsmasq.service

[Unit]
Description=dnsmasq - A lightweight DHCP and caching DNS server
Requires=network.target
Wants=nss-lookup.target
Before=nss-lookup.target
After=network.target

[Service]
Type=forking
PIDFile=/var/run/dnsmasq.pid
ExecStart=/usr/local/dnsmasq/sbin/dnsmasq --conf-file=/usr/local/dnsmasq/dnsmasq.conf
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target

dnsmasq.conf

# egrep -v "^$|^#" /usr/local/dnsmasq/dnsmasq.conf 
bogus-priv
resolv-file=/usr/local/dnsmasq/resolv.conf
strict-order
user=dnsmasq
group=dnsmasq
addn-hosts=/usr/local/dnsmasq/hosts

准备文件

# cp /etc/resolv.conf /usr/local/dnsmasq/
# touch /usr/local/dnsmasq/hosts
# chown -R dnsmasq.dnsmasq /usr/local/dnsmasq

运行dnsmasq

# systemctl enable dnsmasq
# systemctl start dnsmasq
Apr 14 19:26:50 172-16-18-54 systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
Apr 14 19:26:50 172-16-18-54 dnsmasq[46942]: started, version 2.89 cachesize 150
Apr 14 19:26:50 172-16-18-54 dnsmasq[46942]: compile time options: IPv6 GNU-getopt no-DBus no-UBus no-i18n no-IDN DHCP DHCPv6 no-Lua TFTP no-conntrack ips>
Apr 14 19:26:50 172-16-18-54 systemd[1]: Started dnsmasq - A lightweight DHCP and caching DNS server.
Apr 14 19:26:50 172-16-18-54 dnsmasq[46942]: reading /usr/local/dnsmasq/resolv.conf
Apr 14 19:26:50 172-16-18-54 dnsmasq[46942]: using nameserver 10.42.255.1#53
Apr 14 19:26:50 172-16-18-54 dnsmasq[46942]: using nameserver 10.42.255.2#53
Apr 14 19:26:50 172-16-18-54 dnsmasq[46942]: using nameserver 114.114.114.114#53
Apr 14 19:26:50 172-16-18-54 dnsmasq[46942]: read /etc/hosts - 9 names
Apr 14 19:26:50 172-16-18-54 dnsmasq[46942]: read /usr/local/dnsmasq/hosts - 0 names

参考文档

https://thekelleys.org.uk/dnsmasq/doc.html

标签:14,部署,18,ubuntu22.04,2.89,dnsmasq,usr,local
From: https://www.cnblogs.com/wangguishe/p/17317977.html

相关文章

  • docker03 容器操作 应用部署 迁移备份 dockerfile
    今日内容详细目录今日内容详细1容器操作2应用部署2.1mysql部署2.2redis部署2.3nginx部署3迁移与备份4Dockerfile1容器操作#启动容器 dockerstart容器id#停止容器 dockerstop容器id#文件拷贝 #容器的文件copy到宿主机上(不是在容器内执行)dockercp容......
  • 学习K8S 使用Operator部署管理Nginx
    创建一个KubernetesOperator部署nginx的大致过程如下:确定您要使用的OperatorSDK版本并安装它。使用OperatorSDK命令行创建新的Operator项目。定义CustomResourceDefinition(CRD),即将在Kubernetes中定义的自定义资源规范,以及该资源的状态和操作。例如,定义一个名为......
  • 自己项目用到的Nginx环境部署手册
    nginxsticky基于cookie的负载均衡googler开发的google-perftools优化Nginx管理,性能将会有一定程度的提升[/size]([/size][size=10.5pt;font-family:'Calibri',sans-serif;"lang="EN-US]64位[/size]操作系统请先安装libunwind库,32位操作系统不要安装。libunwind库为基于64......
  • docker-day4——Dockerfile、docker私有仓库、dockercompose介绍、dockercompose部署f
    目录一、Dockerfile1.1常用和不常用命令1.2dockerfile构建一个djagno项目二、docker私有仓库2.1镜像传到官方仓库2.2镜像分层2.3私有仓库搭建三、dockercompose介绍四、dockercompose部署flask+redis项目4.1新建flask项目app.py4.2编写Dockerfile--》用于构建flask项目的......
  • kafka集群部署教程
    ####部署zookeeper集群1、先部署zookeeper集群一般是3个节点,安装zookeeper依赖java环境先安装jdk   yuminstalljava-1.8.0-openjdk-devel-y    java-version#查看jdk版本2、创建工作目录(3个节点都需要执行)   mkdir-p/usr/local/zookeeper  ......
  • linux中systemctl管理go服务 (gin)git部署
    go安装下载 https://golang.google.cn/dl/解压至指定目录,一般到/usr/localsudotar-C/usr/local-xzfgo**.linux-amd64.tar.gz设置环境变量#修改~/.bashrc文件$sudogedit~/.bashrc#在该文件最后一行插入$exportPATH=$PATH:/usr/local/go/bin$source~/......
  • laravel + node 在vagrant + ubuntu18.04 部署过程
    注意:当前的操作都是基于本地mac开发坏境配置操作,遇到了很多坑,这里借此做记录:一、ubuntu18.04上部署的php环境php7.4+msyql,常用的php扩展之类的可以自行的查询安装二、ubuntu18.04上部署nodejs14.17.6开始搜索直接用命令,装的node不是我们当前所需要的最后决定使......
  • Tomcat 5.5部署jsp项目—jsp乱码问题的解决
    1、最基本的乱码问题。这个乱码问题是最简单的乱码问题。一般新会出现。就是页面编码不一致导致的乱码。<%@pagelanguage="java"pageEncoding="UTF-8"%><%@pagecontentType="text/html;charset=iso8859-1"%><html><head><title>中文问题</title><......
  • docker部署nacos服务
    windowsdockerrun--namenacos-eMODE=standalone-v/mnt/docker_data/nacos/conf/application.properties:/D/worktool/nacos/application.properties-p8848:8848-d-p9848:9848nacos/nacos-server:v2.2.0linuxdockerrun--namenacos-eMODE=standalone-v......
  • docker容器操作,应用部署,迁移与备份,Dockerfile
    目录容器操作应用部署mysql部署redisnginx迁移与备份容器保持为镜像镜像备份和恢复Dokcerfile镜像从哪里来使用Dockerfile来构建什么是DockerfileDockerfile的命令构建一个带vim的centos镜像基于Python3.8构建一个能够运行你这个程序的镜像容器操作启动容器dockerstart容器i......