服务器root用户:
[root@localhost ~]# ifconfig
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.130.128 netmask 255.255.255.0 broadcast 192.168.130.255
inet6 fe80::20c:29ff:fe2c:de8 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:2c:0d:e8 txqueuelen 1000 (Ethernet)
RX packets 309 bytes 30419 (29.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 247 bytes 24604 (24.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 17 bytes 2039 (1.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 17 bytes 2039 (1.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
客户端:
创密钥:
[redhat@localhost root]$ ssh-keygen
密钥:[redhat@localhost root]$ ll /home/redhat/.ssh
总用量 8
-rw-------. 1 redhat redhat 2622 3月 14 20:55 id_rsa
-rw-r--r--. 1 redhat redhat 582 3月 14 20:55 id_rsa.pub
[redhat@localhost root]$ ll /home/redhat/.ssh
总用量 8
-rw-------. 1 redhat redhat 2622 3月 14 20:55 id_rsa
-rw-r--r--. 1 redhat redhat 582 3月 14 20:55 id_rsa.pub
传密钥给服务器root用户:
[redhat@localhost root]$ ssh-copy-id root@192.168.130.128
远程连接服务器root用户
[redhat@localhost root]$ ssh 'root@192.168.130.128'
Activate the web console with: systemctl enable --now cockpit.socket
Register this system with Red Hat Insights: insights-client --register
Create an account or view all your systems at https://red.ht/insights-dashboard
Last failed login: Tue Mar 14 20:59:14 CST 2023 from 192.168.130.129 on ssh:notty
There was 1 failed login attempt since the last successful login.
Last login: Tue Mar 14 20:51:16 2023 from 192.168.130.1
配置dns正向解析
下载bind
[root@bogon ~]# yum install bind -y
编辑/etc/named.conf文件
(1) 修改解析的主机为自己并且允许的用户为139网段的所有人
options {
listen-on port 53 { 192.168.139.128; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
secroots-file "/var/named/data/named.secroots";
recursing-file "/var/named/data/named.recursing";
allow-query {192.168.139.128/24 ; };
(2)修改区域配置文件,添加正向区域配置
zone "abc.com" IN{ #正向解析abc.com区域
type master; #类型为主区域服务器配置
file "abc.zone"; #指定区域解析文件为abc.zone
};
进入到/var/named下
[root@bogon ~]# cd /var/named
$TTL 1D
@ IN SOA dns1.abc.com. test.163.com (
0 ;serial #序列号,主从同步序列号越大代表越新
1D ;refresh #刷新时间
1H ;retry #请求dns请求不到重试时间间隔
1w ;expire #和主dns连接不上的时候,失效时间不在请求
3H ) ;minimum #最小的刷新时间
IN NS dns1.abc.com.
IN MX 10 mail.abc.com.
dns1.abc.com. IN A 192.168.80.1
dns2.abc.com. IN A 172.16.0.253
fileserver.abc.com. IN A 172.16.0.100
printserver.abc.com. IN A 172.16.0.101
www.abc.com. IN A 172.16.0.200
www.abc.com. IN A 172.16.0.201
mail.abc.com. IN A 172.16.0.25
ntp.abc.com. IN A 172.16.0.22
;CNAME: www,abc.com. -> web.abc.com.
web IN CNAME www #别名:web.abc.com
启动服务
[root@bogon named]# systenctl restart named
测试:
nslookup dns1.abc.com 192.168.139.128
nslookup dns2.abc.com 192.168.139.128
nslookup fileserver.abc.com 192.168.139.128
nslookup printserver.abc.com 192.168.139.128
nslookup www.abc.com 192.168.139.128
nslookup www.abc.com 192.168.139.128
nslookup mail.abc.com 192.168.139.128
nslookup ntp.abc.com 192.168.139.128
[root@localhost ~]nslookup dns1.abc.com 192.168.139.128
Server: 192.168.139.128
Address: 192.168.139.128#53
Name: dns1.abc.com
Address: 192.168.139.128
[root@localhost ~]nslookup dns2.abc.com 192.168.139.128
Server: 192.168.139.128
Address: 192.168.139.128#53
Name: dns2.abc.com
Address: 172.16.0.253
[root@localhost ~]nslookup fileserver.abc.com 192.168.139.128
Server: 192.168.139.128
Address: 192.168.139.128#53
Name: fileserver.abc.com
Address: 172.16.0.100
[root@localhost ~]nslookup printserver.abc.com 192.168.139.128
Server: 192.168.139.128
Address: 192.168.139.128#53
Name: printserver.abc.com
Address: 172.16.0.101