1、简单自动生成文本脚本:
cat > word1.txt 创建文本时 会等待输入,如果想不等待输入,直接生成文本,可以先写个脚本(如:word.sh),把对应的输入写在 +END+ +END+之间。运行脚本就可以生成 word1.txt word2.txt 二个文本了,不需要等待输入。
[root@localhost ww]# vi word.sh (编写脚本)
#! /bin/bashcat > word1.txt << +END+word1+END+cat > word2.txt << +END+word2+END+
[root@localhost ww]# sh word.sh (执行脚本)
查看生成的文本:
2、同理也可以将名称服务器自动部署到155机
(编写脚本)
[root@localhost root]# vi dnsgen.sh
IP="192.168.155"RIP="155.168.192"#! /bin/bashcat >> /etc/named.conf << +END+zone "gr.org" IN {type master;file "gr.org.db";allow-update { none;};};zone "$RIP.in-addr.arpa" IN{ type master; file "$RIP.db";};+END+cat > /var/named/$RIP.db << +END+\$TTL 86400@ IN SOA ns.gr.org. root.gr.org. ( 20150215 4H 20M 1W 15M) IN NS ns.gr.org.3 IN PTR ns.gr.org.3 IN PTR www.gr.org.4 IN PTR mail.gr.org.+END+cat > /var/named/gr.org.db << +END+\$TTL 86400@ IN SOA ns.gr.org. root.gr.org. ( 20140203 6H 20M 3W 15M)@ IN NS ns.gr.org.@ IN MX 10 mail.gr.org.bbs IN CNAME www.gr.org.www IN A $IP.3ns IN A $IP.3mail IN A $IP.4+END+cat > /etc/resolv.conf << +END+nameserver $IP3+END+
如图
2、执行脚本
开始向192.168.155.3复制上述文本
[root@localhost root]# sh dnsgen.sh
如果没提示,就部署成功,可以看下面文件和内容来看是否正常生成:
[root@localhost root]# cd /var/named
[root@localhost named]# ls155.168.192.db gr.org.db (成功生成)[root@localhost named]# cat /etc/resolv.conf
nameserver 192.168.155.3 (成功添加)[root@localhost named]# cat /etc/named.conf
zone "gr.org" IN {
type master; file "gr.org.db"; allow-update { none; };};zone "155.168.192.in-addr.arpa" IN {
type master; file "155.168.192.db";};至此都正常部署了
3、启动服务
[root@localhost named]# service named start
剩下来验证
参考 后面的部分