返回顶部
首页 > 资讯 > 操作系统 >linux笔记13
  • 580
分享到

linux笔记13

2024-04-02 19:04:59 580人浏览 泡泡鱼
摘要

主从DNS同步当单一DNS无法满足客户需求是开启一个同步的次级DNS,他们dns的内容一致。主机: vim /etc/named.rfc1912.zones zone "asd.com" IN {

主从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                        重启服务

 

(检测结果)

[root@localhost ~]# 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.* root@172.25.254.225:/mnt        远程发送密码给用户以更新dnsderen

 

systemctl restart named                                    重启服务

 

发送端:

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

> server 172.25.254.125

> update delete www.asd.com                                    删除

> send

> quit退出

 

『测试结果』

root@localhost named]# ls

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

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

 

root@localhost 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                                                    重启服务

 

[root@localhost 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 we@localhost identified by 'westos';

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

 

MariaDB [(none)]> GRANT CREATE ON *.* TO we@localhost ;

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

MariaDB [(none)]> SHOW GRANTS FOR we@localhost ;        权限显示

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

| Grants for we@localhost                                                                                    |

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

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

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

1 row in set (0.00 sec)

 

MariaDB [(none)]> GRANT INSERT ON *.* to we@localhost ;

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

 

MariaDB [(none)]> SHOW GRANTS FOR we@localhost ;        权限查看

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

| Grants for we@localhost                                                                                            |

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

| 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 we@localhost ;

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

 

MariaDB [(none)]> DROP USER we@localhost ;                                删除用户

Query OK, 0 rows affected (0.00 sec)

 

数据库密码

当忘记密码:

systemctl stop mariadb.service                                     停止服务

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

[root@localhost ~]# 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

 

[root@localhost ~]# fg                                                            查看后台

mysqld_safe --skip-grant-tables

^Z       

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

[root@localhost ~]# killall -9 mysqld_safe                                    关闭后台进程

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

[root@localhost ~]# 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

[root@localhost ~]# 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      |       |

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

 

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

 

[root@localhost ~]# 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

 

;

;

;

;

;

;

;

;

;

;

 

--

-- Table structure for table `UTAB`

--

 

DROP TABLE IF EXISTS `UTAB`;

;

;

CREATE TABLE `UTAB` (

  `user` varchar(10) NOT NULL,

  `password` varchar(10) NOT NULL,

  `class` varchar(5) DEFAULT NULL

) ENGINE=InnoDB DEFAULT CHARSET=latin1;

;

 

--

-- Dumping data for table `UTAB`

--

 

LOCK TABLES `UTAB` WRITE;

;

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

;

UNLOCK TABLES;

;

 

;

;

;

;

;

;

;

 

-- 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                恢复数据库

[root@localhost ~]# 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';

 

systemctl restart httpd                                        重启服务

 

linux笔记13

linux笔记13

linux笔记13

linux笔记13

linux笔记13


 

 

 

 

 

 

 

 

邮件服务(smtp协议)

配置基础dns邮件服务

『结果』

(主机)

[root@localhost ~]# 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

 

(从机)

[root@localhost ~]# 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 root@172.25.254.225:/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               重启服务

 

『测试结果』

从机向主机

[root@localhost ~]# mail root@linux.com

Subject: asd

asd

asdqwe.

.

EOT

[root@localhost ~]# mailq

Mail queue is empty

主机

[root@localhost named]# mailq

Mail queue is empty

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

[root@localhost 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 root@westos.com  Sun Nov 27 01:56:18 2016

Return-Path: <root@westos.com>

X-Original-To: root@linux.com

Delivered-To: root@linux.com

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

To: root@linux.com

Subject: asd

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

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

From: root@westos.com (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                            重启服务

 

『测试结果』

[root@localhost ~]# mail qqq@linux.com                向root的别名发送邮件(可接受)

Subject: 123

qweasd

.

EOT

[root@localhost ~]# mail more@linux.com                向多方发送邮件(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                                             修改匿名文件

root@westos.com     123@qq.com                             (最后一行 前为真实邮件地址;后为假的)

postmap generic                                                加密文件

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

systemctl restart postfix.service                                            重启服务

『测试结果』

从机:

[root@localhost postfix]# mail root@linux.com                        发送邮件

Subject: 456

asd

asd

.

EOT

主机:

[root@localhost ~]# 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 123@qq.com  Sun Nov 27 03:38:52 2016                            发送方变为匿名

Return-Path: <123@qq.com>

X-Original-To: root@linux.com

Delivered-To: root@linux.com

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

To: root@linux.com

Subject: 456

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

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

From: 123@qq.com (root)

Status: R

 

asd

asd

 

远程检测25端口

[root@localhost 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:root@westos.com                                                     邮件来自

250 2.1.0 Ok

rcpt to:root@linux.com                                                        发送去

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                        退出

 


--结束END--

本文标题: linux笔记13

本文链接: https://lsjlt.com/news/36221.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
  • linux笔记13
    主从DNS同步当单一DNS无法满足客户需求是开启一个同步的次级DNS,他们dns的内容一致。主机: vim /etc/named.rfc1912.zones zone "asd.com" IN {...
    99+
    2024-04-02
  • python学习笔记13-python面
    python学习笔记12-python面向对象python一切皆对象一、基本概念1、面向对象和面向过程面向对象编程:C++,Java,Python面向过程编程:函数式编程,C程序等2、类和对象类:是对事物的抽象,比如:人类,球类对象:是类的...
    99+
    2023-01-31
    学习笔记 python
  • Linux笔记
    一。基础思想 一切皆文件。 两条权限原则: 权限分组原则权限最小原则 su是切换用户,而sudo则是用root权限执行某操作( 普通用户+sudo=安全) Linux目录 系统只存在一颗文件树、从==/==开始,所有的文件都...
    99+
    2023-08-20
    linux 服务器 运维
  • [PYTHON] 核心编程笔记(13.P
    13.1 介绍类与实例:类与实例相互关联,类是对象的定义,而实例是"真正的实物",它存放了类中所定义的对象的具体信息下面的示例展示如何创建一个类:class MyNewObjectType(bases):    'define MyNewO...
    99+
    2023-01-31
    核心 笔记 PYTHON
  • MySQL学习笔记(13):锁和事务
    本文更新于2019-09-22,使用MySQL 5.7,操作系统为Deepin 15.4。 目录锁锁概述MyISAM表级锁InnoDB行级锁InnoDB表级锁死锁事务事务概述InnoDB事务分布式事务 锁 锁概述 MyISAM和M...
    99+
    2015-05-30
    MySQL学习笔记(13):锁和事务
  • docker笔记13-Dockerfile的保留字指令
        Dockerfile是用来构建Docker镜像的构建文件,是由一系列命令和参数构成的脚本。    构建三步骤:1、编写dockerfile文件;2、do...
    99+
    2023-06-04
  • linux入门笔记
    学习linux也不是那么难,首先你就必须掌握这些入门知识,这样才能让你从新手变老手,下面就从几个方面来教你学linux。【1】Linux介绍【2】vi编辑器(1)三种模式:(2)vi命令【1】Linux介绍(1)四个重要的人物肯.汤姆森 B...
    99+
    2023-06-05
  • Linux 学习笔记 二
    压缩解压缩压缩格式:gz bz2 xz zip z 压缩算法,算法不同,压缩比也不同compress: filename.Zuncompress: 不能压缩文件夹,会将文件夹内的文件单个...
    99+
    2024-04-02
  • Linux自学笔记——LNMP
           传统上基于进程或线程模型架构的web服务通过每进程或每线程处理并发请求,这势必会在网络和I/O操作时产生阻塞,其另一个必然结果则是对内存或CPU的利用率...
    99+
    2024-04-02
  • Linux入门笔记3
    一、管理权限和归属1.权限概述文档归属所有者(u):拥有此文件/目录的用户-user所属组(g):拥有此文件/目录的组-group其他用户(o):除所有者、所属组以外的用户-other访问权限读取(r):允许查看内容-read写入(w):允...
    99+
    2023-01-31
    入门 笔记 Linux
  • Linux学习笔记 Day 2~3
    继续整理周末课程的Linux学习笔记。 vim编辑器 最受欢迎的是emacs,vim是vi的增强版本,特点是编辑内容时有颜色变化。命令:vim /etc/passwd 三种模式: 1. 普通模式-->可视模式 2....
    99+
    2023-01-31
    学习笔记 Linux Day
  • 2018-3-14 Linux学习笔记
    Nginx访问日志的格式是在主配置文件中定义的. vim /usr/local/nginx/conf/nginx.conf //搜索log_format 日志字段含义:$remote_addr 客户端IP(公网IP...
    99+
    2023-01-31
    学习笔记 Linux
  • 2018-3-15 Linux学习笔记
    编辑虚拟主机配置文件vim /usr/local/nginx/conf/vhost/test.com.conf 配置如下:location ~* ^.+\.(gif|jpg|png|swf|flv|rar|zip|doc|pdf|gz|...
    99+
    2023-01-31
    学习笔记 Linux
  • 2018-3-29 Linux学习笔记
    Tomcat是Apache软件基金会(Apache Software Foundation)的Jakarta项目中的一个核心项目,由Apache、Sun和其他一些公司及个人共同开发而成。 java程序写的网站用tomcat+jdk来运行...
    99+
    2023-01-31
    学习笔记 Linux
  • 【MongoDB学习笔记13】MongoDB的更新(update)操作进阶
    一、批量更新默认只对符合条件的一条文档更新> db.post.find()    { "_id" : ObjectId("54a5...
    99+
    2024-04-02
  • linux系统命令笔记整理
    本文讲述了linux系统命令。分享给大家供大家参考,具体如下: 一、linux系统目录 /bin         系统命令目录 /d...
    99+
    2022-06-03
    linux 系统命令
  • linux shell编程学习笔记(3)
    1、什么是变量保存变化的数据——变量名:名称固定,由系统预设或用户自定义——变量值:根据用户设置、系统环境变化而变化2、如何定义变量——变量名=变量的值2.1变量名的规则(1)数字、字母、下划线(2)字母区分大小写(3)当变量名相同时,后赋...
    99+
    2023-01-31
    学习笔记 linux shell
  • mysql笔记-
    用单表接近一千万数据(四列:int,两个varchar,日期时间)测,发现几个效率几乎一致 count(0)=count(1)=count(数字)=count(*)>count(primary key)>count(column...
    99+
    2021-01-21
    mysql笔记-
  • redis笔记-
    前言 为了避免单点故障,我们需要将数据复制多份部署在多台不同的服务器上,即使有一台服务器出现故障其他服务器依然可以继续提供服务 作用: 数据备份 扩展读性能(读写分离) 复制方式: 全量复制 部分复制   实现方式   1、一主二...
    99+
    2021-09-21
    redis笔记-
  • Redis 笔记
    Redis常用管理命令 # dbsize 返回当前数据库 key 的数量。 # info 返回当前 redis 服务器状态和一些统计信息。 # monitor 实时监听并返回redis服务器接收到的所有请求信息。 # shutd...
    99+
    2020-04-14
    Redis 笔记
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作