linux笔记13

主从DNS同步

当单一DNS无法满足客户需求是开启一个同步的次级DNS,他们dns的内容一致。

主机:

vim /etc/named.rfc1912.zones

zone "asd.com" IN {

type master;

file "asd.com.zone";

allow-update { none; };

allow-transfer { 172.25.254.225; };        从机地址

};

systemctl restart named

从机:

yum install bind -y            安装服务

vim /etc/named.conf            修改配置文件

options {

listen-on port 53 { any; };

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";

allow-query     { any; };

dnssec-validation no;            同主机一致

vim /etc/named.rfc1912.zones

zone "asd.com" IN {

type slave;                设置为从机

masters { 172.25.254.125; };            主机地址

file "slaves/asd.com.zone";

allow-update { none; };

};

systemctl restart named                        重启服务

(检测结果)

[[email protected] ~]# dig www.asd.com

; <<>> DiG 9.9.4-RedHat-9.9.4-14.el7 <<>> www.asd.com

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 63544

;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2

;; OPT PSEUDOSECTION:

; EDNS: version: 0, flags:; udp: 4096

;; QUESTION SECTION:

;www.asd.com.INA

;; ANSWER SECTION:

www.asd.com.86400INA172.25.254.126

DNS修改同步

从机:

systemctl stop firewalld         关闭火墙,允许通知通过

主机:

vim /etc/named.rfc1912.zones

zone "asd.com" IN {

type master;

file "asd.com.zone";

allow-update { none; };

allow-transfer { 172.25.254.225; };

also-notify { 172.25.254.225; };                通知从机同步更新

};

vim /var/named/asd.com.zone

$TTL 1D

@       IN SOA  dns.asd.com. root.asd.com. (

01      ; serial        修改serial,提示有更新(最多10位)文件在更新是查看的比较值

1D      ; refresh

1H      ; retry

1W      ; expire

3H )    ; minimum

NS      dns.asd.com.

dns     A       172.25.254.125

www     A       172.25.254.128                                    DNS更新

systemctl restart named                                            重启服务并通知从机更新dns

『测试结果』

主从机DNS保持一致,主机更新,从机同步更新

DNS远程更新

主机(服务端)

setenforce 0                                                更改selinux

chmod 770 /var/named                                        更改目录权限

vim /etc/named.rfc1912.zones                                修改文件

zone "asd.com" IN {

type master;

file "asd.com.zone";

allow-update { 172.25.254.225; };                    发送新的dns的地址

};

发送端:

nsupdate

> server 172.25.254.125                                        更改的dns ip

> update delete www.asd.com                                    删除

> send发送

> server 172.25.254.125

> update add www.asd.com 86400 A 172.25.254.120                    添加新的dns (86400 缓存一天)

> send

> quit                                                            退出

注:当完成> server 172.25.254.125

> update delete www.asd.com

> send

后主机端的/var/named/会出一个asd.com.zone.jnl

当systemctl retsart named 后 该文件会覆盖原本的asd.com.zone,所以建议提前备份

『测试结果』

远程可以更改主机的dns服务(可以进行删除和添加)

DNS远程更新(加密)

主机:

dnssec-keygen -a HMAC-MD5 -b 100 -n HOST gou  (-a 加密类型 -b加密字节 -n 加密用途)

获得公钥和私钥

cp -p /etc/rndc.key /etc/gou.key                复制模版

vim /etc/gou.key                                编写内容

key "gou" {                                        加密名称

algorithm hmac-md5;                        格式

secret "/pLHdCuATXkKuZNjGQ==";             密码

};

vim /etc/named.conf

43   include "/etc/gou.key";

vim /etc/named.rfc1912.zones                     修改配置文件

zone "asd.com" IN {

type master;

file "asd.com.zone";

allow-update { key gou; };                只接受有key的人的修改

};

scp Kgou.+157+64442.* [email protected]:/mnt        远程发送密码给用户以更新dnsderen

systemctl restart named                                    重启服务

发送端:

[[email protected] mnt]# nsupdate -k Kgou.+157+64442.private (-k 用密匙的方式)

> server 172.25.254.125

> update delete www.asd.com                                    删除

> send

> quit退出

『测试结果』

[email protected] named]# ls

asd.com.zone      data     named.ca     named.localhost  slaves

asd.com.zone.jnl  dynamic  named.empty  named.loopback

[email protected] named]# dig www.asd.com

; <<>> DiG 9.9.4-RedHat-9.9.4-14.el7 <<>> www.asd.com

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 55177

;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:

; EDNS: version: 0, flags:; udp: 4096

;; QUESTION SECTION:

;www.asd.com.INA

;; AUTHORITY SECTION:

asd.com.10800INSOAdns.asd.com. root.asd.com. 3 86400 3600 604800 10800

DDNS(花生壳)动态DNS获取

yum install dhcp  -y                                                        安装dhcp

cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example  /etc/dhcp/dhcpd.conf        复制模版

vim /etc/dhcp/dhcpd.conf                                                        配置文件

6 # option definitions common to all supported networks...

7 option domain-name "asd.com";                                                域名

8 option domain-name-servers 172.25.254.125;dns ip

13 # Use this to enble / disable dynamic dns updates globally.

14 ddns-update-style interim;                                                开启dhcp时通知dns

30 subnet 172.25.254.0  netmask 255.255.255.0 {                                子网掩码

31   range 172.25.254.247 172.25.254.249;                                    ip获取段

32   option routers 172.25.254.125;

33 }

34 key gou {                                                                    key名称

35         algorithm hmac-md5;                                                加密方式

36         secret /pLHdCuATXkKuZNjGQ==;

37 };

38 zone asd.com. {

39         primary 127.0.0.1;                                                    自循环

40         key gou;

41 }

vim /var/named/asd.com.zone                                                     复原该文件

systemctl restart named

systemctl restart dhcpd                                                         重启服务

客户端:

更改ip获取方式为dhcp

hostnamectl set-hostname  bbq.asd.com                                         更改主机名(必须属于asd域)

systemctl restart network                                                         重启服务

『测试结果』

dig bbq.asd.com

结果与客户端ip一致

数据库

yum install mariadb-server.x86_64 -y                                    数据库服务的安装

vim /etc/my.cnf                                                          修改配置文件

# Settings user and group are ignored when systemd is used.

# If you need to run mysqld under a different user or group,

# customize your systemd unit file for mariadb according to the

# instructions in http://fedoraproject.org/wiki/Systemd

skip-networking=1                                                        关闭网卡上的数据库端口

systemctl restart mariadb                                                    重启服务

[[email protected] named]# mysql_secure_installation                         开启安全机制

/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB

SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we‘ll need the current

password for the root user.  If you‘ve just installed MariaDB, and

you haven‘t set the root password yet, the password will be blank,

so you should just press enter here.

Enter current password for root (enter for none):                             输入密码(无)

OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB

root user without the proper authorisation.

Set root password? [Y/n] y                                                    设置密码

New password:

Re-enter new password:

Password updated successfully!

Reloading privilege tables..

... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone

to log into MariaDB without having to have a user account created for

them.  This is intended only for testing, and to make the installation

go a bit smoother.  You should remove them before moving into a

production environment.

Remove anonymous users? [Y/n] y                                                  关闭匿名访问

... Success!

Normally, root should only be allowed to connect from ‘localhost‘.  This

ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y                                            不允许root远程访问

... Success!

By default, MariaDB comes with a database named ‘test‘ that anyone can

access.  This is also intended only for testing, and should be removed

before moving into a production environment.

Remove test database and access to it? [Y/n] y                                            不允许临时数据库

- Dropping test database...

... Success!

- Removing privileges on test database...

... Success!

Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

Reload privilege tables now? [Y/n] y                                                        刷新

... Success!

Cleaning up...

All done!  If you‘ve completed all of the above steps, your MariaDB

installation should now be secure.

Thanks for using MariaDB!

mysql -u root -p westos                                                                     登陆

数据库的查询(;表示命令输入完成)

MariaDB [(none)]> SHOW DATABASES;                                                        显示数据库

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

+--------------------+

3 rows in set (0.00 sec)

MariaDB [(none)]> USE mysql;                                                                进入数据库

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

MariaDB [mysql]> SHOW TABLES;                                                        显示数据库中的表

+---------------------------+

| Tables_in_mysql           |

+---------------------------+

| columns_priv              |

| db                        |

| event                     |

| func                      |

| general_log               |

| help_category             |

| help_keyword              |

| help_relation             |

| help_topic                |

| host                      |

| ndb_binlog_index          |

| plugin                    |

| proc                      |

| procs_priv                |

| proxies_priv              |

| servers                   |

| slow_log                  |

| tables_priv               |

| time_zone                 |

| time_zone_leap_second     |

| time_zone_name            |

| time_zone_transition      |

| time_zone_transition_type |

| user                      |

+---------------------------+

24 rows in set (0.00 sec)

MariaDB [mysql]> SELECT User,Host,Password FROM user;            查看user表中的host,user,password字段

+------+-----------+-------------------------------------------+

| User | Host      | Password                                  |

+------+-----------+-------------------------------------------+

| root | localhost | *28C1E2BE21B45562A34B6CC34A19CFAFC2F88F96 |

| root | 127.0.0.1 | *28C1E2BE21B45562A34B6CC34A19CFAFC2F88F96 |

| root | ::1       | *28C1E2BE21B45562A34B6CC34A19CFAFC2F88F96 |

+------+-----------+-------------------------------------------+

3 rows in set (0.00 sec)

MariaDB [mysql]> CREATE DATABASE asd ;                                        创建一个数据库

MariaDB [mysql]> USE asd;                                                    进入数据库

MariaDB [asd]> CREATE TABLE UTAB ( uer varchar(10) not null, password varchar(8) not null, age varchar(3) );                   创建一张表(用户名【10】不能没有,密码【8】不能没有,年龄【3】可以不添)

MariaDB [asd]> SHOW TABLES;                                                    显示数据库

+---------------+

| Tables_in_asd |

+---------------+

| UTAB          |

+---------------+

MariaDB [asd]> DESC UTAB ;                                    显示表的属性

+----------+-------------+------+-----+---------+-------+

| Field    | Type        | Null | Key | Default | Extra |

+----------+-------------+------+-----+---------+-------+

| uer      | varchar(10) | NO   |     | NULL    |       |

| password | varchar(8)  | NO   |     | NULL    |       |

| age      | varchar(3)  | YES  |     | NULL    |       |

+----------+-------------+------+-----+---------+-------+

MariaDB [asd]> INSERT INTO UTAB VALUES (‘asd‘,‘qwe‘,‘24‘);    添加内容进表

Query OK, 1 row affected (0.00 sec)

MariaDB [asd]> SELECT * FROM UTAB ;                                    显示表

+-----+----------+------+

| uer | password | age  |

+-----+----------+------+

| asd | qwe      | 24   |

+-----+----------+------+

MariaDB [asd]> ALTER TABLE UTAB ADD class varchar(8) AFTER password ;            添加一个字段在password后

Query OK, 1 row affected (0.03 sec)

Records: 1  Duplicates: 0  Warnings: 0

MariaDB [asd]> UPDATE UTAB SET  ;                                                class附值

Query OK, 1 row affected (0.00 sec)

Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [asd]> SELECT * FROM UTAB;

+-----+----------+-------+------+

| uer | password | class | age  |

+-----+----------+-------+------+

| asd | qwe      | 1     | 24   |

+-----+----------+-------+------+

MariaDB [asd]> UPDATE UTAB SET  WHERE uer=‘asd‘;                            class值的修改

Query OK, 1 row affected (0.01 sec)

Rows matched: 1  Changed: 1  Warnings: 0

MariaDB [asd]> SELECT * FROM UTAB;

+-----+----------+-------+------+

| uer | password | class | age  |

+-----+----------+-------+------+

| asd | qwe      | 3     | 24   |

+-----+----------+-------+------+

MariaDB [asd]> INSERT INTO UTAB VALUES (‘asd‘,‘qwe‘,‘24‘);

ERROR 1136 (21S01): Column count doesn‘t match value count at row 1

MariaDB [asd]> INSERT INTO UTAB VALUES (‘gou‘,‘qwe‘,‘‘,‘24‘);

Query OK, 1 row affected (0.01 sec)

MariaDB [asd]> SELECT * FROM UTAB;

+-----+----------+-------+------+

| uer | password | class | age  |

+-----+----------+-------+------+

| asd | qwe      | 3     | 24   |

| gou | qwe      |       | 24   |

+-----+----------+-------+------+

MariaDB [asd]> DELETE FROM UTAB uer=‘gou‘;                                        删除某一列

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘uer=‘gou‘‘ at line 1

MariaDB [asd]> DELETE FROM UTAB WHERE  uer=‘gou‘;

Query OK, 1 row affected (0.01 sec)

MariaDB [asd]> SELECT * FROM UTAB;

+-----+----------+-------+------+

| uer | password | class | age  |

+-----+----------+-------+------+

| asd | qwe      | 3     | 24   |

+-----+----------+-------+------+

MariaDB [asd]> DROP TABLE UTAB                                                删除表

-> ;

Query OK, 0 rows affected (0.00 sec)

MariaDB [asd]> SELECT * FROM UTAB;

ERROR 1146 (42S02): Table ‘asd.UTAB‘ doesn‘t exist

MariaDB [asd]> DROP DATABASE asd;                                                    删除库

Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> SELECT * FROM UTAB;

ERROR 1046 (3D000): No database selected

MariaDB [(none)]> SHOW DATABASES

-> ;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

+--------------------+

3 rows in set (0.00 sec)

数据库 用户的权限和访问

MariaDB [(none)]> CREATE USER [email protected] identified by ‘westos‘;

Query OK, 0 rows affected (0.00 sec)         创建用户we,密码为westos,仅可本地登陆([email protected]‘%‘可远程登陆)

MariaDB [(none)]> GRANT CREATE ON *.* TO [email protected] ;

Query OK, 0 rows affected (0.00 sec)                授权可以在任意库的任意表中创建

MariaDB [(none)]> SHOW GRANTS FOR [email protected] ;        权限显示

+------------------------------------------------------------------------------------------------------------+

| Grants for [email protected]                                                                                    |

+------------------------------------------------------------------------------------------------------------+

| GRANT CREATE ON *.* TO ‘we‘@‘localhost‘ IDENTIFIED BY PASSWORD ‘*28C1E2BE21B45562A34B6CC34A19CFAFC2F88F96‘ |

+------------------------------------------------------------------------------------------------------------+

1 row in set (0.00 sec)

MariaDB [(none)]> GRANT INSERT ON *.* to [email protected] ;

Query OK, 0 rows affected (0.00 sec)                可以在任意库的任意表中插入

MariaDB [(none)]> SHOW GRANTS FOR [email protected] ;        权限查看

+--------------------------------------------------------------------------------------------------------------------+

| Grants for [email protected]                                                                                            |

+--------------------------------------------------------------------------------------------------------------------+

| GRANT INSERT, CREATE ON *.* TO ‘we‘@‘localhost‘ IDENTIFIED BY PASSWORD ‘*28C1E2BE21B45562A34B6CC34A19CFAFC2F88F96‘ |

+--------------------------------------------------------------------------------------------------------------------+

1 row in set (0.00 sec)

FLUSH PRIVILEGES  ;                                                    重载授权表

MariaDB [(none)]> REVOKE CREATE on *.* from [email protected] ;

Query OK, 0 rows affected (0.00 sec)                                撤销用户创建权限

MariaDB [(none)]> DROP USER [email protected] ;                                删除用户

Query OK, 0 rows affected (0.00 sec)

数据库密码

当忘记密码:

systemctl stop mariadb.service                                     停止服务

mysqld_safe --skip-grant-tables &                                开启安全模式

[[email protected] ~]# fg

mysqld_safe --skip-grant-tables

^Z

[1]+  Stopped                 mysqld_safe --skip-grant-tables

mysql -u root                                                        进入数据库

MariaDB [(none)]> UPDATE mysql.user set Password=‘redhat‘ WHERE User=‘root‘ ;        更新密码(明文)

Query OK, 3 rows affected (0.00 sec)

Rows matched: 3  Changed: 3  Warnings: 0

| localhost | root | redhat   | Y           | Y           | Y           | Y

MariaDB [(none)]> UPDATE mysql.user set Password=password(‘redhat‘) WHERE User=‘root‘ ; 更新密码(加密)

Query OK, 3 rows affected (0.00 sec)

Rows matched: 3  Changed: 3  Warnings: 0

| localhost | root | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 | Y           | Y

[[email protected] ~]# fg                                                            查看后台

mysqld_safe --skip-grant-tables

^Z

[1]+  Stopped                 mysqld_safe --skip-grant-tables

[[email protected] ~]# killall -9 mysqld_safe                                    关闭后台进程

[1]+  Killed                  mysqld_safe --skip-grant-tables

[[email protected] ~]# ps aux | grep mysql                                                        查看进程

mysql     3196  0.0  4.8 859060 91736 pts/0    Sl   20:52   0:00 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --skip-grant-tables --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/mariadb.pid --socket=/var/lib/mysql/mysql.sock

root      3416  0.0  0.0 112640   940 pts/0    R+   20:58   0:00 grep --color=auto mysql

[[email protected] ~]# kill -9 3196                                                        关闭

systemctl start mariadb                                            开启服务(可以正常登陆)

修改密码:

mysqladmin -uroot -predhat password westos

数据库的备份和恢复

MariaDB [(none)]> CREATE DATABASE westos ;

MariaDB [westos]> CREATE TABLE UTAB (user varchar(10)not null, password varchar(10)not null, class varchar(5) );

MariaDB [westos]> INSERT INTO UTAB VALUES (‘asd‘,‘123‘,‘4‘);

Query OK, 1 row affected (0.01 sec)

MariaDB [westos]> INSERT INTO UTAB VALUES (‘lee‘,‘123‘,‘‘);

Query OK, 1 row affected (0.01 sec)

MariaDB [westos]> SELECT * FROM UTAB;

+------+----------+-------+

| user | password | class |

+------+----------+-------+

| asd  | 123      | 4     |

| lee  | 123      |       |

+------+----------+-------+

(创建一个实验用的数据库)

[[email protected] ~]# mysqldump -uroot -pwestos westos > /mnt/westos.sql                备份数据库

-- MySQL dump 10.14  Distrib 5.5.35-MariaDB, for Linux (x86_64)

--

-- Host: localhost    Database: westos

-- ------------------------------------------------------

-- Server version5.5.35-MariaDB

/*!40101 SET @[email protected]@CHARACTER_SET_CLIENT */;

/*!40101 SET @[email protected]@CHARACTER_SET_RESULTS */;

/*!40101 SET @[email protected]@COLLATION_CONNECTION */;

/*!40101 SET NAMES utf8 */;

/*!40103 SET @[email protected]@TIME_ZONE */;

/*!40103 SET TIME_ZONE=‘+00:00‘ */;

/*!40014 SET @[email protected]@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;

/*!40014 SET @[email protected]@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;

/*!40101 SET @[email protected]@SQL_MODE, SQL_MODE=‘NO_AUTO_VALUE_ON_ZERO‘ */;

/*!40111 SET @[email protected]@SQL_NOTES, SQL_NOTES=0 */;

--

-- Table structure for table `UTAB`

--

DROP TABLE IF EXISTS `UTAB`;

/*!40101 SET @saved_cs_client     = @@character_set_client */;

/*!40101 SET character_set_client = utf8 */;

CREATE TABLE `UTAB` (

`user` varchar(10) NOT NULL,

`password` varchar(10) NOT NULL,

`class` varchar(5) DEFAULT NULL

) ENGINE=InnoDB DEFAULT CHARSET=latin1;

/*!40101 SET character_set_client = @saved_cs_client */;

--

-- Dumping data for table `UTAB`

--

LOCK TABLES `UTAB` WRITE;

/*!40000 ALTER TABLE `UTAB` DISABLE KEYS */;

INSERT INTO `UTAB` VALUES (‘asd‘,‘123‘,‘4‘),(‘lee‘,‘123‘,‘‘);

/*!40000 ALTER TABLE `UTAB` ENABLE KEYS */;

UNLOCK TABLES;

/*!40103 SET [email protected]_TIME_ZONE */;

/*!40101 SET [email protected]_SQL_MODE */;

/*!40014 SET [email protected]_FOREIGN_KEY_CHECKS */;

/*!40014 SET [email protected]_UNIQUE_CHECKS */;

/*!40101 SET [email protected]_CHARACTER_SET_CLIENT */;

/*!40101 SET [email protected]_CHARACTER_SET_RESULTS */;

/*!40101 SET [email protected]_COLLATION_CONNECTION */;

/*!40111 SET [email protected]_SQL_NOTES */;

-- Dump completed on 2016-11-26 21:26:37

mysqldump -uroot -pwestos westos --no-data                 只备份表格不备份其中数据

mysqldump -uroot -pwestos westos --all-database                备份全部

mysql -uroot -pwestos -e "SHOW DATABASES;"

mysql -uroot -pwestos -e "DROP westos;"                        删除原有库(非交互)

mysql -uroot -pwestos -e "DROP DATABASE westos;"

mysql -uroot -pwestos -e "SHOW DATABASES;"

mysql -uroot -pwestos -e "CREATE DATABASE westos;"

mysql -uroot -pwestos westos < /mnt/westos.sql                恢复数据库

[[email protected] ~]# mysql -uroot -pwestos -e "SELECT * FROM westos.UTAB;"

+------+----------+-------+

| user | password | class |

+------+----------+-------+

| asd  | 123      | 4     |

| lee  | 123      |       |

+------+----------+-------+

图形管理数据库

yum install httpd -y                                        安装服务

lftp 172.25.254.250                                下载 phpMyAdmin-3.4.0-all-languages.tar.bz2

tar -jxf phpMyAdmin-3.4.0-all-languages.tar.bz2                 解压

yum install php php-mysql -y                                    安装php

cd myadmin/

cp -p config.sample.inc.php  config.inc.php                    复制配置和i文件模版

vim config.inc.php                                        修改配置文件

17 $cfg[‘blowfish_secret‘] = ‘westos‘; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */

systemctl restart httpd                                        重启服务

邮件服务(smtp协议)

配置基础dns邮件服务

『结果』

(主机)

[[email protected] ~]# dig  -t mx westos.com

; <<>> DiG 9.9.4-RedHat-9.9.4-14.el7 <<>> -t mx westos.com

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 22032

;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2

;; OPT PSEUDOSECTION:

; EDNS: version: 0, flags:; udp: 4096

;; QUESTION SECTION:

;westos.com.INMX

;; ANSWER SECTION:

westos.com.86400INMX1 172.25.254.225.

;; AUTHORITY SECTION:

westos.com.86400INNSdns.westos.com.

;; ADDITIONAL SECTION:

dns.westos.com.86400INA172.25.254.125

(从机)

[[email protected] ~]# dig  -t mx linux.com

; <<>> DiG 9.9.4-RedHat-9.9.4-14.el7 <<>> -t mx linux.com

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 42394

;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2

;; OPT PSEUDOSECTION:

; EDNS: version: 0, flags:; udp: 4096

;; QUESTION SECTION:

;linux.com.INMX

;; ANSWER SECTION:

linux.com.86400INMX1 172.25.254.125.

;; AUTHORITY SECTION:

linux.com.86400INNSdns.linux.com.

;; ADDITIONAL SECTION:

dns.linux.com.86400INA172.25.254.125

邮件通信(smtp)

主机:

vim /etc/postfix/main.cf                     修改postfix配置文件

75 myhostname = linux.com                    主机名称

83 mydomain = linux.com                        域名

99 myorigin = $mydomain                        邮件后缀

113 inet_interfaces = all                        开启所有网络端口

116 #inet_interfaces = localhost

164 mydestination = $myhostname, $mydomain, localhost            接受邮件类型

systemctl restart postfix.service                 重启服务

scp /etc/postfix/main.cf [email protected]:/etc/postfix/main.cf        向从机发送模版

从机:

vim /etc/postfix/main.cf                        修改postfix配置文件

75 myhostname = westos.com                      主机名称

83 mydomain = westos.com                        域名

99 myorigin = $mydomain                        邮件后缀

113 inet_interfaces = all                       开启所有网络端口

116 #inet_interfaces = localhost

164 mydestination = $myhostname, $mydomain, localhost   接受那些目的地过来的邮件

systemctl restart postfix.service               重启服务

『测试结果』

从机向主机

[[email protected] ~]# mail [email protected]

Subject: asd

asd

asdqwe.

.

EOT

[[email protected] ~]# mailq

Mail queue is empty

主机

[[email protected] named]# mailq

Mail queue is empty

You have mail in /var/spool/mail/root

[[email protected] named]# mail

Heirloom Mail version 12.5 7/5/10.  Type ? for help.

"/var/spool/mail/root": 1 message 1 new

>N  1 root                  Sun Nov 27 01:56  22/700   "asd"

& 1

Message  1:

From [email protected]  Sun Nov 27 01:56:18 2016

Return-Path: <[email protected]>

X-Original-To: [email protected]

Delivered-To: [email protected]

Date: Sun, 27 Nov 2016 01:56:17 -0500

To: [email protected]

Subject: asd

User-Agent: Heirloom mailx 12.5 7/5/10

Content-Type: text/plain; charset=us-ascii

From: [email protected] (root)

Status: R

asd

asdqwe.

mailq         查看邮件信息

postsuper -d 4B9DE17E849                删除滞留邮件(4E..为邮件编号)

postsqueue -f            刷新滞留邮件

邮件别名

vim /etc/aliases

# Person who should get root‘s mail

#root:          marc

qqq:            root                                        root的别名为qqq

more:           :include:/etc/moreusers                    多方用户

vim /etc/moreusers                                          配置多方用户

root

student                                                    (包含的用户)

postalias /etc/aliases                                    重新读取/etc/aliases文件

systemctl restart postfix.service                            重启服务

『测试结果』

[[email protected] ~]# mail [email protected]                向root的别名发送邮件(可接受)

Subject: 123

qweasd

.

EOT

[[email protected] ~]# mail [email protected]                向多方发送邮件(root,student都可接受)

Subject: 234

aaqwe

.

EOT

postconf -e "inet_interface=localhost"                修改/etc/postfix/main.cf 文件

postconf -d                                             查找/etc/postfix/main.cf中的信息

postconf -n                                            列出/etc/postfix/main.cf中所有参数

邮件的匿名

从机

cd /etc/postfix

vim generic                                             修改匿名文件

[email protected]     [email protected]                             (最后一行 前为真实邮件地址;后为假的)

postmap generic                                                加密文件

postconf -e "smtp_generic_maps = hash:/etc/postfix/generic"            将文件写如配置文件参数

systemctl restart postfix.service                                            重启服务

『测试结果』

从机:

[[email protected] postfix]# mail [email protected]                        发送邮件

Subject: 456

asd

asd

.

EOT

主机:

[[email protected] ~]# mail

Heirloom Mail version 12.5 7/5/10.  Type ? for help.

"/var/spool/mail/root": 1 message 1 new

>N  1 root                  Sun Nov 27 03:38  22/681   "456"

& 1

Message  1:

From [email protected]  Sun Nov 27 03:38:52 2016                            发送方变为匿名

Return-Path: <[email protected]>

X-Original-To: [email protected]

Delivered-To: [email protected]

Date: Sun, 27 Nov 2016 03:38:52 -0500

To: [email protected]

Subject: 456

User-Agent: Heirloom mailx 12.5 7/5/10

Content-Type: text/plain; charset=us-ascii

From: [email protected] (root)

Status: R

asd

asd

远程检测25端口

[[email protected] postfix]# telnet 172.25.254.125 25                        链接25端口

Trying 172.25.254.125...

Connected to 172.25.254.125.

Escape character is ‘^]‘.

220 linux.com ESMTP Postfix

ehlo hello                                                                    检测

250-linux.com

250-PIPELINING

250-SIZE 10240000

250-VRFY

250-ETRN

250-ENHANCEDSTATUSCODES

250-8BITMIME

250 DSN

mail from:[email protected]                                                     邮件来自

250 2.1.0 Ok

rcpt to:[email protected]                                                        发送去

250 2.1.5 Ok

data                                                                            内容

354 End data with <CR><LF>.<CR><LF>

asd

asdw

.

250 2.0.0 Ok: queued as D8C7C17E84F

quit                        退出

时间: 2024-10-26 10:56:11

linux笔记13的相关文章

Unix &amp; Linux笔记(13)

第22章 vi文本编辑器 22.1 vi重要的原因 kedit gedit Pico Nano POSIX / Single Unix Specification 22.2 vi历史简介 ed em en ex vi 22.3 Vim:vi的备用编辑器 22.4 启动vi ^G 显示文件名称 22.5 启动Vim:vim vim -C [ -rR ] [ file- ] -C compatibility mode 22.6 命令模式和输入模式 编辑缓冲区 editing buffer Ctrl

python 学习笔记 13 -- 常用的时间模块之time

Python 没有包含对应日期和时间的内置类型,不过提供了3个相应的模块,可以采用多种表示管理日期和时间值: *    time 模块由底层C库提供与时间相关的函数.它包含一些函数用于获取时钟时间和处理器的运行时间,还提供了基本解析和字符串格式化工具 *    datetime 模块为日期.时间以及日期时间值提供一个更高层接口.datetime 中的类支持算术.比较和时区配置. *    calendar 模块可以创建周.月和年的格式化表示.它还可以用来计算重复事件.给定日期是星期几,以及其他基

Linux笔记之Makefile

规则: 目标 : 依赖 命令 make是如何工作的: (1)make在当前目录下寻找makefile或Makefile. (2)如果找到,他会寻找文件中的第一个目标文件(target),并把这个文件作为第一个目标. (3)如果目标文件不存在,或者目标文件所依赖的.o文件修改时间要比目标文件新,那么,就会执行后面所定义的命令来生成目标文件. (4)如果目标文件所以依赖的.o文件也存在,那么make会在当前文件中寻找目标为.o文件所依赖性,如果找到则再根据这一规则生成.o文件.(这有些像堆栈的过程.

HTML&CSS基础学习笔记13—无序列表

无序列表 有时我们的工作繁忙,杂事很多,怕忘记,就会把事情一件件列出来,防止忘记. 它们的排列顺序对于我们来说并不重要,可以随意调换,我们将它称为无序列表,HTML里用<ul>标签来表示无序列表,列表里的项目则用<li>标签来表示: 1 2 3 4 5 <ul>     <li></li>     <li></li>     ... </ul> 看一段实例代码: 对于的浏览器显示结果是这样的: 更多内容学习,请

linux笔记 文件的压缩与解压缩gzip、bzip2、xz、zip&unzip、tar打包、tar打包和压缩并用

压缩文件意义节省网络传输带宽,降低磁盘使用率.但会使用一定的cpu. 1.gzip 不支持压缩目录,gzip后直接跟文件名,在当前目录下压缩时,原文件会消失. #gzip filename 指定压缩目录:#gzip -c 123.txt > /tmp/123.txt.gz 将当前目录下123.txt文件压缩到tmp目录下名字为123.txt.gz 解压缩:#gzip -d file.gz #zcat file.gz  查看.gz文件内容 2.bzip2 不支持压缩目录,bzip2后可直接跟文件名

辛星整理的三本linux笔记,免积分下载,希望对您有所帮助

废话不多说了,第一本是我在看李明老师的视频的时候的笔记,全书大约116页,在csdn上的下载地址为:点我下载 ,如果左边的地址崩溃了,也可以在浏览器中输入如下地址然后下载:http://download.csdn.net/detail/xinguimeng/7757985   在百度网盘上的下载地址为:点我去百度网盘,如果左边的地址跪了,也可以在浏览器中输入如下下载地址进行下载:http://pan.baidu.com/s/1pJBdc8N  . 第二本是我在看韩顺平老师讲linux的时候的笔记

Linux(Ubuntu 13.04)环境下 Eclipse perl插件EPIC的安装

? 1 2 3 4 5 6 7 8 9 10 11 12 13 14     这几天要学习perl,打算用eclipse这个IDE,那么装一个perl的插件是很有必要; 网上搜了下,安装EPIC大家提到最多的就是输入http://e-p-i-c.sf.net/updates/testing,但是我遇到的情况是一直在pending,令人抓狂: 后来参照Pydev的插件安装方法,试了下,成功了,下面就是我的步骤 我的系统:Ubuntu13.04 安装步骤: 1:到这里下载插件:http://pan.

linux笔记之grep使用

1.问:grep.egrep是什么? 答:grep是文本搜索工具,grep是根据用户指定的'模式(pattern)'对目标文本进行过滤,显示被模式匹配到的行. 2.问:grep.egrep中用户指定的'模式(pattern)'是什么?分为几类? 答:grep中用户指定的'模式'是一种由特殊字符组成的具有某种特定意义的表达式,我们称为正则表达式,其中的特殊字符我们称为元字符.正则表达式分为:基本正则表达式.扩展正则表达式. 3.问:grep.egrep的使用格式是怎么书写的? 答:grep的使用格

【Linux笔记】cd无法进入xargs管道输出的目录

今天在写shell脚本的时候,想用cd进入xargs管道输出的目录,但是提示报错.详情如下: [环境描述] 目录结构: [[email protected] nagiosclient_db]# ls -ltr total 2488 -rw-r--r--.        1     root   root    405725   Mar  3 14:12   nrpe-2.12.tar.gz -rw-r--r--.        1     root   root    2095419 Mar