树莓派空中串口透传工具

树莓派空中串口透传工具

快速安装:在命令行执行

wget -qO- https://tech.biko.pub/resource/rpi-ws-uart-setup.sh | sudo bash


源码仓库:

https://github.com/hardcore-rpi/pilib/tree/main/packages/ws-uart




# 默认参数启动
sudo pilib-ws-uart
# 指定参数启动
sudo PORT=8081 UART_COM='/dev/ttyUSB1' UART_BAUD_RATE=9600 pilib-ws-uart


==========



# curl  https://tech.biko.pub/resource/rpi-ws-uart-setup.sh
#!/bin/bash

set -e

echo "开始安装树莓派空中串口 pilib-ws-uart"

if ! command cnpm &> /dev/null
then
  npm install -g cnpm --registry=https://registry.npm.taobao.org
fi

cnpm i pilib-ws-uart -g

echo "[电气罐头] 树莓派空中串口 pilib-ws-uart 安装完成"
echo "使用文档:https://tech.biko.pub/#/posts/rpi-ws-uart"


CentOS8切换到Stream

用yum和dnf都可以直接操作.

dnf install centos-release-stream
dnf distro-sync
cat /etc/centos-release

邮件迁移合并工具

imapsync

yum -y -q install imapsync
    imapsync --host1 mail.gmail.com     \
         --user1 [email protected] \
         --password1 passwordold   \
         --host2 mail.newhost.com  \
         --user2 [email protected] \
         --password2 passwordnew \
         --ssl1  \
         --ssl2


getmail

yum -y -q install getmail
mkdir -p  /root/.getmail/maildir/{new,cur,tmp}

cat>/root/.getmail/getmailrc.buddha<<EOF
[retriever]
type = SimplePOP3Retriever
server = pop.qq.com #如果是gmail则改为pop.gmail.com
username = budda
password = password

[destination]
type = Maildir
path = ~/.getmail/maildir/ #就是刚才在~/.getmail/建立的目录,注意该目录下一定要有new,cur,tmp这三个子目录

[options]
read_all = False #只接受以前没有收取的邮件,如果改成True则收取邮箱中所有邮件
delete = False #下载邮件后不在服务器上删除该邮件,如果改成True则删除
EOF


getmail --rcfile=getmailrc.buddha


思科路由命令备忘稿:Cisco BGP常用show命令

show ip bgp  regexp ^6939
show ip bgp neighbors 100.64.163.1
show ip bgp neighbors 100.64.163.1 advertised-routes


Cisco BGP常用show命令
1.常用的show 命令
查看BGP路由表
XRV8#show ip bgp all
For address family: IPv4 Unicast
BGP table version is 217, local router ID is 10.255.255.8
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
*> 10.33.0.0/19 0.0.0.0 32768 i
*> 10.33.1.0/24 0.0.0.0 0 32768 i
*> 10.33.2.0/24 0.0.0.0 0 32768 i
*> 10.33.3.0/24 0.0.0.0 0 32768 i
查看BGP邻居表
XRV8#show ip bgp summary 
BGP router identifier 10.255.255.8, local AS number 65002
BGP table version is 217, main routing table version 217
72 network entries using 10368 bytes of memory
76 path entries using 6080 bytes of memory
3/3 BGP path/bestpath attribute entries using 456 bytes of memory
1 BGP AS-PATH entries using 24 bytes of memory
0 BGP route-map cache entries using 0 bytes of memory
0 BGP filter-list cache entries using 0 bytes of memory
BGP using 16928 total bytes of memory
BGP activity 140/68 prefixes, 220/144 paths, scan interval 60 secs
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
10.201.1.1 4 65000 95 89 217 0 0 01:08:02 4
10.201.2.1 4 65000 86 90 217 0 0 01:01:00 4
查看路由表中的BGP路由
XRV8#show ip route bgp
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override
Gateway of last resort is not set
10.0.0.0/8 is variably subnetted, 141 subnets, 4 masks
B 10.33.0.0/19 [200/0], 01:07:50, Null0
B 10.63.0.0/19 [20/0] via 10.201.2.1, 00:14:30
B 10.79.0.0/19 [20/0] via 10.201.2.1, 00:14:30
B 10.118.0.0/19 [200/0], 01:07:50, Null0
B 10.123.0.0/19 [200/0], 01:07:50, Null0
B 10.133.0.0/19 [20/0] via 10.201.2.1, 00:14:30
B 10.149.0.0/19 [200/0], 01:07:50, Null0
B 10.158.0.0/19 [20/0] via 10.201.2.1, 00:14:30
 查看BGP路由含有某些特定路由的信息
XRV8#show ip route bgp | include 10.133.0.0
B 10.133.0.0/19 [20/0] via 10.201.2.1, 00:19:04
 查看含有某些前缀的BGP路由信息
XRV8#show ip bgp 10.133.0.0
BGP routing table entry for 10.133.0.0/19, version 216
Paths: (2 available, best #2, table default)
Not advertised to any peer
Refresh Epoch 4
65000 65001, (aggregated by 65001 10.255.255.7)
10.201.1.1 from 10.201.1.1 (10.255.255.5)
Origin IGP, localpref 100, valid, external, atomic-aggregate
rx pathid: 0, tx pathid: 0
Refresh Epoch 4
65000 65001, (aggregated by 65001 10.255.255.7)
10.201.2.1 from 10.201.2.1 (10.255.255.6)
Origin IGP, localpref 100, valid, external, atomic-aggregate, best
rx pathid: 0, tx pathid: 0x0
 查看某个特定的掩码区间的路由
XRV8#show ip bgp 10.133.0.0/16 longer-prefixes
BGP table version is 217, local router ID is 10.255.255.8
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
* 10.133.0.0/19 10.201.1.1 0 65000 65001 i
*> 10.201.2.1 0 65000 65001 i
 查看起源于某个特定AS的路由
XRV8#show ip bgp regexp 65001$
BGP table version is 217, local router ID is 10.255.255.8
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale, m multipath, b backup-path, f RT-Filter,
x best-external, a additional-path, c RIB-compressed,
Origin codes: i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found
Network Next Hop Metric LocPrf Weight Path
* 10.63.0.0/19 10.201.1.1 0 65000 65001 i
*> 10.201.2.1 0 65000 65001 i
* 10.79.0.0/19 10.201.1.1 0 65000 65001 i
*> 10.201.2.1 0 65000 65001 i
* 10.133.0.0/19 10.201.1.1 0 65000 65001 i
*> 10.201.2.1 0 65000 65001 i
* 10.158.0.0/19 10.201.1.1 0 65000 65001 i
*> 10.201.2.1 0 65000 65001 i


Cisco配置备忘稿

VRF

Usage Guidelines

This command is available for all IP-route tracked objects that are tracked by the track ip route global configuration command. Use this command to track a route that belongs to a specific VPN.

Examples

In the following example, the route associated with a VRF named VRF1 is tracked:

Router(config)# track 1 ip route 10.0.0.0 255.0.0.0 metric threshold
Router(config-track)# exit
Router(config)# ip vrf VRF1
Router(config-vrf)# rd 100:1
Router(config-vrf)# route-target both 100:1
!
Router(config)# interface ethernet0/2
Router(config-if)# no shutdown
Router(config-if)# ip vrf forwarding VRF1
Router(config-if)# ip address 10.0.0.2 255.0.0.0

Command

Description

ip vrf forwarding

Associates a VPN VRF with an interface or subinterface.

track ip route

Tracks the state of an IP route and enters tracking configuration mode.



ip tcp adjust-mss


  • ip tcp adjust-mss 1452

  • ip mtu 1492

Examples

The following example shows the configuration of a PPPoE client with the MSS value set to 1452:

vpdn enable
no vpdn logging
!
vpdn-group 1
request-dialin
protocol pppoe
!
interface Ethernet0
 ip address 192.168.100.1 255.255.255.0
 ip tcp adjust-mss 1452
 ip nat inside
!
interface ATM0
 no ip address
 no atm ilmi-keepalive
 pvc 8/35
 pppoe client dial-pool-number 1
!
dsl equipment-type CPE
dsl operating-mode GSHDSL symmetric annex B
dsl linerate AUTO
!
interface Dialer1
 ip address negotiated
 ip mtu 1492
 ip nat outside
 encapsulation ppp
 dialer pool 1
 dialer-group 1
 ppp authentication pap callin
 ppp pap sent-username sohodyn password 7 141B1309000528
!
ip nat inside source list 101 interface Dialer1 overload
ip route 0.0.0.0 0.0.0.0 Dialer1
access-list 101 permit ip 192.168.100.0 0.0.0.255 any



原文地址https://www.cisco.com/en/US/docs/ios-xml/ios/ipapp/command/ip_tcp_adjust-mss_through_ip_wccp_web-cache_accelerated.html

goflow(Netflow/IPFIX Collector)

go get github.com/cloudflare/goflow/cmd/goflow
cd ~/go/src/github.com/cloudflare/goflow/cmd/goflow
go install

goflow -kafka=false -nf -nf.addr 192.168.1.8 -nf.port 567

goflow -h
goflow -kafka=false -nf -nf.addr 192.168.1.8 -nf.port 5678


邮件系统收集整理

iRedMail


https://qing.su/article/158.html
香菇肥牛大佬写了些涨经验值的内容.


poste


https://poste.io/
基于docker的一个邮件投递系统

postal


   https://postal.atech.media/

https://github.com/postalhq/postal/wiki/Quick-Install
用来专门投递邮件这玩意不错的.

mailu


https://mailu.io/
https://github.com/Mailu/Mailu
mailu这玩意是基于docker运行的, 看起来好像不错, 还没搭建过,

Mail-in-a-Box

https://mailinabox.email/
https://github.com/mail-in-a-box/mailinabox
指定在ubuntu上部署, ubuntu18可以安装, 还算比较不错的.

postalserver

http://docs.postalserver.io
https://github.com/postalserver/postal

 


Zimbra和Modoboa好像还可以, 但还没搭建过.


未完待续

ESXI清空root密码

先挂一个rescue系统重启并进入,挂载/dev/sda5分区.

www.system-rescue-cd.org 可以下载, 用linux带rescue的iso也可以.


操作流程大致如下:

mkdir /mnt/sda5
mount /dev/sda5 /mnt/sda5
cp /mnt/sda5/state.tgz /tmp
cd /tmp
tar -xf state.tgz #(这一步对文件进行解压之后,会生成一个local.tgz的文件)
tar -xf local.tgz #(这一步操作结束后,tmp下会有一个etc目录)
vim etc/shadow   #(把root的密码删掉)
rm -f /tmp/state.tgz /tmp/local.tgz
tar -zcvf local.tgz etc/
tar -zcvf state.tgz local.tgz
cp state.tgz /mnt/sda5/


files.photo.gallery

演示地址:https://files.photo.gallery/demo/?samples

下载链接:https://cdn.jsdelivr.net/npm/files.photo.gallery/index.php

设置说明:https://forum.photo.gallery/viewtopic.php?f=66&t=9964

开心补丁:https://cdn.jsdelivr.net/gh/yyingc/[email protected]/files.js


php组建需求: fileinfo exif imagemagick


配置根目录、密码访问和排除不需要显示的目录:

// 根目录配置
'root' => '根目录路径', // root path relative to script.
'start_path' => false, // start path relative to script. If empty, root is start path
// 登录账号密码配置
'username' => 'zhujizixun',
'password' => '12345678', // Add password directly or use https://tinyfilemanager.github.io/docs/pwd.html to encrypt the password (encrypted password is more secure, as it prevents your password from being exposed directly in a file).
// 排除文件或者目录
'files_exclude' => '/.(html|xml)$/i', // '/.(pdf|jpe?g)$/i'
'dirs_exclude' => '//js|/_files(/|$)/i', //'//Convert|/football|/node_modules(/|$)/i',
'allow_symlinks' => true, // allow symlinks

whmcs的nginx伪静态规则

  location ~ /(announcements|knowledgebase|download|store|password|cart|account|subscription)(.*) { rewrite (.*) /index.php; }
  location ~ /(.*)/(addons|apps|search|domains|help|services|setup|utilities|clients)(.*) { rewrite (.*) /admin/index.php;}

方案一:

if (!-f $request_filename){ rewrite (.*) /index.php;  }

方案二:

 rewrite ^/(announcements|knowledgebase|download|store|password|cart|account|subscription)(.*)$ /index.php;

其他设置:

  location ~* \.(tpl|inc|cfg)$ {  deny all; }
  location ^~ /vendor/ { deny all; }


方案一主要匹配本地没有的就丢index.php上去,  也可以用try_files

方案二主要是直接进行rewrite.


其他配置主要是隐藏一些目录和文件不让访问.


 总的来说用 location来匹配稍微稳妥一些, 例如 /admin/clientsservices.php 会被为静态匹配到, 还是得运用if来判断匹配.

解决nocps的samba跨网速度慢的问题

smb跨网的速度慢到爆,  虽然可以在Installation profiles里面增加一个外带本地smb路径, 在能不改变就不改变的前提下解决.


在ROS里面把445,137,138,139的tcp和udp重新定向到网内的smb服务器ip上.

/ip firewall nat
add action=dst-nat chain=dstnat dst-address=远程SMB dst-address-type=!local dst-port=445,137,138,139 protocol=udp to-addresses=本地SMB
add action=dst-nat chain=dstnat dst-address=远程SMB dst-address-type=!local dst-port=445,137,138,139 protocol=tcp to-addresses=本地SMB

然后将nocps下smb目录文件同步出来, 先把nocps的smb挂载到本地目录然后用rsync进行同步, 然后再分发到其他区域的smb服务器.


其实能在路由上做nat的情况, 完全可以把smb单独出来分区域镜像跑, 但是我不太想去折腾了, 能省一步省一步.





BGP Regular Expressions Examples

Regular Expressions are used often for BGP route manipulation or filtering. In this lesson we’ll take a look at some useful regular expressions. First let’s take a look at the different characters that we can use:

Characters

?
repeats the previous character one or zero times.
*
repeats the previous character zero or many times.
+
repeats the previous character one or more times.
^
matches the beginning of a string.
$
matches the end of a string.
[]
is a range.
_
matches the space between AS numbers or the end of the AS PATH list.
\\
is an escape character. You’ll need this for BGP confederations.

Examples

^$matches an empty AS PATH so it will match all prefixes from the local AS.
^51_matches prefixes from AS 51 that is directly connected to our AS.
_51_matches prefixes that transit AS 51.
_51$matches prefixes that originated in AS 51, the $ ensures that it’s the beginning of the AS PATH.
^([0-9]+)_51matches prefixes from AS 51 where AS 51 is behind one of our directly connected AS’es.
^51_([0-9]+)matches prefixes from the clients of directly connected AS 51.
^(51_)+([0-9]+)matches prefixes from the clients of directly connected AS 51, where AS 51 might be doing AS PATH prepending.
^51_([0-9]+_)+matches prefixes from the clients of directly connected AS 51, where the clients might be doing AS PATH prepending.
^\65200\)matches prefixed from confederation peer 65200.

https://networklessons.com/bgp/bgp-regular-expressions-examples/

内网IP分配用途表

Address BlockPresent UseReference
0.0.0.0/8"This" NetworkRFC 1122, Section 3.2.1.3
10.0.0.0/8Private-Use NetworksRFC 1918
127.0.0.0/8LoopbackRFC 1122, Section 3.2.1.3
169.254.0.0/16Link LocalRFC 3927
172.16.0.0/12Private-Use NetworksRFC 1918
192.0.0.0/24IETF Protocol AssignmentsRFC 5736
192.0.2.0/24TEST-NET-1RFC 5737
192.88.99.0/246to4 Relay AnycastRFC 3068
192.168.0.0/16Private-Use NetworksRFC 1918
198.18.0.0/15Network Interconnect
Device Benchmark Testing
RFC 2544
198.51.100.0/24TEST-NET-2RFC 5737
203.0.113.0/24TEST-NET-3RFC 5737
224.0.0.0/4MulticastRFC 3171
240.0.0.0/4Reserved for Future UseRFC 1112, Section 4
255.255.255.255/32Limited BroadcastRFC 919, Section 7
RFC 922, Section 7

#---------------------- 










Summary Table

Address BlockPresent UseReference
0.0.0.0/8"This" NetworkRFC 1122, Section 3.2.1.3
10.0.0.0/8Private-Use NetworksRFC 1918
127.0.0.0/8LoopbackRFC 1122, Section 3.2.1.3
169.254.0.0/16Link LocalRFC 3927
172.16.0.0/12Private-Use NetworksRFC 1918
192.0.0.0/24IETF Protocol AssignmentsRFC 5736
192.0.2.0/24TEST-NET-1RFC 5737
192.88.99.0/246to4 Relay AnycastRFC 3068
192.168.0.0/16Private-Use NetworksRFC 1918
198.18.0.0/15Network Interconnect
Device Benchmark Testing
RFC 2544
198.51.100.0/24TEST-NET-2RFC 5737
203.0.113.0/24TEST-NET-3RFC 5737
224.0.0.0/4MulticastRFC 3171
240.0.0.0/4Reserved for Future UseRFC 1112, Section 4
255.255.255.255/32Limited BroadcastRFC 919, Section 7
RFC 922, Section 7

华为交换机常用命令


1. 查看接口的统计信息


* display interface命令用来查看接口当前运行状态和接口统计信息。

* display counters命令用来查看接口的流量统计计数。

* display counters error命令用来查看错误报文的统计信息。

* display counters rate命令用来查看接口的入方向或出方向流量速率。

* display counters top interface report用来显示接口流量TOP N的统计报告。

* display ip interface命令用来查看接口与IP相关的配置和统计信息,包括接口接收和发送的报文数、字节数和组播报文数,以及接口接收、发送、转发和丢弃的广播报文数。


2. 查看接口的状态


* display interface brief命令用来查看接口状态和配置的简要信息。

* display interface description命令用来查看指定接口的描述信息。

* display interface ethernet brief命令用来查看以太网接口的简要信息。

* display ip interface brief和display ip interface description命令用来查看接口与IP相关的简要信息,包括IP地址、子网掩码、物理链路和协议的Up/Down状态以及处于不同状态的接口数目。


3. 查看光功率和模块型号


* display interface interface-type interface-number查看某光口插入的光模块的信息。

* display transceiver diagnosis interface查看所有光口的收发光功率信息。

* display transceiver diagnosis interface interface-type interface-number查看某光口的收发光功率信息。


hex dec ip

#!/bin/bash
dec2ip () {
    local ip dec=$@
    for e in {3..0}
    do
        ((octet = dec / (256 ** e) ))
        ((dec -= octet * 256 ** e))
        ip+=$delim$octet
        delim=.
    done
    printf '%s\n' "$ip"
}

dec2ip "$@"
#!/bin/bash
ip2dec () {
    local a b c d ip=$@
    IFS=. read -r a b c d <<< "$ip"
    printf '%d\n' "$((a * 256 ** 3 + b * 256 ** 2 + c * 256 + d))"
}

ip2dec "$@"
dec2ip ()
{
   local v=$1
   local i1=$((v>>24&255))
   local i2=$((v>>16&255))
   local i3=$((v>>8&255))
   local i4=$((v&255))
   printf '%d.%d.%d.%d\n' $i1 $i2 $i3 $i4
}


tohex

echo -n   10.0.14.5  | hexdump -e '/1 "%02x"';

ip2hex

gethostip -x 10.0.14.5

hex2ip

hextoip() { hex=$1;  printf "%d." 0x${hex:0:2};  printf "%d." 0x${hex:2:2};  printf "%d." 0x${hex:4:2};  printf "%d" 0x${hex:6:2};  }