显示标签为“linux”的博文。显示所有博文
显示标签为“linux”的博文。显示所有博文

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
查看是否成功激活
查看日志记录








2017年10月10日星期二

SL6安装postgresql

参考网址 https://wiki.postgresql.org/wiki/YUM_Installation
数据库安装
  1. 访问yum.postgresql.org,选择你要安装的postgresql安装版本,选择OS的类型复制rpm包链接。
  2. yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-6-x86_64/pgdg-sl96-9.6-3.noarch.rpm(我的系统是sl6)
  3. yum install postgresql96-server即可完成安装。
数据库初始化
数据库在运行前需初始化,有两种方法
  1. 第一种方法, 按照wiki.postgresql.org指导,使用service postgresql-9.6 initdb进行初始化工作,此参数的具体明细,可查看/etc/init.d/postgresql-9.6脚本,其中变量PGDATA为data保存位置,PGLOG为日志保存位置,可以修改脚本满足自己需要。
  2. 使用initdb参数时, 获取$LANG为字符格式, 新建了数据目录, 修改了目录访问权限与读写权限, 初始化了启动日志.
  3. 最后,执行的命令为SU -l postgres -c "initdb --pgdata='data_path' --auth='ident' $LANG".
  4. 这种方式执行的数据库启动后,是不知道postgres用户的密码,需要进入psql进行更改(切换至psotgres用户并执行psql命令不需要密码)
  5. initdb的详细参数是可参考/usr/pgsql-9.6/share/man/man1/initdb.1, 仔细查看.
  6. 第二种方法,则是根据initdb手册, 按自己的需求进行数据库初始化.同时也需修改/etc/init.d/postgresql-9.6启动脚本PGDATA参数,才能开机启动服务.
    mkdir -p /opt/pgsql/9.6/data
    chown postgres.postgres /opt/pgsql/9.6/data
    su -l postgres -c "/usr/pgsql-9.6/bin/initdb --pgdata=/opt/pgsql/9.6/data --auth=ident --locale=en_US.UTF-8 --username=postgres -W"
    执行此命令前,需自己建立好目录,并有正确权限,否则会出错
initdb常用参数简介
  1. --auth= 设置pg_hba.conf文件中host与local的验证方法
  2. --auth-host --auth-local 同上,只是分别设置host与local
  3. -D --pgdata= 数据保存path, 可以自行设置PGDATA变量, 在安装时调用
  4. -E 编码方式
  5. --locale=
  6. -U --username= superuser用户名
  7. -W 提示输入密码
设置开机启动postgresql
chkconfig --level 235 postgresql-9.6 on

设置远程可以连接postgresql
  1. 修改数据目录下的postgresql.conf中
    listen_addresses = '*' 打开所有地址的IP地址监听
  2. 修改数据目录下的pg_hba.sql,添加
  3. # IPv4 local connections:
    host    all             all             192.168.13.0/24         md5
  4. 重启服务

认证方法如下:
"trust", "reject", "md5", "password", "gss", "sspi","ident", "peer", "pam", "ldap", "radius" or "cert".  注意"password"发送明文,"md5"发送加密

2017年5月9日星期二

keepass2与keepassx的比较

https://superuser.com/questions/878902/whats-the-difference-between-keepass-and-keepassx
这个站点做了很好的说明

You probably already know, but both KeePass and KeePassX are open source (published under the GNU General Purpose Licence 2) secure (using AES or Twofish) data storage programs, using a single database file to store (mainly) passwords, or pretty much any data you'd like e.g. user names, passwords, urls, attachments and comments.
KeePass was started about 2003, originally for Windows only, but now uses Mono to run on anything that Mono supports, like Mac OS X, Linux, FreeBSD...
KeePassX is an "Contributed/Unofficial KeePass Port" of KeePass that was started in 2005 (if the copyright notice on the bottom of their webpages is accurate) to run KeePass on Linux. It is now available as a native program for Linux, Windows, OS X, and others.
As the KeePassX homepage says:
Originally KeePassX was called KeePass/L for Linux since it was a port of Windows password manager Keepass Password Safe. After KeePass/L became a cross platform application the name was not appropriate anymore and therefore, on 22 March 2006 it has been changed [to KeePassX].

Currently, the biggest difference between KeePass & KeePassX seems to be the appearance and "feel" of each program, especially on Linux or Mac OS X where KeePassX doesn't rely on Mono, so matches the look of other native programs closer. And, KeePassX's version 0.4.x & 2.x display issues.
Also, KeePassX doesn't support plugins (there are several plugins for KeePass), as the user Grief points out in their answer so do upvote it too.

Screenshots of KeePassX "1.x"/(0.4.x) & "2.x", and KeePass2

These are on a Linux Mint 17 XFCE (Ubuntu 14.04 based) system. See this Ubuntu package search for keepass for what version's currently in what release:

KeePassX 0.4.3 (version 1.x compatible)

This version's in Ubuntu "Trusty Tahr" 14.04 LTS, and uses the KeePass v1.x database - AES/Rijndael or Twofish KeePassX 0.4 This is basically the same font & sizes as other windows, looks great & fits in. You can customize the columns & see the preview panel. Opening an entry to view/edit opens a new window: KeePassX 0.4 view entry

KeePassX 2.0.2

In Ubuntu 16.04 LTS & 16.10, using the KeePass v2.x database - AES/Rijndael only. KeePass2 normal view It uses the new database version 2.x, but you can't use TwoFish encryption, and it removes some display features like the preview panel (the bottom/right panel with details on the selected entry) and customizing columns. Viewing/editing an entry does not open a new window, it changes the whole KeePassX window into the view/edit window.
For some reason, it wouldn't let me resize the window to any smaller than this screenshot. Hopefully they'll add back the missing display features soon, but until then I'll stick with KeePassX 0.4.x.

KeePass 2.25 using Mono

In Ubuntu 14.04 LTS, there's a slightly higher version in 16.04 LTS & newer: enter image description here Visually very similar to KeePassX 0.4.3 but the font's different & smaller, just looks out of place. The preview panel's much more compact (like reading a .CSV file) and viewing/editing an entry opens a new window. It's got a side-by-side view too: KeePass2 side-by-sideAlso can NOT do somethings that the Windows version can like Export to KeePass version 1 formats: KeePass2 Not on Windows Error And has some display issues for me, like in this next image the key transformation rounds is actually 6003, but only the 6 is visible: KeePass2 Display Problems

Formerly, the current "main" KeePassX (0.4.3) only supported "the KeePass 1.x (Classic) password database format" But as of December 7, 2015, KeePassX version 2 has finally reached a stable release:
We’re proud to announce the first stable release of the KeePassX 2 series after several years of development.
KeePassX 2.0 is using the new .kdbx (same as KeePass 2) database format.
You can import your .kdb database from 0.4 from the Database > Import KeePass 1 database.
This is a one-way process though. You can’t migrate back to the .kdb format.
New features include:
  • Multiple attachments per entry
  • Add custom key/value pairs to entries
  • Open multiple database in one window
And the page "KeePass Edition Comparison" is probably helpful to differentiate versions 1 and 2.
It compares around 50 different aspects, copying them all here would be unnecessary, so I'll just paste a few of the differences, features that KeePass 1.x do NOT have, compared to KeePass 2.x. Many of these look very Windows-centered:
Full Unicode Support, Enhanced High DPI Support, Windows User Account, One-Time Passwords (as a plugin), Enter Master Key on Secure Desktop, Custom String Fields, Internal Attachment Viewer/Editor, Entry History, Import External Icons, Group Notes, Show Entries of Sub-Groups, Recycle Bin, Entry Tags, Grouped Results, Sort Search Results, Auto-Type TCATO, Pick Characters, Export To XSL-Transformed, Import from "More than 35 formats (see Help: Import)", Open Database via URL (FTP, HTTP, WebDAV, SCP, SFTP, FTPS), Shared Database Editing (Office-style locking), Synchronization, Scripting, Trigger System.
And, KeePass 1.x supports the Rijndael & Twofish Encryption Algorithms. KeePass 2.x only uses Rijndael.
See the linked Comparison page above for more info, & some description.

2017年5月6日星期六

mint 18.1 qqlight安装

1:安装winehq
sudo dpkg --add-architecture i386
get key https://dl.winehq.org/wine-builds/Release.key
install key sudo apt-key add Release.key
添加源 sudo apt-add-repository 'deb https://dl.winehq.org/wine-builds/ubuntu/ xenial main'(mint)
sudo apt update
sudo apt install winehq-devel

2:安装cabextract
sudo apt install cabextract

3:下载winetricks
wget  https://raw.githubusercontent.com/Winetricks/winetricks/master/src/winetricks
chmod 755 winetricks
sudo mv winetricks /usr/bin/

4:下载qqlight.verb
https://github.com/hillwoodroc/winetricks-zh
wget https://raw.githubusercontent.com/hillwoodroc/winetricks-zh/master/verb/qqlight.verb

5:安装qqlight
winetricks qqlight.verb

6:中间会下载多个文件,如果发现文件缺失,自行下载并放到指定目录

7:修改快捷方式
右键kde,edit application, 增加item
Exec=env WINEPREFIX=/home/wangzili/.local/share/wineprefixes/qqlight wine "C:\\Program Files (x86)\\Tencent\\QQLite\\Bin\\QQScLauncher.exe"

2017年4月25日星期二

Linux Mint 安装后的二三事

最近使用的Ubuntu16.04经常报错,又不想花时间去解决,又因最近一次Gnome的安装,系统无法进入桌面,一气之下安装了Mint,总结如下
  1. 系统安装不再叙述;
  2. 输入法
  • 安装fcitx fcitx-table-wbpy qt4-qtconfig fcitx-frontend-qt4 kde-config-fcitx fcitx-ui-classic
  • 使用im-config配置输入法
  • 使用fcitx-config配置输入法
  • 使用qt4 settings配置输入法
  1.  安装shadowsockets-qt5
  • sudo add-apt-repository ppa:hzwhuang/ss-qt5
  • sudo apt update
  • sudo apt install shadowsocks-qt5
  1. 设置tmpfs
  • 设置虚拟盘, 修改/etc/fstab 此方案不可行
  • 参见https://forums.linuxmint.com/viewtopic.php?t=237543
  • sudo cp /usr/share/systemd/tmp.mount /etc/systemd/system/
  • sudo systemctl enable tmp.mount
  • Reboot