Raspberry Pi 获取公网地址
因为买不起域名,请高主任帮忙解决内网上线问题。感谢CCTV,感谢MTV,感谢高主任帮我写的脚本。
1>: 安装配置postfix
[*]
[*]# apt-get install postfix (安装postfix)
[*]或:
[*]# aptitude install postfix
[*]
[*]# echo 'www.yes4ko.com' >/etc/hostname (修改主机名)
[*]# echo 'X.X.X.X www.yes4ko.com www' >> /etc/hosts
[*]# echo 'X.X.X.X ftp.yes4ko.com ftp' >> /etc/hosts
[*]
[*]
[*]# vim /etc/postfix/main.cf
[*]myhostname = www.yes4ko.com (主机名FQDN)
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = yes4ko.com (发件人地址)
mydestination = www.yes4ko.com, localhost.localdomain (允许收件的主机)
relayhost = (由于是非公网domain,需要由上游ISP MTA帮忙送信,置空即可!)
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 hash:/etc/postfix/access (只允许这些地址使用postfix)
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = ipv4
relay_domains = yes4ko.com, localhost
[*]:wq
[*]
[*]# vim /etc/postfix/access
.yes4ko.com OK (允许此domain使用postfix)
X.X.X. REJECT (拒绝X.X.X.0/24使用postfix)
[*]:wq
[*]# postalias hash:/etc/aliases (重新生成)
[*]# postmap hash:/etc/postfix/access
[*]
[*]# /etc/init.d/postfix reload(重新加载配置文件)
[*]# /etc/init.d/postfix check (检查 postfix 相关的配置文件)
# /etc/init.d/postfix start (运行 postfix 服务)
# /etc/init.d/postfix stop (停止 postfix 服务)
[*]
[*]# /usr/sbin/postqueue -p (查看邮件队列排队的邮件)
[*]或:
[*]# mailq
[*]
[*]# /etc/init.d/postfix flush (强制将目前正在邮件队列排队的邮件寄出)
2>: 自动获取公网地址
[*]# vim /usr/sbin/getPubIP.sh (编写脚本取得公网IP并mail至相关邮箱)
[*]#!/bin/sh
[*]#Program: save as /usr/sbin/getPubIP.sh
[*]#
[*]DATE=$(date +'%Y-%m-%d %H:%M:%S')
[*]curl ifconfig.me/ip > getip.txt 2>&1
[*]echo $DATE >> getip.txt
[*]tail -2 getip.txt| mail -s 'Today's Public IP Addr' none@none.com
[*]:wq
[*]
3>: 配置 routine
[*]# echo '07 */1 * * * root /usr/sbin/getPubIP.sh' >> /etc/crontab (每间隔1小时执行一次该脚本)
4>: Reserved for future use....
5>: Reserved for future use....
6>: Reserved for future use....
7>: Reserved for future use....
More About Debian :http://bbs.chinaunix.net/thread-3751791-1-1.html
More About Postfix: http://www.postfix.org/STANDARD_CONFIGURATION_README.html#null_client
原文刊载于高主任cu论坛-http://blog.chinaunix.net/uid-25256412-id-4228235.html
好文章
页:
[1]