PVE/postfix配置smtp发送邮件
发布时间:December 9, 2021 // 分类: // No Comments
安装认证模块:
apt install libsasl2-modules
#如需pcre匹配安装
#apt install postfix-pcre
修改/etc/postfix/main.cf添加:
myhostname=pve.lan
#配置文件内有relayhost要先注释,465端口是SMTPS,587端口是STARTTLS
relayhost = smtp.qq.com:465
#此参数被smtp_tls_security_level取代
#smtp_use_tls = yes
#使用SMTPS非STARTTLS加密方式
smtp_tls_wrappermode = yes
#加密级别
smtp_tls_security_level = encrypt
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
#本地用户替换为smtp认证用户,smtp_generic_maps和sender_canonical_maps都可以
smtp_generic_maps = hash:/etc/postfix/generic
#sender_canonical_maps = hash:/etc/postfix/sender_canonical
#使用pcre匹配本机用户
#sender_canonical_maps = pcre:/etc/postfix/sender_pcre_canonical
#header检查并替换发送者名称
smtp_header_checks = pcre:/etc/postfix/smtp_header_checks
sender_canonical或generic映射本机用户到smtp账号:
cat /etc/postfix/generic
#本机所有用户,注意pve.lan为主配置文件myhostname
@pve.lan support@haiyun.me
#下面2个等效
root support@haiyun.me
root@pve.lan support@haiyun.me
正则映射:
cat /etc/postfix/sender_pcre_canonical
#匹配所有hostname和所有用户
/.*/ support@haiyun.me
smtp账号密码:
cat /etc/postfix/sasl_passwd
smtp.qq.com support@haiyun.me:password
生成hash数据库,pcre不用生成:
postmap /etc/postfix/sasl_passwd
postmap /etc/postfix/generic
postmap /etc/postfix/sender_canonical
替换发件人姓名:
cat /etc/postfix/smtp_header_checks
/^From:.*/ REPLACE From: 重要通知 <support@haiyun.me>
发送邮件测试:
apt install bsd-mailx
echo "www.haiyun.me" |mail -s test support@haiyun.me
echo "test" | /usr/bin/pvemailforward
将其它用户邮件转发到root用户:
cat /etc/aliases
postmaster: root
nobody: root
#也可使用~/.forward
#root: support@haiyun.me
postalias /etc/aliases
将root用户邮件转发到外部邮箱:
cat ~/.forward
support@haiyun.me
参考:
https://serverfault.com/questions/717719/how-can-i-strip-or-rewrite-the-senders-name-of-a-from-address-when-using-postfi
https://forum.proxmox.com/threads/get-postfix-to-send-notifications-email-externally.59940/
PVE/Linux安装nut管理apc BK650M2-CH ups自动关机
发布时间:December 9, 2021 // 分类: // 9 Comments
先查看usb是否识别ups:
lsusb
Bus 001 Device 054: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
安装:
apt install nut-server nut-client
配置nut运行为服务器模式,可控制多台电脑。
/etc/nut/nut.conf
MODE=netserver
设置nut和ups连接方式,修改此配置后需重新启动upsdrvctl start生效。
/etc/nut/ups.conf
[myups]
driver = usbhid-ups
port = auto
desc = "APC UPS"
#忽略低电量和低运行时间,有的断电后会马上关机
ignorelb
#重写ups返回的低电量和低运行时间值,可用于控制停电时关机时间,满足一个关机,-1为禁用此项
override.battery.charge.low = 99
override.battery.runtime.low = -1
#可以都设置为-1禁用ups低电量自动关机,使用下面的脚本自定义关机
连接ups,nut-server启动时自动加载,usb拔出后需手工启动。
upsdrvctl start
设置nut server监听ip和端口:
/etc/nut/upsd.conf
LISTEN 0.0.0.0 3493
设置客户端连接验证密码:
/etc/nut/upsd.users
#管理员可set更改ups内变量参数,master可设置FSD关机标签,slave收到通知后关机
[admin]
password = 123456
actions = SET FSD
instcmds = ALL
upsmon master
[user1]
password = 123456
actions = FSD
#instcmds = ALL
upsmon master
#别的电脑连接使用此用户
[user2]
password = 123456
#actions = SET
#instcmds = ALL
upsmon slave
设置upsmon客户端连接nut server监控ups状态,当断电后执行关机等操作:
/etc/nut/upsmon.conf
MONITOR myups@localhost 1 user1 123456 master
upsmon默认监控断电且ups电量过低时执行关机,可自定义关机:
upsmon.conf
NOTIFYCMD /sbin/upssched
#当使用电池来电时syslog并执行上面的命令
NOTIFYFLAG ONBATT SYSLOG+EXEC
NOTIFYFLAG ONLINE SYSLOG+EXEC
upssched自定义操作:
/etc/nut/upssched.conf
CMDSCRIPT /usr/local/bin/upssched
#此目录nut要可写
PIPEFN /run/nut/upssched.pipe
LOCKFN /run/nut/upssched.lock
#断电10秒后执行上面脚本并发送power-off参数
AT ONBATT * START-TIMER power-off 10
#来电后取消上面定时
AT ONLINE * CANCEL-TIMER power-off
关机脚本,要添加可执行权限:
/usr/local/bin/upssched
#! /bin/sh
case $1 in
power-off)
/sbin/upsmon -c fsd
;;
*)
logger -t upssched "Unrecognized command: $1"
;;
esac
启动并查看ups信息:
systemctl restart nut-server.service
systemctl restart nut-client.service
upsc myups
配置nut-cgi web管理界面:
apt install nut-cgi --no-install-recommends fcgiwrap nginx
nut-cgi连接nut-server配置:
/etc/nut/hosts.conf
MONITOR myups@localhost 1 user1 123456 master
nginx配置文件:
server {
listen 89;
charset utf-8;
location /{
alias /usr/share/nut/www/;
try_files $uri $uri/ /index.html;
}
location /cgi-bin/nut/ {
gzip off;
alias /usr/lib/cgi-bin/nut/;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/lib/$fastcgi_script_name;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
}
access_log off;
}
nut web界面效果:
参考:
https://loganmarchione.com/2017/02/raspberry-pi-ups-monitor-with-nginx-web-monitoring/
https://srackham.wordpress.com/2013/02/27/configuring-nut-for-the-eaton-3s-ups-on-ubuntu-linux/
https://alainlam.cn/?p=56
https://untitled.pw/hardware-iot/2767.html
https://www.wangchucheng.com/zh/posts/setting-up-ups-with-nut-on-linux/
https://forums.contribs.org/index.php?topic=44443.0
PVE/KVM安装windows遇到的问题
发布时间:December 8, 2021 // 分类: // No Comments
由于windows不包含VirtIO驱动,PVE默认使用ide硬盘很卡,在新建虚拟机时将硬盘ide调整为scsi,额外新建一个cd驱动器挂载virtio-win iso,然后在windows安装界面加载挂载的驱动,windows7最新可用版本为virtio-win-0.1.173。
windows7安装完成后设备管理器有一未识别设备,下载windows6.x-hypervintegrationservices-x64管理员运行powershell安装。
Dism /online /Add-Package /PackagePath:C:\windows6.x-hypervintegrationservices-x64.cab
参考:
https://forum.proxmox.com/threads/unknown-device-in-win7-vm.49698/
https://forum.proxmox.com/threads/windows-7-and-virtio-drivers-no-signed-drivers-found-for-0-1-185-and-0-1-190-or-bsod-with-0-1-189.79708/
https://pve.proxmox.com/wiki/Paravirtualized_Block_Drivers_for_Windows
https://pve.proxmox.com/wiki/Windows_7_guest_best_practices
https://pve.proxmox.com/wiki/Windows_VirtIO_Drivers
ubuntu挂载samba/smb共享中文乱码
发布时间:December 3, 2021 // 分类: // No Comments
安装smb/samba客户端及手工挂载:
apt-get install cifs-utils
mount -t cifs -o user=user,pass=pass,file_mode=0644,dir_mode=0755 //192.168.1.1/share /mnt/
#有的参数不一样并需要指定版本
#mount -t cifs -o username=user,password=pass,iocharset=utf8,vers=3.0 //192.168.1.1/temp /mnt/
修改fstab配置文件开机自动挂载:
cat /etc/fstab
//192.168.1.1/share /mnt cifs user=user,pass=pass 0 0
如果中文乱码先查看编码是否为utf8:
cat /etc/default/locale
LANG="en_US.UTF-8"
LANGUAGE="en_US:en"
#LANG="zh_CN.UTF-8"
#LANGUAGE="zh_CN:zh"
查看是否安装nls_utf8内核模块:
ls /lib/modules/$(uname -r)/kernel/fs/nls/nls_utf8.ko
安装nls_utf8内核模块:
apt install linux-modules-extra-$(uname -r)
还是不行挂载添加指定utf8编码:
iocharset=utf8
参考:
https://askubuntu.com/questions/519796/unable-to-mount-cifs-with-iocharset-utf8
分类
- Apache (13)
- Nginx (45)
- PHP (86)
- IIS (8)
- Mail (17)
- DNS (16)
- Cacti (14)
- Squid (5)
- Nagios (4)
- Puppet (7)
- CentOS (13)
- Iptables (23)
- RADIUS (3)
- OpenWrt (41)
- DD-WRT (1)
- VMware (9)
- 网站程序 (2)
- 备份存储 (11)
- 常用软件 (20)
- 日记分析 (10)
- Linux基础 (18)
- 欧诺代理 (0)
- Linux服务 (18)
- 系统监控 (4)
- 流量监控 (7)
- 虚拟化 (28)
- 伪静态 (2)
- LVM (3)
- Shell (18)
- 高可用 (2)
- 数据库 (16)
- FreeBSD (3)
- 网络安全 (25)
- Windows (35)
- 网络工具 (22)
- 控制面板 (3)
- 系统调优 (10)
- Cisco (3)
- VPN (6)
- ROS (20)
- Vim (14)
- KMS (4)
- PXE (2)
- Mac (1)
- Git (1)
- PE (1)
- LNS (2)
- Xshell (7)
- Firefox (13)
- Cygwin (4)
- OpenSSL (9)
- Sandboxie (3)
- StrokesPlus (1)
- AutoHotKey (4)
- Total Commander (3)
- WordPress (3)
- iMacros (6)
- Typecho (2)
- Ollydbg (1)
- Photoshop (1)
- 正则 (3)
- Debian (3)
- Python (8)
- NoSQL (6)
- 消息队列 (4)
- JS (7)
- Tmux (3)
- GO (7)
- HHVM (2)
- 算法 (1)
- Docker (2)
- PT (15)
- N1 (16)
- K2P (6)
- LUKS (4)
最新文章
- 光猫拨号ImmortalWrt/OpenWRT路由获取ipv6遇到的问题
- php-fpm错误error_log日志配置
- debian-12/bookworm安装mariadb10.3和mysql5.6
- smokeping主从配置及遇到的问题
- openwrt/linux使用tcpdump/nflog ulogd记录iptables日志
- tmux bash shell自动保存history
- ImmortalWrt/OpenWRT为guest wifi网络配置ipv6 nat6
- PVE更新upgrade遇到The following packages have been kept back
- openwrt/immortalwrt修改odhcpd ipv6 preferred_lifetime和valid_lifetime
- golang版本udpxy iptv rtp多播转http单播
最近回复
- opnfense: 谢谢博主!!!解决问题了!!!我之前一直以为内置的odhcp6就是唯一管理ipv6的方式
- liyk: 这个方法获取的IPv6大概20分钟之后就会失效,默认路由先消失,然后Global IPV6再消失
- 海运: 不好意思,没有。
- zongboa: 您好,請問一下有immortalwrt設定guest Wi-Fi的GUI教學嗎?感謝您。
- 海运: 恩山有很多。
- swsend: 大佬可以分享一下固件吗,谢谢。
- Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
- 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
- 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
- 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
归档
- August 2024
- May 2024
- February 2024
- January 2024
- December 2023
- November 2023
- October 2023
- September 2023
- August 2023
- May 2023
- April 2023
- February 2023
- January 2023
- December 2022
- September 2022
- July 2022
- April 2022
- March 2022
- February 2022
- January 2022
- December 2021
- November 2021
- April 2021
- March 2021
- February 2021
- January 2021
- December 2020
- November 2020
- October 2020
- September 2020
- July 2020
- May 2020
- April 2020
- March 2020
- February 2020
- January 2020
- December 2019
- November 2019
- July 2019
- April 2019
- March 2019
- February 2019
- January 2019
- December 2018
- November 2018
- October 2018
- September 2018
- August 2018
- July 2018
- June 2018
- April 2018
- March 2018
- February 2018
- January 2018
- December 2017
- October 2017
- September 2017
- August 2017
- July 2017
- April 2017
- March 2017
- February 2017
- January 2017
- December 2016
- November 2016
- July 2016
- June 2016
- November 2015
- October 2015
- September 2015
- August 2015
- July 2015
- June 2015
- May 2015
- April 2015
- March 2015
- February 2015
- January 2015
- December 2014
- November 2014
- October 2014
- September 2014
- August 2014
- July 2014
- June 2014
- May 2014
- April 2014
- March 2014
- February 2014
- January 2014
- December 2013
- November 2013
- October 2013
- August 2013
- July 2013
- June 2013
- May 2013
- April 2013
- March 2013
- February 2013
- January 2013
- December 2012
- November 2012
- October 2012
- September 2012
- August 2012
- July 2012
- June 2012
- May 2012
- April 2012
- March 2012
- February 2012
- October 2011
- September 2011
- August 2011
- July 2011