2022年5月30日星期一

Raspbian 树莓派安装freeswitch

这个方法在我的raspbian上安装不成功!!!
先前记得freeswitch是免费的,安装应该很方便,但今天一弄,有点复杂,记一下
fusionpbx有一个安装脚本,我的操作是基于这个脚本的,大家可以下载下来看看。因为我的pi配置太低,所下想先单独安装freeswitch测试一下,所以没有使用安装脚本进行安装。
sudo git clone https://github.com/fusionpbx/fusionpbx-install.sh.git

先看看freeswitch.org安装说明

TOKEN=YOURSIGNALWIRETOKEN
 
apt-get update && apt-get install -y gnupg2 wget lsb-release
wget --http-user=signalwire --http-password=$TOKEN -O - https://freeswitch.signalwire.com/repo/deb/rpi/debian-release/freeswitch_archive_g0.pub | apt-key add -
 
# This is universal for all Debian distros
# `lsb_release -sc` returns buster or stretch
echo "deb https://freeswitch.signalwire.com/repo/deb/rpi/debian-release/ `lsb_release -sc` main" > /etc/apt/sources.list.d/freeswitch.list
echo "deb-src https://freeswitch.signalwire.com/repo/deb/rpi/debian-release/ `lsb_release -sc` main" >> /etc/apt/sources.list.d/freeswitch.list
 
# you may want to populate /etc/freeswitch at this point.
# if /etc/freeswitch does not exist, the standard vanilla configuration is deployed
apt-get update && apt-get install -y freeswitch-meta-all

因为我的raspbian是基于debian 11,所以这里有两个问题
1:用户名和token要用你自己的,所以你要在https://signalwire.com/freeswitch注册一个账号,然后生成一个token,这个token只出现一次,所以你要记好。
要把token和http-usr换成你自己的。如果你不是debian 11,应该用这种方法没有问题,可以继续安装了。
2:因为的我raspbian是基于debian 11的,这里使用apt-key add的方法已经不行了,需要使用下面的方法
a.下载signalwire的gpg文件存放到/usr/share/keyrings
token="your_token_here"
sudo wget --http-user=silentxo --http-password=$token -O /usr/share/keyrings/signalwire-freeswitch-repo.gpg 
https://freeswitch.signalwire.com/repo/deb/rpi/debian-release/signalwire-freeswitch-repo.gpg
b.在/etc/apt/auth.conf.d/下面生成一个保存有用户名和token的验证登录文件,文件内容如下
machine freeswitch.signalwire.com login signalwire password "your_token"
c.使用sudo apt update,会出现
The following signatures couldn't be verified because the public key is not available: 
NO_PUBKEY 36B4249FA7B0FB03
d.执行验证导入sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 36B4249FA7B0FB03
经过上述的操作,可能安装了
sudo apt install freeswitch-meta-all,需要安装382个包,使用954M的磁盘空间。
先进行安装,后续更新
此方法安装完毕,freeswitch启动出现指令错误的提示,无法运行
错误的原因如下:
Setting up ca-certificates-java (20190909) ...
head: cannot open '/etc/ssl/certs/java/cacerts' for reading: No such file or directory
Error occurred during initialization of VM
Server VM is only supported on ARMv7+ VFP
dpkg: error processing package ca-certificates-java (--configure):
 installed ca-certificates-java package post-installation script subprocess returned error exit status 1
删除原安装,使用编译安装,痛苦的过程。


2022年5月26日星期四

在树莓派上安装配置bind9 dns server

所有的命令与文件的路径都是基于raspberry-pi的Raspbian系统和bind9的安装
uname -a
Linux dns.cqlr.com 5.15.32+ #1538 Thu Mar 31 19:37:58 BST 2022 armv6l GNU/Linux

lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye

1.apt安装程序包 sudo apt install bind9 bind9-doc dnsutils

2.我的raspberry-pi 开启了dhcp客户端服务,导致配置了静态IP(修改/etc/networ/interface)后,dhcpcd 服务又自动获取了IP,重而让服务器有两个IP,关闭dhcpcd服务使用此命令,sudo systemctl disable dhcpcd

cat interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source /etc/network/interfaces.d/*
auto eth0
iface eth0 inet static
address 192.168.199.100/24
gateway 192.168.199.1

你可以不关闭dhcpcd服务,不修改interfaces,转为修改/etc/dhcpcd.conf 设置如下的参数(这种方法我没有测试过,认为关掉一个服务,设备开销要少一些)
interface eth0
static ip_address=192.168.1.23/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1

bind9的配置文件如下:
/etc/bind/named.conf
主要的配置文件,没有配置内容只有对named.conf.options named.conf.local named.conf.default-zones的引用
/etc/bind/named.conf.options
bind服务器的配置选项文件,包括侦听端口,forwarders选项等
/etc/bind/named.conf.local
bind服务器的本地区域配置,此区域的数据将不对外转发
/etc/bind/named.conf.default-zones
bind服务器的默认区域

/usr/share/doc/bind9-doc/arm 目录下有详细的管理手册html文档
https://www.cnblogs.com/doherasyang/p/14464999.html 这是一篇中文文档

几个有用的指令
sudo systemctl status bind9 查看当前bind9服务状态
sudo systemctl restart bind9 重启bind服务器
named-checkconf 检查配置文件
named-checkzone 检查配置区域
sudo rndc flush 清除缓存
rndc是在bind运行时进行操作的管理工具,很有用!

关于修改bind启动项:
修改/etc/defaults/named中的
OPTIONS="-4 -u bind"数据即可让bind9按指定的参数运行
关于这些参数的作用请参考named -help或手册
我这里的-4是指定使用ipv4

关于启动日志
/var/log/syslog中有详细的启动与停止信息可以查看,非常有用

named.conf包括以下几个配置区段
1.acl
2.controls
3.dlz
4.dnssec-policy
5.dyndb
6.key
7.loggind
8.managed-keys
9.masters
10.options
11.parental-agents
12.plugin
13.primaries
14.server
15.statistics-channels
16.trust-anchors
17.trusted-keys
18.view
19.zone

options 区段必须要配置 directory "拟使用的目录"选项,否则程序启动时会出错退出
日志文件是/var/log/syslog,可以使用tail -f /var/log/syslog实时监控日志文件,对于调试很有帮助。

初期配置,修改/etc/bind/named.conf.options
options {
    directory "/var/catch/bind";
    dnssec-validation auto;
};
重启bin9
在本机使用以下命令
dig @127.0.0.1 . ns
如果有返回13个根服务器的地址,服务器就基本正常了,否则要查看日志,排查问题

acl 字符串 { 172.16.72.0/24; 192.168.1.0/24; }; 定义acl名称,可以在以下的命令中引用
allow-notify, allow-query, allow-query-on, allow-recursion, blackhole, allow-transfer, match-clients
acl mylan { 192.168.199.0/24; 127.0.0.1; };

https://kb.isc.org/docs/aa-01526 这个地址有一些相关logging的配置示例可以参考
如果你的queries日志没有记录,要使用 rndc querylog on打开开关

这是我的named.conf.options配置,做个记号
cat named.conf.options
acl internal { 192.168.199.0/24; 127.0.0.1; };
options {
        directory "/var/cache/bind";

        forwarders {
                223.5.5.5;
                223.6.6.6;
                180.76.76.76;
        114.114.114.114;
        };

        allow-query { internal; };
        recursion yes;
        allow-recursion { internal; };
        dnssec-validation no;
        max-cache-size 85%;
};

logging {
     channel default_log {
          file "/var/log/named/default.log" versions 3 size 20m;
          print-time yes;
          print-category yes;
          print-severity yes;
          severity info;
        };

        channel default_syslog {
          print-time yes;
          print-category yes;
          print-severity yes;
          syslog daemon;
          severity info;
        };

        channel default_debug {
          print-time yes;
          print-category yes;
          print-severity yes;
          file "named.run";
          severity dynamic;
        };

        channel queries_log {
          file "/var/log/named/query.log" versions 9 size 20m;
          print-time yes;
          print-category yes;
          print-severity yes;
          severity info;
        };

        channel auth_servers_log {
          file "/var/log/named/auth_servers.log" versions 9 size 20m;
          print-time yes;
          print-category yes;
          print-severity yes;
          severity info;
        };

        channel client_security_log {
          file "/var/log/named/client_security.log" versions 3 size 20m;
          print-time yes;
          print-category yes;
          print-severity yes;
          severity info;
        };

        category default { default_syslog; default_debug; default_log; };
        category config { default_syslog; default_debug; default_log; };
        category dispatch { default_syslog; default_debug; default_log; };
        category network { default_syslog; default_debug; default_log; };
        category general { default_syslog; default_debug; default_log; };
        category queries { queries_log; };
        category resolver { auth_servers_log; default_debug; };
        category cname { auth_servers_log; default_debug; };
        category delegation-only { auth_servers_log; default_debug; };
        category lame-servers { auth_servers_log; default_debug; };
        category edns-disabled { auth_servers_log; default_debug; };
        category client{ client_security_log; default_debug; };
        category security { client_security_log; default_debug; };
};

这是我的named.conf.local配置
//include "/etc/bind/zones.rfc1918";
zone "cqlr.com" {
        type master;
        file "/etc/bind/db.cqlr.com";
        allow-update { internal; };  //同意内网电脑更新
};

zone "199.168.192.in-addr.arpa" {
        type master;
        file "/etc/bind/db.199.168.192";
        allow-update { internal; };  //同意内网电脑更新
};

这是我的db.cqlr.com的配置
$ORIGIN .
$TTL 604800     ; 1 week
cqlr.com                IN SOA  ns.cqlr.com. root.cqlr.com. (
                                6          ; serial
                                604800     ; refresh (1 week)
                                86400      ; retry (1 day)
                                2419200    ; expire (4 weeks)
                                604800     ; minimum (1 week)
                                )
                        NS      ns.cqlr.com.
                        A       192.168.199.100
$ORIGIN cqlr.com.
dns                     A       192.168.199.100
ns                      A       192.168.199.100
$TTL 1200       ; 20 minutes
winent                  A       192.168.199.120 //这是我的win7自动更新的记录
$TTL 604800     ; 1 week
wzl                     A       192.168.199.161

这是我的db.199.168.192的配置
$ORIGIN .
$TTL 604800     ; 1 week
199.168.192.in-addr.arpa IN SOA ns.cqlr.com. root.cqlr.com. (
                                3          ; serial
                                604800     ; refresh (1 week)
                                86400      ; retry (1 day)
                                2419200    ; expire (4 weeks)
                                604800     ; minimum (1 week)
                                )
                        NS      ns.cqlr.com.
$ORIGIN 199.168.192.in-addr.arpa.
100                     PTR     ns.cqlr.com.
                        PTR     dns.cqlr.com.
$TTL 1200       ; 20 minutes
120                     PTR     winent.cqlr.com. //这是我的win7自动更新的记录
$TTL 604800     ; 1 week
161                     PTR     wzl.cqlr.com.

这是/etc/bind的目录权限,先前因为bind用户没有w权限,不能生成.jnl的文件导致客户端自动更新失败
ls -l /etc |grep bind
drwxrwsr-x 2 root bind    4096 May 27 14:43 bind

我的cqlr.com使用了动态更新,当手动修改了zone文件后并reload后并不生效,可以使用下面的方法:
sudo rndc freeze cqlr.com
edit zone 文件
sudo rndc thaw cqlr.com
这样你新增的主机就会刷新并有效了











2022年5月24日星期二

在Linux设备开安装vlmcsd kms server

1.使用 git clone https://github.com/Wind4/vlmcsd 将源码下载至本地
2.使用make开始编译程序

编译完成后,文件如下:
bin/vlmcs 测试kms的客户端
bin/vlmcsd kms服务器端
etc/vlmcsd.ini 配置文件
etc/vlmcsd.kmd I don't know
man/vlmcs.1
man/vlmcsd.7
man/vlmcsd.8
man/vlmcsd-floppy.7
man/vlmcsd.ini.5
man/vlmcsdmulti.1 各种文档
将文档copy到/usr/share/man下的对应目录,将vlmcs vlmcsd copy到/usr/sbin/

关于开机启动,可以编辑/etc/rc.local 将启动脚本写入exit 0之前或者配置为其它开机启动
/usr/sbin/vlmcsd -l /var/log/vlmcsd.log > /dev/null 2>&1
这是我加入rc.local中的启动脚本,指定日志目录名称以缺省启动

验证:
服务端运行netstat -an|grep 1688查看是否有监听端口存在
客户端cscript ospp.vbs /sethst:server-ip
cscript ospp.vbs /act
查看是否成功激活
查看日志记录