ubuntu16.04 搭建 dns 服务器

具体需求:部门管理中,有git服务器,部门管理系统的服务器,* 服务器等等,每一个访问都是用ip,这样很烦,不高大上,我想整成这样:git服务器:git.com 管理系统的服务器:mag.com… 的形式。

解决方法:新建一个虚拟机(这里是ubuntu 16.04 64位),搭建成一个dns服务器,然后让部门的每一台电脑的dns指向dns服务器,就可以了。

环境(都是ubuntu16.04 64位):我的git服务器: 10.10.3.155
管理系统所在的服务器:10.10.3.154
新建的dns服务器:10.10.3.153

现在开始搭建dns服务器(10.10.3.153)

1.更新环境,切换成root用户

su root
apt-get update

2.安装bind9

apt-get install bind9

3.配置/etc/bind/named.conf.local 文件(服务器域解析文件)

zone “mag.com”{
type master;
file “db.mag.com”;
};
zone “git.com”{
type master;
file “db.git.com”;
};

4.步骤3中的db.mag.com和db.git.com是域解析文件,默认在/etc/var/cache/bind,它们的格式与bind9自带的模板db.local格式一致,我们把/etc/bind/db.local文件copy到/etc/var/cache/bind下,并命名为db.mag.com 和 db.git.com

cp /etc/bind/db.local /var/cache/bind/db.mag.com
cp /etc/bind/db.local /var/cache/bind/db.git.com

5.编辑域解析文件

vim /var/cache/bind/db.mag.com

在末尾加:@ IN A 10.10.3.154

即:

;
; BIND data file for local loopback interface
;
$TTL 604800
@ IN SOA localhost. root.localhost. (
2 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS localhost.
@ IN A 127.0.0.1
@ IN AAAA ::1
@ IN A 10.10.3.154

db.git.com 的配置同理,在/var/cache/bind/db.git.com *后面加一句@ IN A 10.10.3.155 即可。

6.配置/etc/bind/named.conf.options 文件

在中间加入下面的代码,dns服务器就可以访问外网了

forwarders {
8.8.8.8;
};

完整的文件如下:

options {
directory “/var/cache/bind”;

// If there is a firewall between you and nameservers you want
// to talk to, you may need to fix the firewall to allow multiple
// ports to talk. See http://www.kb.cert.org/vuls/id/800113

// If your ISP provided one or more IP addresses for stable
// nameservers, you probably want to use them as forwarders.
// Uncomment the following block, and insert the addresses replacing
// the all-0’s placeholder.

// forwarders {
// 0.0.0.0;
// };

forwarders {
8.8.8.8;
};

//========================================================================
// If BIND logs error messages about the root key being expired,
// you will need to update your keys. See https://www.isc.org/bind-keys
//========================================================================
dnssec-validation auto;

auth-nxdomain no; # conform to RFC1035
listen-on-v6 { any; };
};

7.重启bind9服务

/etc/init.d/bind9 restart

8.测试
%title插图%num

在浏览器输入:git.com 回车

%title插图%num

9.就这样成功了。

ubuntu16.04阿里云ECS安装图形化界面

前提:阿里云ECS ubuntu16.04

时间:2019年11月

步骤简要说明:

阿里云 ECS服务器版本: ubuntu16.04 抢占式 64bit

step1: 安装图形化界面操作

step2: 阿里云服务器后台进入图形化界面

​ 远程连接密钥是多少,要记住 比如:437493

step3: 阿里云控制台进行远程连接,下载teamviewer

​ *好登录自己本地的teamviewer账号,并自己设置连接的密码

step4: 在自己电脑(win or linux)装上teamviewer进行远程ID连接

​ 一般是输入密码即可匹配

step5: 关于屏幕分辨率匹配问题,teamviewer连接后一共才那几个选项,慢慢试,暂未找到好的解决方案。

下面是亲测可用的流程


安装图形化界面操作

更新软件源

# apt-get update

安装图形化界面(该步骤大概需要花2分钟)

# apt-get install ubuntu-desktop

重启

reboot

如需使用其他用户登录,需要修改50-ubuntu.conf配置文件

# vi /usr/share/lightdm/lightdm.conf.d/50-ubuntu.conf

修改为

  1. [Seat:*]
  2. user-session=ubuntu
  3. greeter-show-manual-login=true
  4. allow-guest=false

然后重启

# reboot

%title插图%num

管理员控制台

进入阿里云-控制台-ECS-选择自己的ECS服务器-远程控制

此时会提示远程连接的验证码,只提示一次,务必记住

为确保万一,请设置自己的ECS的登录密码。

username:root password:请自行设置且记住

此时已经登录进图形化界面了,接下来就是下载teamviewer

打开火狐浏览器,搜索 teamviewer,选择download,下载指定版本

♥ ubuntu16.04 64bit 下载 ubuntu支持的版本 .deb x86 64位

♥ 下载完成,执行deb 进行 install即可

♥ 安装完毕,在software搜索teamviewer打开即可

打开teamviewer进行

? 首选登录自己teamviewer账号

? 在password旁边有个刷新按钮,点击选择 set personal password

这样会比较方便进行远程连接

本地teamviewer连接

*好可以在计算机和联系人这里添加远程计算机的连接方式