2024年10月

MySQL 8.0开始将caching_sha2_password作为默认的身份验证插件.
MariaDB 10.3 支持unix_socket、mysql_native_password认证插件。

mariadb 10.3 root 用户默认认证方式为unix_socket,在本地不需要密码直接登录。
更改认证方式:
UPDATE user SET plugin='unix_socket' WHERE User='root';
UPDATE user SET plugin='mysql_native_password' WHERE User='root';
flush privileges;

Mikrotik开局配置
一、LAN口桥接
1:添加桥接
/interface bridge add name=lan
2:把端口加到桥接
/interface bridge port add interface=ether2 bridge=lan
/interface bridge port add interface=ether3 bridge=lan
/interface bridge port add interface=ether4 bridge=lan
3:创建VLAN
/interface vlan add name=vlan2001 interface=lan vlan-id=2001
/interface vlan add name=vlan2002 interface=lan vlan-id=2002
二、IP地址和路由配置
1:添加内网IP地址添加到接口(也可以是VLAN)
/ip address add address=172.16.99.254 24 interface=lan
/ip address add address=10.10.1.254 24 interface=vlan2001
/ ip address add address=10.10.2.254 24 interface=vlan2001
2:添加外网IP地址到接口
/ip address add address=192.168.51.101 24 interface=ether1
/ip address add address=192.168.51.102 24 interface=ether1
3:添加默认网关到路由表
/ip route add dst-address=0.0.0.0 0 gateway=192.168.51.254
4:设置DNS
/ip dns set servers=8.8.4.4,8.8.8.8
三、添加NAT
1:添加客户上网用NAT

/ip firewall nat add chain=srcnat action=masquerade
/ip firewall nat add chain=srcnat src-address=10.10.2.0 24 action=src-nat to-addresses=192.168.51.102
2:添加远程管理内部设备用NAT
/ip firewall nat add chain=dstnat dst-address=192.168.51.101 dst-port=9901 protocol=tcp action=dst-nat to-addresses=172.16.99.1 to-ports=80
四、添加DHCP
1:添加IP地址池
/ip pool add name=vlan2001 ranges=10.10.1.1-10.10.1.253
/ip pool add name=vlan2002 ranges=10.10.2.1-10.10.2.253
2:添加DHCP服务器
/ip dhcp-server add name=vlan2001 interface=vlan2001 address-pool=vlan2001
/ip dhcp-server add name=vlan2002 interface=vlan2002 address-pool=vlan2002
3:添加DHCP分配网络信息
/ip dhcp-server network add address=10.10.1.0 24 gateway=10.10.1.254 dns-server=10.10.1.254,8.8.4.4
/ip dhcp-server network add address=10.10.2.0 24 gateway=10.10.2.254 dns-server=10.10.2.254,8.8.4.4

windows server 2022 core
安装OpenSSH Server服务器
Get-WindowsCapability -Online | ? Name -like 'OpenSSH*'

Add-WindowsCapability -Online -Name OpenSSH.Server
Set-Service -Name sshd -StartupType ‘Automatic’
Start-Service sshd

WebAdministration IISAdministration
首先要导入IIS管理模块WebAdministration
Import-Module WebAdministration
执行下面命令进入IIS命令行
IIS:
可以执行dir查看AppPools、Sites、SslBindings信息

微软案例:
https://learn.microsoft.com/zh-cn/iis/manage/powershell/powershell-snap-in-creating-web-sites-web-applications-virtual-directories-and-application-pools

新建应用程序池 api.dd.com

New-Item iis:\AppPools\api.dd.com
Set-ItemProperty iis:\AppPools\api.dd.com managedRuntimeVersion v4.0 #更改应用程序池版本为4.0,默认为2.0(Windows Server 2008 R2)

新建站点 api.dd.com,主机头为 api.dd.com,路经为 d:\apidd

New-Item iis:\Sites\api.dd.com -bindings @{protocol="http";bindingInformation=":80:api.dd.com"} -physicalPath d:\apidd
new-item test

为站点 api.dd.com 添加主机头 imageapi.dd2.com

New-WebBinding -Name "api.dd.com" -IPAddress "*" -Port 80 -HostHeader imageapi.dd2.com

为站点 api.dd.com 更改应用程序池为 api.dd.com

Set-ItemProperty IIS:\Sites\api.dd.com -name applicationPool -value api.dd.com

在站点api.dd.com下新建应用程序cust_account_api ,目录为D:\cust_account_api_new

new-item iis:\sites\api.dd.com\cust_account_api -type Application -physicalpath D:\cust_account_api_new
Set-ItemProperty IIS:\Sites\api.dd.com\cust_account_api -name applicationPool -value api.dd.com

在站点ServerLog下新建虚拟目录cust_account_api ,目录为D:\cust_account_api_new\log

new-item D:\cust_account_api_new\log -type directory -force
new-item iis:\sites\ServerLog\cust_account_api -type VirtualDirectory -physicalpath D:\cust_account_api_new\log

新建IISLog站点

New-Website -Name IISLog -Port 11001 -PhysicalPath "D:\IISLog"
New-WebVirtualDirectory -Site IISLog -Name APPLog -PhysicalPath D:\APPLog
New-WebVirtualDirectory -Site IISLog -Name SystemLog -PhysicalPath C:\Windows\System32\Winevt\Logs

更改IIS站点的物理路径:

Set-ItemProperty "iis:\sites\Default Web Site" -Name physicalpath -Value "c:\inetpub"

使用appcmd.exe:

New-Alias -name appcmd -value $env:windir\system32\inetsrv\appcmd.exe

这样就可以在当前PS环境下直接使用appcmd了

get-website

备份/还原单个站点:

1.appcmd add backup
2.remove-website|?{$_.name -ne "sitename"}

$webclient = New-Object Net.WebClient
$webclient.DownloadString("http://localhost");

在ubuntu 20.04 中,默认已经开启了dns缓存服务,由systemd-resolv服务提供dns缓存服务。

它监听127.0.0.53:53端口。

systemd-resolv服务直接管理/etc/resolv.conf文件,所以直接修改/etc/resolv.conf是无效的。

可以修改systemd-resolv服务的配置文件/etc/systemd/resolved.conf中的DNS值。

也可以修改网络配置文件/etc/netplan/00-installer-config.yaml 中的nameservers

  1. 统计某个IP访问的时间$4、页面$7
    awk '/66.249.66.164/ {a[$1]++;print a[$1] ,$1,$4,$7}' access.log

1.统计访问IP次数:
awk '{a[$1]++}END{for(v in a)print v,a[v]}' access.log

2.统计访问访问大于100次的IP:
awk '{a[$1]++}END{for(v in a){if(a[v]>100)print v,a[v]}}' access.log

3.统计访问IP次数并排序取前10:
awk '{a[$1]++}END{for(v in a)print v,a[v]|"sort -k2 -nr |head -10"}' access.log

4.统计时间段访问最多的IP:
awk '$4>="[02/Jan/2017:00:02:00" && $4<="[02/Jan/2017:00:03:00"{a[$1]++}END{for(v in a)print v,a[v]}' access.log

5.统计上一分钟访问量:
date=$(date -d '-1 minute' +%d/%d/%Y:%H:%M)
awk -vdate=$date '$4~date{c++}END{print c}' access.log

6.统计访问最多的10个页面:
awk '{a[$7]++}END{for(v in a)print v,a[v]|"sort -k1 -nr|head -n10"}' access.log

7.统计每个URL数量和返回内容总大小:
awk '{a[$7]++;size[$7]+=$10}END{for(v in a)print a[v],v,size[v]}' access.log

8.统计每个IP访问状态码数量:
awk '{a[$1" "$9]++}END{for(v in a)print v,a[v]}' access.log

9.统计访问IP是404状态次数:
awk '{if($9~/404/)a[$1" "$9]++}END{for(i in a)print v,a[v]}' access.log