DNS安装bind+webmin

1.系统初始化配置yum

#添加访问互联路由
cat > /etc/resolv.conf <<EOF
nameserver 114.114.114.114
nameserver 8.8.8.8
EOF

cat /etc/resolv.conf


#设置为阿里云yum源

rm -rf /etc/yum.repos.d/bak && mkdir -p /etc/yum.repos.d/bak && mv /etc/yum.repos.d/* /etc/yum.repos.d/bak

curl -o /etc/yum.repos.d/CentOS-7.repo http://mirrors.aliyun.com/repo/Centos-7.repo


yum clean all && yum makecache

cd /etc/yum.repos.d


#CentOS7使用/etc/rc.d/rc.local设置开机自动启动
chmod +x /etc/rc.d/rc.local

#安装依赖包
yum -y install vim net-tools lrzsz unzip gcc telnet wget sshpass ntpdate ntp curl

2.安装bind

yum install -y bind*


#开机自启
systemctl enable named

systemctl restart named

systemctl status named


3.安装webmin

cat > /etc/yum.repos.d/webmin.repo <<EOF
[Webmin]

name=Webmin Distribution Neutral

baseurl=http://download.webmin.com/download/yum

enabled=1
EOF




#下载jcameron-key.asc密钥文件

wget http://www.webmin.com/jcameron-key.asc --no-check-certificate

#添加GPG密钥

rpm --import jcameron-key.asc

#2.安装webmin
yum -y install webmin


#开机自启
systemctl enable webmin

systemctl restart webmin

systemctl status webmin



4.登入webmin

https://2xx.x.xx.10:10000

用服务器账户密码 登入
root
b!Maaa$eLvbT5DR^mkBasd

5.二进制安装bind-9.18.17

安装包下载

rpm下载地址:https://pkgs.org/download/bind 输入Bind搜索,依赖bind-utils、bind-libs、bind-license

rpm安装时才需要安装依赖

rpm所有版本下载地址:
http://rpm.pbone.net/index.php3?stat=3&limit=1&srodzaj=1&dl=40&search=bind-9.9&field[]=1&field[]=2

tar所有版本下载地址:ftp://ftp.isc.org/isc

tar下载地址:https://ftp.isc.org/isc/bind9/9.18.17/bind-9.18.17.tar.gz

可视化管理插件:https://gitee.com/opendevops/codo-dns



yum -y install net-tools vim gcc* tcpdump cmake bind-utils zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel libxml* git wget  libtool 

yum install -y epel-release libuv libuv-devel libcap-devel libcap-devel libnghttp2-devel userspace-rcu-devel 


xz -d bind-9.18.17.tar.xz

tar xvf bind-9.*.tar


cd /root/bind-9.*


./configure --prefix=/usr/local/named  


#安装
make && make install

#查看版本
/usr/local/named/sbin/named -v

#创建运行用户-设置不能登入
groupadd named  
useradd -g named -s /sbin/nologin named


mkdir /usr/local/named/zones        #保存dns zone配置文件的目录
mkdir /usr/local/named/log          #保存日志就新建这个目录
touch /usr/local/named/etc/named.conf #保存DNS配置文件

cd /usr/local/named/etc/
/usr/local/named/sbin/rndc-confgen > rndc.conf
cat rndc.conf > rndc.key
chmod 777 /usr/local/named/zones/
tail -10 rndc.conf | head -9 | sed s/#\ //g > named.conf



ln -s /usr/local/named/etc/named.conf /etc/named.conf




chown -R named:named /usr/local/named/
chown -R named:named /var/named/


cat /dev/null > /var/log/messages

/usr/local/named/sbin/named -u named -c /usr/local/named/etc/named.conf


ps -ef|grep named

cat /var/log/messages




6.设置二进制开机自启

vim /etc/profile
export PATH=$PATH:/usr/local/named/bin/

# 刷新环境变量,立即生效
source /etc/profile



mkdir -p  /etc/named

# 编译安装目录:/usr/local/named
# 配置⽂件: /usr/local/named/named.conf
mkdir /etc/named
ln -s /usr/local/named/etc/named.conf /etc/named/

# 在系统服务目录里创建 named.service 文件



cat > /lib/systemd/system/named.service << EOF
[Unit]
Description = named.server
After = network.target

[Service]
Type = forking
ExecStart = /usr/local/named/sbin/named -u named -c /usr/local/named/etc/named.conf
PrivateTmp = true

[Install]
WantedBy = multi-user.target
EOF


# 开机自启named服务
systemctl enable named

# 启动named服务
systemctl start named && systemctl status named

# 关闭named服务
systemctl stop named && systemctl status named

# 重启named服务
systemctl restart named && systemctl status named

# 查看named服务状态
systemctl status named

你可能感兴趣的:(linux,webmin,bind)