所有由ts发布的文章

postfix疯狂外发垃圾邮件之分析与解决

本周二上班有人反应公司邮箱无法外发邮件,后来登录到服务器查看原因,不看不知道,一看吓一跳,服务器日志疯狂滚动!一看全是被其它邮件服务器拒绝的信息!由于这台服务器以前不是我管,连配置文件都find了好久,最终从十多个main.cf中找到了真正的配置文件……

下面开始分析问题与解决问题!

分析

localhost# find / -name main.cf

…….

/usr/local/etc/postfix/main.cf

/usr/opt/software/postfix-2.8.9/conf/main.cf

/etc/postfix/main.cf

这么多配置文件也不知道具体是哪个,但根据常理,最有可能的便是/etc/postfix/main.cf了。

打开/etc/postfix/main.cf来看看。

localhost# cat /etc/postfix/main.cf | grep -v # | grep -v ^$

queue_directory = /var/spool/postfix

command_directory = /usr/sbin

daemon_directory = /usr/libexec/postfix

data_directory = /var/lib/postfix

mail_owner = postfix

myhostname = mail.example.com

mydomain = example.com

myorigin = $mydomain

unknown_local_recipient_reject_code = 550

debug_peer_level = 2

debugger_command =

         PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin

         ddd $daemon_directory/$process_name $process_id & sleep 5

sendmail_path = /usr/sbin/sendmail

newaliases_path = /usr/bin/newaliases

mailq_path = /usr/bin/mailq

setgid_group = maildrop 

html_directory = no

manpage_directory = /usr/local/man

sample_directory = /etc/postfix

message_size_limit = 512000000

virtual_mailbox_limit = 1024000000

readme_directory = /usr/local/share/doc/postfix

virtual_mailbox_base = /usr/opt/home/domains

virtual_uid_maps = static:1000

virtual_gid_maps = static:1000

virtual_alias_maps = $alias_maps, mysql:/etc/postfix/mysql_virtual_alias_maps.cf

virtual_mailbox_maps = mysql:/etc/postfix/mysql_virtual_mailbox_maps.cf

virtual_mailbox_domains = mysql:/etc/postfix/mysql_virtual_domains_maps.cf

smtpd_sasl_auth_enable = yes

broken_sasl_auth_clients = yes

smtpd_sasl_local_domain = $myhostname

smtpd_sasl_security_options = noanonymous

smtpd_recipient_restrictions =

        permit_mynetworks, 

        permit_sasl_authenticated,

        reject_unauth_destination,

dspam_destination_recipient_limit = 1

mydestination =

smtpd_sender_restrictions = check_sender_access hash:/etc/postfix/sender_access

smtpd_client_restrictions = 

        reject_rbl_client cblless.anti-spam.org.cn,

        reject_rbl_client cdl.anti-spam.org.cn,

        reject_rbl_client opm.blitzed.org,

        reject_rbl_client bl.spamcop.net

localhost# vi /etc/postfix/sender_access

carr.chee@aol.com        REJECT

Henry.bny5@hotmail.com   REJECT

pmck.hsr69@yahoo.com     REJECT

……..

由以上配置文件可以看到,我们对发信者的检测仅限于sender_access。仅仅只是拒绝了sender_access中拒绝的用户。而没有其它任何限制。限制条件很宽松。

截取部分日志分析

localhost# tail /var/log/maillog

Oct 22 16:36:01 localhost postfix/error[18675]: 42263221CA: to=<altoact@verizon.net>, relay=none, delay=111421, delays=105070/6348/0/2.6, dsn=4.0.0, status=deferred (delivery temporarily suspended: host relay.verizon.net[206.46.232.11] refused to talk to me: 571 Email from 124.172.224.76 is currently blocked by Verizon Online’s anti-spam system. The email sender or Email Service Provider may visit http://www.verizon.net/whitelist and request removal of the block. 121022)

Oct 22 16:36:01 localhost postfix/qmgr[32357]: 184F627BF64: from=<lindawatts338@yahoo.com.hk>, size=2338, nrcpt=50 (queue active)

Oct 22 16:36:01 localhost postfix/smtp[18300]: 1C34F26235C: to=<andrew.rawson@honeywell.com>, relay=mail2.honeywell.com[199.61.24.28]:25, delay=110287, delays=110274/11/2.4/0, dsn=4.0.0, status=deferred (host mail2.honeywell.com[199.61.24.28] refused to talk to me: 554 mail2.honeywell.com)

Oct 22 16:36:01 localhost postfix/smtp[18288]: connect to news-daily.com.inbound15.mxlogicmx.net[208.65.144.12]:25: Connection refused

发现全是一些被defferred的信息。其它邮件服务器已经拒绝我们投递。

那么再用mailq命令来查看一下队列文件。

结果发现mailq刷屏刷得没完没了了。太多缓存的邮件!

localhost#  mailq 

-Queue ID- –Size– —-Arrival Time—- -Sender/Recipient——-

5D1477C0D*     2333 Mon Oct 22 18:36:47  jrobert299@yahoo.com.hk

(delivery temporarily suspended: host mx.west.cox.net[68.6.19.3] refused to talk to me: 554 fed1rmimpi210 cox 124.172.224.76 blocked.  Error Code: IPBL0100 – Refer to Error Codes section at http://postmaster.cox.net/confluence/display/postmaster/Error+Codes for more information.)

                                         n_jhenderson@cox.net

截取其中一个例子来分析,可分为五部分来看。

1,5D1477C0D* 是指缓存邮件的ID

2,2333 是指邮件的大小。

3,jrobert299@yahoo.com.hk 是指发件人。

4,(delivery temporarily suspended: host mx.west.cox.net[68.6.19.3] refused to talk to me: 554 fed1rmimpi210 cox 124.172.224.76 blocked.  Error Code: IPBL0100 – Refer to Error Codes section at http://postmaster.cox.net/confluence/display/postmaster/Error+Codes for more information.)

通过第4段信息我们可以得到如下信息:

delivery temporarily suspended告诉我们邮件投递被延迟。

host mx.west.cox.net[68.6.19.3] refused to talk to me 告诉我们投递给mx.west.cox.net[68.6.19.3] 的邮件服务器拒收我们的信件。

124.172.224.76 我们邮件服务器的Ip地址。

Error Code: IPBL0100 – Refer to Error Codes section at http://postmaster.cox.net/confluence/display/postmaster/Error+Codes for more information.)

通过http://postmaster.cox.net/confluence/display/postmaster/Error+Codes 上查看更多拒收的原因。

5,n_jhenderson@cox.net 收件人地址!

由上面的日志我们可以知道

1,我们的邮件服务器的发件人地址被伪造了!

2,我们邮件服务器已经被很多其它邮件服务器列入了黑名单

3,收件人并非我们认识的人

结论,这个邮件服务器很可能被入侵,且被当作垃圾邮件的中继者。

那么,谁会是这个入侵者呢?倒底是什么漏洞导致的?

下面来让找到事件的源头。

首先,根据上面的分析,我们知道发件人和收件人都不是邮件服务器所在域的成员。那么我们就得考虑我们的邮件服务器是不是一个开放的中继(open relay)。

验证:

[root@mail ~]# telnet mail.example.com 25

Trying 124.172.224.76…

Connected to mail.example.com (124.172.224.76).

Escape character is ‘^]’.

220 mail.example.com ESMTP Postfix

helo aa@bb.com

250 mail.example.com

mail from:aa@bb.com

250 2.1.0 Ok

rcpt to:445335413@qq.com

554 5.7.1 <445335413@qq.com>: Relay access denied

可以看到,我们不经过认证发送邮件给qq邮箱并没有成功。所以,这并不是一个open relay的服务器!既然如此,那别人想用我的邮件服务器外发邮件,那么就必需要通过认证才可以。那么让我们用认证的方式登录并偿试伪造发信人地址外发邮件!

先将用户名和密码经过base64编码。

[root@mail ~]# perl -MMIME::Base64 -e “print encode_base64(‘123456’);”         

MTIzNDU2

[root@mail ~]# perl -MMIME::Base64 -e “print encode_base64(‘test1@example.com’);”

dGVzdDFAZXhhbXBsZS5jb20=

验证:

[root@mail ~]# telnet mail.example.com 25

Trying 124.172.224.76…

Connected to mail.example.com (124.172.224.76).

Escape character is ‘^]’.

220 mail.example.com ESMTP Postfix

auth login

334 VXNlcm5hbWU6

dGVzdDFAZXhhbXBsZS5jb20=

334 UGFzc3dvcmQ6

MTIzNDU2

235 2.7.0 Authentication successful

mail from:test@yahoo.com

250 2.1.0 Ok

rcpt to:445335413@qq.com

250 2.1.5 Ok

data

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

hello inveracious test!

.

250 2.0.0 Ok: queued as 99F4C23F008

quit

221 2.0.0 Bye

Connection closed by foreign host.

上面我用认证用户test1@example.com登录后,伪造成test@yahoo.com来发信。结果显示成功!我们再回到服务器端看看有什么日志产生!

localhost# tail /var/log/maillog

Oct 26 02:54:27 localhost postfix/qmgr[40723]: 99F4C23F008: from=<test@yahoo.com>, size=197, nrcpt=1 (queue active)

Oct 26 02:54:27 localhost postfix/smtp[41094]: 99F4C23F008: to=<445335413@qq.com>, relay=mx3.qq.com[119.147.192.199]:25, delay=110, delays=109/0/0.04/0.1, dsn=5.0.0, status=bounced (host mx3.qq.com[119.147.192.199] said: 550 Mail content denied. http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=20022&&no=1000726 (in reply to end of DATA command))

Oct 26 02:54:27 localhost postfix/cleanup[41089]: 69EA423F027: message-id=<20121025185427.69EA423F027@mail.example.com>

Oct 26 02:54:27 localhost postfix/bounce[41095]: 99F4C23F008: sender non-delivery notification: 69EA423F027

Oct 26 02:54:27 localhost postfix/qmgr[40723]: 69EA423F027: from=<>, size=2203, nrcpt=1 (queue active)

Oct 26 02:54:27 localhost postfix/qmgr[40723]: 99F4C23F008: removed

日志显示邮件ID为99F4C23F008的邮件,发件人是test@yahoo.com。接收服务器是mx3.qq.com的25端口。状态是被退回。通过http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=20022&&no=1000726 可以查看到拒绝原因。

经过认证登录后的用户,可以伪造发件人随意外发邮件!

由以上信息我们可以推断,很可能是由于别人盗用了我们的账号,然后利用我们的账号伪造其它发信人,疯狂外发邮件!那么,我们现在需要从三方面着手。

1,找出真正的发件人是哪个合法用户并马上修改密码。

2,阻止邮件继续疯狂外发。

3,禁止认证用户伪造发件人外发邮件。

解决

 1,找出可能被盗号的用户!

通过maillog虽然看不到被拒绝邮件到底是谁发出的,但可以看到被拒绝投递的邮件ID.就比如下面两封邮件的ID分别为45C4E130CB 4728312BBA。这时候,我们可以查找到一些收信地址比较可疑的邮件来分析。

localhost# tail  /var/log/maillog

Oct 22 16:41:38 localhost postfix/error[18801]: 45C4E130CB: to=<blantonlarry@bellsouth.net>, relay=none, delay=101364, delays=95002/6357/0/5.3, dsn=4.0.0, status=deferred (delivery temporarily suspended: host gateway-f1.isp.att.net[204.127.217.16] refused to talk to me: 550-124.172.224.76 blocked by ldap:ou=rblmx,dc=att,dc=net 550 Error – Blocked for abuse. See http://att.net/blocks)

Oct 22 16:41:38 localhost postfix/error[18103]: 4728312BBA: to=<bhaitov@yahoo.com>, relay=none, delay=102971, delays=96576/6386/0/9.8, dsn=4.7.1, status=deferred (delivery temporarily suspended: host mta5.am0.yahoodns.net[66.94.237.139] refused to talk to me: 421 4.7.1 [TS03] All messages from 124.172.224.76 will be permanently deferred; Retrying will NOT succeed. See http://postmaster.yahoo.com/421-ts03.html)

…..

我们可以通过postcat -q命令来查看指定ID邮件的详细内容。比如我觉得ID为2FDF423FA50的邮件很可疑,那么让我们详细看看邮件:

localhost# postcat -q 2FDF423FA50

*** ENVELOPE RECORDS deferred/2/2FDF423FA50 ***

message_size:            2428            4714              50               0            2428

message_arrival_time: Wed Oct 24 06:18:07 2012

create_time: Wed Oct 24 06:18:08 2012

named_attribute: log_ident=2FDF423FA50

named_attribute: rewrite_context=remote

named_attribute: sasl_method=LOGIN     <—–sasl认证通过

named_attribute: sasl_username=info@example.com   <——-认证用户名

sender: lindawatts101@yahoo.com.hk <—–伪造的发信者

named_attribute: log_client_name=unknown

named_attribute: log_client_address=68.167.29.196  <—-登录客户端的ip

named_attribute: log_client_port=1464

named_attribute: log_message_origin=unknown[68.167.29.196]

named_attribute: log_helo_name=User

named_attribute: log_protocol_name=ESMTP

named_attribute: client_name=unknown

named_attribute: reverse_client_name=h-68-167-29-196.mclnva23.static.covad.net

named_attribute: client_address=68.167.29.196

named_attribute: client_port=1464

named_attribute: helo_name=User

named_attribute: protocol_name=ESMTP

named_attribute: client_address_type=2

named_attribute: dsn_orig_rcpt=rfc822;ajagoodin@yahoo.com

original_recipient: ajagoodin@yahoo.com

recipient: ajagoodin@yahoo.com <——收件人1

named_attribute: dsn_orig_rcpt=rfc822;ajagostinelli@cox.net

original_recipient: ajagostinelli@cox.net <——收件人2

recipient: ajagostinelli@cox.net

named_attribute: dsn_orig_rcpt=rfc822;ajagra2001@yahoo.com

original_recipient: ajagra2001@yahoo.com <——收件人3

recipient: ajagra2001@yahoo.com

………

通过上面的这封邮件,我们可以知道,这封邮件是由info@example.com.这个用户来认证登录的。登录者IP 68.167.29.196。该用户将发信人伪造成:lindawatts101@yahoo.com.hk。并且同时发送很多封邮件出去! 如果真存在lindawatts101@yahoo.com.hk这个用户的话,那这个用户信箱估计也被塞满了无数退信邮件.

很显然,上面这封邮件并不是一封正常邮件!通过这封邮件很快就可以确定这个用户的密码很可能是被别人破解了!或者邮件系统有其它漏洞,入侵者亲自建立了该用户用来群发邮件。

搜索/var/spool/postfix/defrred目录下面的ip 68.167.29.196,发现有5600邮件被阻塞着。而且还在不断增加。且用户均为info@example.com。可以确定,IP 68.167.29.196为入侵者。

       localhost#  cd /var/spool/postfix/defrred

localhost# find . -exec grep “68.167.29.196” {} \; | wc -l

5625

登录数据库查看info@example.com这个用户的创建情况。这个在webman管理后台上面是看不到的。

localhost# /usr/opt/local/mysql-5.1.47/bin/mysql -uextmail -pextmail

mysql> select * from mailbox where  username=’info@example.com’\G;

*************************** 1. row ***************************

        username: info@example.com

             uid: info

        password: $1$RpyMEokE$CK31uufL9uNk6PjqSorXa1

        clearpwd: 

            name: 

        mailhost: 

         maildir: example.com/info/Maildir/

         homedir: example.com/info

           quota: 524288000S

    netdiskquota: 524288000S

          domain: example.com

       uidnumber: 1000

       gidnumber: 1000

      createdate: 2012-04-25 15:35:54    <—–创建日期

      expiredate: 0000-00-00

          active: 1

disablepwdchange: 0

    disablesmtpd: 0

     disablesmtp: 0

  disablewebmail: 0

  disablenetdisk: 0

     disableimap: 1

     disablepop3: 0

        question: 

          answer: 

1 row in set (0.00 sec)

mysql> select * from manager;

+——————+————————————+——-+——+————+————-+———–+——————+———————+————+——–+

| username         | password                           | type  | uid  | name       | question    | answer    | disablepwdchange | createdate          | expiredate | active |

+——————+————————————+——-+——+————+————-+———–+——————+———————+————+——–+

| root@extmail.org | $1$ZwYBBBz1$mh.Uwro5vqXMwYum0eprq/ | admin | root | Super User | my question | my answer |                0 | 2007-02-14 15:10:04 | 2010-11-08 |      1 |

+——————+————————————+——-+——+————+————-+———–+——————+———————+————+——–+

管理员账号只有一个,info@example.com也不是新建的。那应该是Info@example.com的用户密码被破解了。

来看看info@example.com这个用户的登录日志。发现全是由68.167.29.196的主机登录的。

localhost# cat /var/log/maillog | grep info@example.com

Oct 24 00:32:10 localhost postfix/smtpd[4202]: 8F005249014: client=unknown[68.167.29.196], sasl_method=LOGIN, sasl_username=info@example.com

Oct 24 00:32:16 localhost postfix/smtpd[5029]: 11044249024: client=unknown[68.167.29.196], sasl_method=LOGIN, sasl_username=info@example.com

Oct 24 00:32:17 localhost postfix/smtpd[4626]: 930FB249028: client=unknown[68.167.29.196], sasl_method=LOGIN, sasl_username=info@example.com

Oct 24 00:32:17 localhost postfix/smtpd[4765]: A890624902B: client=unknown[68.167.29.196], sasl_method=LOGIN, sasl_username=info@example.com

登录extman,将info@example.com这个用户的密码改掉。

我们登录info@example.com来看看用户情况。结果发现有一万多封退信信息,由于这个账号没人用,所以一直未发现这个问题。

2,清除所有缓存垃圾邮件,阻止邮件服务器继续偿试外发!

清除defer和deferred目录下的缓存邮件

我们来瞧瞧邮件缓存目录

localhost# du -sh /var/spool/postfix/*

2.1G    /var/spool/postfix/defer

2.7G    /var/spool/postfix/deferred

可以看到,被延迟发送的邮件占用了5个g的空间!

清除邮件中的所有队列

localhost# postsuper -d ALL 

postsuper: Deleted: 292551 messages

共清除了将近30万封缓存的邮件。

如果缓存邮件里面有重要邮件,不能删除所有邮件,那么也可以写一个脚本,只清除所有属于68.167.29.196的缓存邮件。

localhost# vi deldefer.sh

#删除defferred中的缓存

cd /var/spool/postfix/deferred/

find . -exec grep 68.167.29.196 {} \; | awk ‘{print $3}’ | cut -d/ -f3 >/tmp/del.txt

for i  in `cat /tmp/del.txt`

        do

        postsuper -d “$i”

        done

rm -rf /tmp/del.txt

#删除deffer中的缓存

cd /var/spool/postfix/defer

for i in `find .|cut -d/ -f3`

        do

        postcat -q $i |grep 68.167.29.196

                if [ $? -eq 0 ];

                then

                echo $i >> /tmp/defer.txt

                postsuper -d $i

                fi

        done

rm -rf /tmp/defer.txt

脚本说明:

在删除deffer和defferred下面的缓存邮件的脚本是不同的。由于defer下的缓存邮件用cat直接查看是看不到发件人及登录ip等详细信息的,需要用postcat来查看才能显示出详细的信息。所以deffer目录里的清除脚本写法和上面defferred的有些不同。注意:在删除了deferred下面的缓存后,如果不删除defer的缓存,defer下的邮件仍然会被不停的投递出去,直到最后变为deferred之后才会放弃。所以,如果只删除deferred下面的邮件而不删除defer下面的邮件的话,过不了多久,deferred下面又会出现大量邮件,而这个邮件是由defer目录下的缓存引起的。

——————————————————-

再次查看缓存目录,容量终于恢复正常值。

localhost# du -sh /var/spool/postfix/*

162K    /var/spool/postfix/defer

 46K    /var/spool/postfix/deferred

删除info@example.com用户邮箱的退信邮件

下面该删除info@example.com用户的所有退信邮件了.通过查看邮件发现所有的垃圾邮件均是今天一天生成的。到服务器端查找并删除今天的所有邮件。

进入到info用户的邮件目录

localhost# cd /usr/opt/home/domains/example.com/info/Maildir/

可以看到有12779封邮件。

localhost# ls -l cur/ |wc -l

   12779

查找今天生成的邮件,共11589封

localhost# find cur/ -ctime -1 | wc -l     

   11589

删除所有今天的邮件

localhost# find cur/ -ctime -1 -exec rm -f {} \;

删除完毕!

注意find cur/ -ctime -1 -exec rm -f {} \; 中是rm -f !不要写成了rm -rf。否则一执行就把cur目录给删掉了。那么用户以前的邮件也全带着一起删除了!

至此,邮件服务器终于恢复了正常运行。再次用tail -f 来查看日志,不会再出现那恐怖的疯狂刷屏日志了!疯狂的服务器终于恢复了原来的悠闲状态!

3,禁止认证用户假冒发信人外发

修改main.cf配置文件,增加发信人限制功能!

localhost# vi main.cf

mynetworks = 127.0.0.0/8

smtpd_sender_restrictions =

        permit_mynetworks,

        reject_sender_login_mismatch,

        reject_non_fqdn_sender, 

        reject_authenticated_sender_login_mismatch,

        reject_unauthenticated_sender_login_mismatch,

        reject_non_fqdn_recipient,

        reject_invalid_hostname,

        reject_unknown_sender_domain,

        check_sender_access hash:/etc/postfix/sender_access

smtpd_sender_login_maps =

        mysql:/etc/postfix/mysql_virtual_sender_maps.cf,

        mysql:/etc/postfix/mysql_virtual_alias_maps.cf

localhost# postfix reload

在客户端测试效果:

客户端伪造发信人测试,test1@example.com伪造成发件人test@yahoo.com未成功!

[root@mail ~]# perl -MMIME::Base64 -e “print encode_base64(‘123456’);”         

MTIzNDU2

[root@mail ~]# perl -MMIME::Base64 -e “print encode_base64(‘test1@example.com’);”

dGVzdDFAZXhhbXBsZS5jb20=

[root@mail ~]# telnet mail.example.com 25

Trying 124.172.224.76…

Connected to mail.example.com (124.172.224.76).

Escape character is ‘^]’.

auth login

220 mail.example.com ESMTP Postfix

334 VXNlcm5hbWU6

dGVzdDFAZXhhbXBsZS5jb20=

334 UGFzc3dvcmQ6

MTIzNDU2

235 2.7.0 Authentication successful

mail from:test@yahoo.com

250 2.1.0 Ok

rcpt to:445335413@qq.com

553 5.7.1 <test@yahoo.com>: Sender address rejected: not owned by user test1@example.com

客户端用真实的地址发信测试成功

[root@mail ~]# telnet mail.example.com 25

Trying 124.172.224.76…

auConnected to mail.example.com (124.172.224.76).

Escape character is ‘^]’.                                                     220 mail.example.com ESMTP Postfix

auth login

334 VXNlcm5hbWU6

dGVzdDFAZXhhbXBsZS5jb20=

334 UGFzc3dvcmQ6

MTIzNDU2

235 2.7.0 Authentication successful

mail from:test1@example.com

250 2.1.0 Ok

rcpt to:445335413@qq.com

250 2.1.5 Ok

Ok,测试成功!

在CentOS 8系统上配置和管理防火墙(Firewall)的方法

在本文中,我们将介绍如何在CentOS 8操作系统上配置和管理防火墙(Firewall),我们还将说明基本的FirewallD概念。防火墙是一种用于监视和过滤传入和传出网络流量的方法,它通过定义一组安全规则来工作,这些安全规则确定是允许还是阻止特定流量,正确配置的防火墙是整个系统安全的最重要方面之一,CentOS 8搭载了一个名为firewalld的防火墙守护程序,它是具有D-Bus界面的完整解决方案,可让你动态管理系统的防火墙,参考在Ubuntu 18.04/16.04系统上安装和使用Firewalld的方法

基本防火墙概念

Firewalld使用区域和服务的概念,根据你要配置的区域和服务,你可以控制允许或禁止与系统进行的流量。

可以使用firewall-cmd命令行实用程序配置和管理Firewalld。

在CentOS 8操作系统中,iptables被nftables替代,作为firewalld守护程序的默认防火墙后端。

1、防火墙区域

区域是预定义的规则集,用于指定计算机连接到的网络的信任级别,你可以将网络接口和源分配给区域。

以下是FirewallD提供的区域,根据区域的信任级别从不信任到信任:

drop:删除所有传入连接,而无任何通知,仅允许传出连接。

block:所有传入连接均被拒绝,其中icmp-host禁止消息用于IPv4,icmp6-adm禁止用于IPv6n,仅允许传出连接。

public:用于不受信任的公共区域,你不信任网络上的其他计算机,但是可以允许选择的传入连接。

external:用于在系统充当网关或路由器时启用了NAT伪装的外部网络,仅允许选择的传入连接。

internal:当系统充当网关或路由器时,用于内部网络,网络上的其他系统通常是受信任的,仅允许选择的传入连接。

dmz:用于非军事区中访问网络其余部分的计算机,仅允许选择的传入连接。

work:用于工作机,网络上的其他计算机通常是受信任的,仅允许选择的传入连接。

home:用于家用机器,网络上的其他计算机通常是受信任的,仅允许选择的传入连接。

trusted:接受所有网络连接,信任网络中的所有计算机。

2、防火墙服务

防火墙服务是预定义的规则,适用于区域,并定义必要的设置以允许特定服务的传入流量,该服务使你可以轻松地在一个步骤中执行多个任务。

例如,服务可以包含有关打开端口,转发流量等的定义。

3、防火墙运行时和永久设置

Firewalld使用两个单独的配置集,即运行时配置和永久配置。

运行时配置是实际的运行配置,并且不会在重新启动后持续存在,当firewalld守护程序启动时,它将加载永久配置,该配置将成为运行时配置。

默认情况下,使用firewall-cmd实用程序对Firewalld配置进行更改时,更改将应用​​于运行时配置,要使更改永久生效,请在命令后附加–permanent选项。

要在两个配置集中应用更改,可以使用以下两种方法之一:

1]、更改运行时配置并将其永久化:

$ sudo firewall-cmd <options>

$ sudo firewall-cmd –runtime-to-permanent

2]、更改永久配置并重新加载firewald守护程序:

$ sudo firewall-cmd –permanent <options>

$ sudo firewall-cmd –reload

启用FirewallD

在CentOS 8操作系统上,默认情况下已安装并启用firewalld,如果由于某种原因未在系统上安装它,则可以通过键入以下命令来安装并启动守护程序:

$ sudo dnf install firewalld

$ sudo systemctl enable firewalld –now

可以使用以下方法检查防火墙服务的状态:

$ sudo firewall-cmd –state

如果启用了防火墙,该命令应显示正在运行,否则,你将看到未运行。

参考:CentOS 7下使用FirewallD构建动态防火墙

防火墙区域

如果尚未更改,则默认区域设置为public,所有网络接口都分配给该区域。

默认区域是用于所有未明确分配给另一个区域的区域。

可以通过键入以下命令查看默认区域:

$ sudo firewall-cmd –get-default-zone

返回:

public

要获取所有可用区域的列表,请输入:

$ sudo firewall-cmd –get-zones

返回:

block dmz drop external home internal public trusted work(阻止dmz放下外部家庭内部公共信任的工作)

要查看活动区域和分配给它们的网络接口,请执行以下操作:

$ sudo firewall-cmd –get-active-zones

下面的输出显示接口eth0和eth1已分配给公共区域:

public

interfaces: eth0 eth1

可以使用以下命令打印区域配置设置:

$ sudo firewall-cmd –zone=public –list-all

返回:

public (active)

target: default

icmp-block-inversion: no

interfaces: eth0 eth1

sources:

services: ssh dhcpv6-client

ports:

protocols:

masquerade: no

forward-ports:

source-ports:

icmp-blocks:

rich rules:

从上面的输出中,我们可以看到公共区域处于活动状态,并使用默认目标REJECT,输出还显示该区域由eth0和eth1接口使用,并允许DHCP客户端和SSH通信。

如果要检查所有可用区域的配置,请输入:

$ sudo firewall-cmd –list-all-zones

该命令将显示包含所有可用区域设置的巨大列表。

1、更改区域目标

目标为未指定的传入流量定义区域的默认行为,可以将其设置为以下选项之一:默认,接受,拒绝和删除。

要设置区域的目标,请使用–zone选项指定区域,并使用–set-target选项指定目标。

例如,要将公共区域的目标更改为DROP,可以运行:

$ sudo firewall-cmd –zone=public –set-target=DROP

2、将接口分配给其他区域

你可以为不同区域创建特定的规则集,并为其分配不同的接口,当你在计算机上有多个接口时,这特别有用。

要将接口分配给其他区域,请使用–zone选项指定区域,并使用–change-interface选项指定接口。

例如,以下命令将eth1接口分配给工作区:

$ sudo firewall-cmd –zone=work –change-interface=eth1

通过键入以下命令来验证更改:

$ sudo firewall-cmd –get-active-zones

返回:

work

interfaces: eth1

public

interfaces: eth0

3、更改默认区域

要更改默认区域,请使用–set-default-zone选项,后跟要设为默认区域的名称。

例如,要将默认区域更改为home,可以运行以下命令:

$ sudo firewall-cmd –set-default-zone=home

使用以下命令验证更改:

$ sudo firewall-cmd –get-default-zone

返回:

home

防火墙服务

使用防火墙,可以基于称为服务的预定义规则允许特定端口或源的流量。

要获取所有默认可用服务的列表,请输入:

$ sudo firewall-cmd –get-services

通过打开/usr/lib/firewalld/services目录中的关联.xml文件,可以找到有关每个服务的更多信息,例如,HTTP服务的定义如下(/usr/lib/firewalld/services/http.xml文件):

<?xml version=”1.0″ encoding=”utf-8″?>

<service>

<short>WWW (HTTP)</short>

<description>HTTP is the protocol used to serve Web pages. If you plan to make your Web server publicly available, enable this option. This option is not required for viewing pages locally or developing Web pages.</description>

<port protocol=”tcp” port=”80″/>

</service>

要仅对当前会话(运行时配置)允许公共区域中的接口允许传入的HTTP通信(80端口),请输入:

$ sudo firewall-cmd –zone=public –add-service=http

如果要修改默认区域,则可以省略–zone选项。

要验证是否已成功添加服务,请使用–list-services选项:

$ sudo firewall-cmd –zone=public –list-services

返回:

ssh dhcpv6-client http

如果你想在重启后将80端口保持打开状态,则需要再次输入相同的命令,但这一次带有–permanent选项:

$ sudo firewall-cmd –permanent –zone=public –add-service=http

使用–list-services和–permanent选项来验证你的更改:

$ sudo firewall-cmd –permanent –zone=public –list-services

返回:

ssh dhcpv6-client http

删除服务的语法与添加服务时的语法相同,只需使用–remove-service而不是–add-service选项即可:

$ sudo firewall-cmd –zone=public –remove-service=http –permanent

上面的命令从公共区域永久配置中删除http服务。

下面讲解:创建一个新的FirewallD服务。

正如我们已经提到的,默认服务存储在/usr/lib/firewalld/services目录中,创建新服务的最简单方法是将现有服务文件复制到/etc/firewalld/services目录(该目录是用户创建的服务的位置)并修改文件设置。

例如,要为Plex Media Server创建服务定义,可以使用SSH服务文件:

$ sudo cp /usr/lib/firewalld/services/ssh.xml /etc/firewalld/services/plexmediaserver.xml

打开新创建的plexmediaserver.xml文件,并在<short>和<description>标记内更改服务的简称和描述,你需要更改的最重要的标签是端口标签,它定义了你要打开的端口号和协议。

在下面的示例中,我们打开端口1900 UDP和32400 TCP(/etc/firewalld/services/plexmediaserver.xml文件):

/etc/firewalld/services/plexmediaserver.xml

<?xml version=”1.0″ encoding=”utf-8″?>

<service version=”1.0″>

<short>plexmediaserver</short>

<description>Plex is a streaming media server that brings all your video, music and photo collections together and stream them to your devices at anytime and from anywhere.</description>

<port protocol=”udp” port=”1900″/>

<port protocol=”tcp” port=”32400″/>

</service>

保存文件并重新加载FirewallD服务:

$ sudo firewall-cmd –reload

现在,可以像其他任何服务一样在你的区域中使用plexmediaserver服务。

打开端口和源IP

Firewalld还允许你快速启用来自受信任IP地址或特定端口上的所有流量,而无需创建服务定义。

1、打开源IP

要允许来自特定IP地址(或范围)的所有传入流量,请使用–zone选项指定区域,并使用–add-source选项指定源IP。

例如,要在公共区域中允许来自192.168.1.10的所有传入流量,请运行:

$ sudo firewall-cmd –zone=public –add-source=192.168.1.10

使新规则持久化:

$ sudo firewall-cmd –runtime-to-permanent

使用以下命令验证更改:

$ sudo firewall-cmd –zone=public –list-sources

返回:

192.168.1.10

删除源IP的语法与添加源IP的语法相同,只需使用–remove-source,而不是–add-source选项:

$ sudo firewall-cmd –zone=public –remove-source=192.168.1.10

2、打开源端口

要允许给定端口上的所有传入流量,请使用–zone选项指定区域,并使用–add-port选项指定端口和协议。

例如,要为当前会话打开公共区域中的8080端口,请运行:

$ sudo firewall-cmd –zone=public –add-port=8080/tcp

该协议可以是tcp、udp、sctp或dccp。

验证更改:

$ sudo firewall-cmd –zone=public –list-ports

返回:

8080

要在重新启动后使端口保持打开状态,请使用–permanent选项运行同一命令,或执行以下命令,将规则添加到永久设置中:

$ sudo firewall-cmd –runtime-to-permanent

删除端口的语法与添加端口时的语法相同,只需使用–remove-port,而不是–add-port选项即可:

$ sudo firewall-cmd –zone=public –remove-port=8080/tcp

转发端口

要将流量从一个端口转发到另一个端口,请首先使用–add-masquerade选项启用对所需区域的伪装,例如,要对外部区域启用伪装,请键入:

$ sudo firewall-cmd –zone=external –add-masquerade

1、将流量从一个端口转发到IP地址上的另一个端口

在以下示例中,我们将流量从80端口转发到同一服务器上的8080端口:

$ sudo firewall-cmd –zone=external –add-forward-port=port=80:proto=tcp:toport=8080

2、将流量转发到另一个IP地址

在以下示例中,我们将流量从80端口转发到IP 10.10.10.2的服务器上的80端口:

$ sudo firewall-cmd –zone=external –add-forward-port=port=80:proto=tcp:toaddr=10.10.10.2

3、将流量转发到其他端口上的另一台服务器

在下面的示例中,我们将流量从80端口转发到IP 10.10.10.2的服务器上的8080端口:

$ sudo firewall-cmd –zone=external –add-forward-port=port=80:proto=tcp:toport=8080:toaddr=10.10.10.2

要使转发规则持久化,请使用:

$ sudo firewall-cmd –runtime-to-permanent

结论

通过上面的操作步骤,你已经了解了如何在CentOS 8系统上配置和管理防火墙服务。

确保允许系统正常运行所必需的所有传入连接,同时限制所有不必要的连接。

CentOS7 – 配置Dovecot以实现安全的POP3和IMAP访问-pop3设置

配置Dovecot以实现安全的POP3和IMAP访问

检查电子邮件时,电子邮件程序将连接到您的邮件服务器,以查看邮件目录中是否有新邮件。 如果将其配置为使用邮局协议(POP3),则会在本地下载邮件并从服务器中删除它们。 如果将其配置为使用Internet邮件访问协议(IMAP),则邮件将保留在服务器上,您可以远程管理它.

Dovecot开箱即用处理这两种协议。 由于我们已经为其SASL功能安装了Dovecot,我们可以在系统的防火墙中打开POP3和IMAP流量的标准端口并完成。 但是,连接将是未加密的,并且信息将以纯文本形式通过网络传输。 此配方教您如何使用SSL保护这些连接.

准备

此配方需要一个CentOS系统,Postfix和Dovecot配置如前面的配方中所述。 通过使用root帐户登录或使用sudo,还需要管理权限。

怎么做

请按照以下步骤配置对Dovecot的访问权限:

  • 使用文本编辑器打开/etc/dovecot/dovecot.conf:
vi /etc/dovecot/dovecot.conf
  • 找到协议参数。 删除前导#字符并将其值设置为imaps pop3s:
protocols = imaps pop3s
  • 保存更改并关闭文件。
  • 使用文本编辑器打开/etc/dovecot/conf.d/10-ssl.conf:
vi /etc/dovecot/conf.d/10-ssl.conf
  • 找到ssl参数并将其值设置为yes:
 ssl = yes
  • 找到ssl_cert和ssl_key参数。 使用证书和密钥文件的路径更新其值(请注意,两个路径都以<开头):
ssl_cert = </etc/pki/tls/certs/mail.example.pem
ssl_key = </etc/pki/tls/private/mail.example.key
  • 保存更改并关闭文件。
  • 重新启动Dovecot以使更改生效:
systemctl restart dovecot.service
  • 在防火墙中打开用于IMAP over SSL的端口993和用于POP3 over SSL的端口995:
firewall-cmd --permanent --add-service=imaps \
--add-service=pop3s
firewall-cmd --reload

工作原理

Dovecot可以轻松保护POP3和IMAP连接的流量; 事实上,配置它只需要几秒钟。 我们首先编辑了协议参数/etc/dovecot/dovecot.conf,让Dovecot知道我们希望这些协议得到保护:

protocols = imaps pop3s

然后我们更新了/etc/dovecot/conf.d/10-ssl.conf以启用SSL以使用sslparameter并使用ssl_cert和ssl_key识别证书和加密密码。由于Postfix和Dovecot在同一系统上运行,并且我们已经为 Postfix生成了密钥和证书,因此我们可以在Dovecot的配置中引用相同的文件.Dovecot使用前面的<在路径前面指定它应该使用文件的内容作为参数的值而不是文字字符串本身:

ssl = yes
ssl_cert = </etc/pki/tls/certs/mail.example.pem
ssl_key = </etc/pki/tls/private/mail.example.key

Dovecot仍然允许来自localhost的连接对POP和IMAP(分别在端口110和143上)进行非SSL访问,但是一旦我们重新启动它以使配置更改生效,所有其他用户将需要使用SSL来 访问他们的消息.

我们可以使用mailx来测试配置。 首先,我们将检查POP3:

mailx -f pop3s://tboronczyk@mail.example.com

-f参数指定mailx将读取的目录以检索我们的消息。 作为URI,该值指示mailx使用POP3 over SSL(pop3s)在mail.example.com系统上读取我们用户的默认目录。

除了更改URI的协议之外,该命令与检查IMAP相同:

mailx -f imaps://tboronczyk@mail.example.com

因为我们使用的是自签名证书,所以mailx会抱怨证书尚未被用户标记为信任,并提示我们是否要继续。 回答y,然后系统会提示您输入用户密码。 mailx然后显示用户的收件箱。 在提示符处输入quit退出程序:CentOS7 - 配置Dovecot以实现安全的POP3和IMAP访问

mailx可用于测试我们通过SSL测试POP3和IMAP的配置

注意

如果mailx抱怨它缺少nss-config-dir变量,则可以使用-S在命令行上定义它。 该值应该是mailx可用于验证证书信任的证书数据库的路径:

mailx -S nss-config-dir=/etc/pki/nssdb \
-f pop3s://tboronczyk@mail.example.com

当我们第一次配置Postfix时,我们调整了它的home_mailbox参数以将消息存储在不同的目录中。 我承认当时这是可选的,但是当我们设置检索访问时它会使事情变得更容易和更清晰。 如果您当时未设置home_mailbox,则传入的消息将附加到/ var / spool / mail下的用户邮件假脱机文件中,并且Dovecot需要一些其他配置才能访问它们。 这些更改可以在/etc/dovecot/conf.d/10-mail.conf中进行.

或者,您可以将假脱机文件转换为Maildir目录中的单独消息。 首先,安装mb2md软件包:

yum install ftp://ftp.pbone.net/mirror/atrpms.net/el7- 
x86_64/atrpms/stable/mb2md-3.20-2.at.noarch.rpm

打开/etc/postfix/main.cf文件并找到home_mailbox参数。 从值为Maildir /的条目中删除前导#字符:

home_mailbox = Maildir/

保存更改,然后重新启动Postfix以使更新生效。 然后,对于每个帐户,调用mb2md来转换假脱机文件。 该实用程序需要作为目标用户运行,因此请使用su临时切换到该用户的上下文:

su -l -c "mb2md -m" tboronczyk

See also

Refer to the following resources for more information on the different topics discussed in this recipe, including Dovecot, POP3, and IMAP.

  • The mailx manual page (man 1 mailx)
  • The Dovecot Homepage (http://www.dovecot.org/)
  • RFC 3501: Internet Message Access Protocol (https://tools.ietf.org/html/rfc3501)
  • RFC 1939: Post Office Protocol (https://tools.ietf.org/html/rfc1939)
  • Converting Mbox Mailboxes to Maildir format (http://batleth.sapienti-sat.org/projects/mb2md/)

DCS里面增加可以绑定的轴控制

I find that the A-10C lua files (like those of the KA-50) do not work with the mnemomic device and command ID. You have to use the numerical ones.

The code below creates an axis command for the UHF radio volume knob:
Code:

{action = 3011, cockpit_device_id = 54, name = _('UHF Radio Volume')},

The device ID for the UHF Radio is 54 as you can see in “devices.lua”. The command ID is 3011. You find the command as “device_commands.Button_11” in “clickabledata.lua”. So it’s button 11 of device 54. However, as you see in “command_defs.lua”, all device command numbers are defined as 3000 + Button-Number.
Note: The axis uses only half of the slider movement. You have to define parameters in Axis Tune to use the full slider movement or pot rotation. That’s a common problem in custom axis definitions.
Have fun!

https://forums.eagle.ru/forum/english/dcs-world-topics/input-and-output/home-cockpits/268923-adding-custom-axes-a-10c-to-default-lua

AC86U官版固件安装vlmcsd KMS服务

 1.开启jffs和ssh(或telnet),登陆路由器管理界面,通过系统管理-系统设置开启jffs和ssh。

2.通过官方下载vlmcsd可执行文件(官方提供源码及一堆各环境下的编译好的可执行文件,有兴趣可以自己编译)https://github.com/Wind4/vlmcsd/releases/。
       3.上传vlmcsd可执行文件到路由器/
          mips架构的路由器使用/binaries/Linux/mips/little-endian/static/vlmcsd-mips32el-uclibc-static
          AC86U使用这个:arm架构的路由器使用/binaries/Linux/armlittle-endian/static/vlmcsd-armv7el-uclibc-static
          将文件重命名为vlmcsd,通过xftp,winscp等工具上传到路由器/jffs目录下
  4.通过ssh或telnet连接路由器
          赋予vlmcsd可执行权限
          chmod 700 vlmcsd
          启动vlmcsd
          /jffs/vlmcsd

          使用命令netstat -an |grep 1688 检查vlmcsd是否启动成功。

5.修改/jffs/scripts/nat-start,增加vlmcsd,实现自动运行。

6.增加dns解析,添加srv记录到/jffs/configs/dnsmasq.conf.add。  

输入命令
       echo “srv-host=_vlmcs._tcp,router,1688”>>/jffs/configs/dnsmasq.conf.add
  其中 _vlmcs._tcp 为服务名;router为路由在内网中的网络名称(可通过uname –n查看);1688为kms激活服务默认端口号;
       输入命令service restart_dnsmasq重启dnsmasq服务。

制作 macOS Catalina ISO镜像

❶:hdiutil create -o /tmp/Catalina -size 9000m -volname Catalina -layout SPUD -fs JHFS+

❷:hdiutil attach /tmp/Catalina.dmg -noverify -mountpoint /Volumes/Catalina

❸:sudo /Applications/Install\ macOS\ Catalina.app/Contents/Resources/createinstallmedia –volume /Volumes/Catalina –nointeraction

❹:hdiutil detach /volumes/Install\ macOS\ Catalina

❺:hdiutil convert /tmp/Catalina.dmg -format UDTO -o ~/Desktop/Catalina.cdr

❻:mv ~/Desktop/Catalina.cdr ~/Desktop/Catalina.iso

❼:rm /tmp/Catalina.dmg