stelnet 192.168.99.1 22 #登录其他设备ssh
display logbuffer #查看缓冲日志
display fib slot 3 #查看板卡FIB
display memory #查看内存
display ip routing-table vpn-instance vrf1 #查看vrf路由表
display ip routing-table #查看默认路由表
display bgp peer #查看bgp peer
display bgp routing-table 1.0.0.0 #查看1.0.0.0 的路由信息
display bgp routing-table community #查看路由表的community
display bgp routing-table regular-expression 174 #正则匹配as的路由表
display bgp routing-table regular-expression ^174_ #正则匹配as174开头的路由表
display bgp routing-table regular-expression _174$ #正则匹配as174结尾的路由表
display bgp routing-table regular-expression _(4808|4837|9929|10099) #正则匹配联通as的路由表
display bgp routing-table regular-expression _(4134|4809_4134) #正则匹配电信as的路由表
display bgp routing-table peer X.X.X.X accepted-routes #查看bgp邻居收到的路由表
display bgp routing-table peer X.X.X.X advertised-routes #查看bgp邻居发出的路由表
display bgp ipv6 routing-table #查看路由表
display bgp ipv6 peer #查看ipv6 bgp session
display bgp ipv6 routing-table peer XX:XX:XX advertised-routes #查看IPv6 bgp邻居发出的路由表
display interface brief #查看端口状态
display interface GigabitEthernet0/3/0 #查看端口信息,例如spf光信号等
#设置vrf
#
ip vpn-instance vrf1
ipv4-family
route-distinguisher 999:2
apply-label per-route
ip direct-routing-table route-policy HE-IN
vpn-target 999:2 export-extcommunity
vpn-target 999:2 import-extcommunity
#
bgp 999
ipv4-family vpn-instance Local_SG
import-route direct
import-route static
import-route ospf 100
active-route-advertise
ext-community-change enable
import-rib public route-policy HE-IN
peer X.X.X.X as-number 888
peer X.X.X.X timer keepalive 10 hold 180
peer X.X.X.X password simple PASSWORD
peer X.X.X.X route-policy IX-IN import
peer X.X.X.Xroute-policy IX-ipv4-out export
#
ip route-static vpn-instance vrf1 <目的网络> <目的子网掩码> <下一跳地址> #设置ip段vrf出口
有时候跑一个长期运行的命令, 或者突然掉线重新连接后进程还在需要把进程调出来继续执行,
或者是将现有的进程丢进screen里面继续后台运行.
这时候reptyr就派上用场了
yum install reptyr -y
reptyr -T 进程PID
现在用snap商店安装软件越来越频繁了, 而且众多linux发行版都支持了.
sudo yum install snapd
sudo systemctl enable --now snapd.socket
sudo systemctl start snapd.socket
sudo ln -s /var/lib/snapd/snap /snap
export PATH="$PATH:/snap/bin"
echo 'export PATH="$PATH:/snap/bin"' >> $HOME/.bashrc
安装一个 flutter压压惊
sudo yum install epel-release -y
sudo yum install clang cmake ninja-build pkgconfig gtk3-devel xz-devel gtk3-devel -y
snap install flutter --classic
yum install epel-release -y
yum install doxygen -y
git clone https://github.com/BYVoid/OpenCC.git
cd OpenCC
make
sudo make install
git clone https://github.com/nauxliu/opencc4php
cd opencc4php
phpize
./configure
make && sudo make install
echo extension=opencc.so >> /opt/php7/etc/php.d/1-opencc.ini
composer载入php-opencc
composer require overtrue/php-opencc -vvv
swapoff /dev/vda2;
mkswap /dev/vda2;
swapon /dev/vda2;
resize2fs /dev/vda1;
yum -y update;systemctl disable guestfs-firstboot;
rebootp
1. kvm运行Centos9/almalinux-9 出现kernel panic , 改qemu的cpu模式为 host-model 解决 (前两年其实就踩过了没记录给忘记了)
2.系统模版封装
下载转换qcow2为raw
qemu-img convert centos9-stream.qcow2 centos9-stream.raw
#挂载修改文件
kpartx -av centos9-stream.raw
mount /dev/mapper/loop0p2 /mnt
umount /mnt
#### 咔咔咔一顿更改设置
#这里直接先安装一个现有的操作系统, 然后dd写入分区文件,(主要是懒不想去自己封装系统,拿现成的)
kpartx /dev/mapper/vg0-kvmXXXX_img
dd_rescue /dev/mapper/loop0p2 /dev/mapper/vg0-kvmXXXX_img1
mount --bind /dev /mnt/dev
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
chroot /mnt
grub2-install /dev/sdXXXXX #重写引导信息
exit
rm -r /mnt/root/.bash_history #删除操作记录
umount /mnt/dev
umount /mnt/proc
umount /mnt/sys
umount /mnt/
kpartx -dv /dev/mapper/vg0-kvmXXXX_img
/scripts/kvmtemplate --generation=2 --mode=package --vmid=kvmXXXX #重新打包模版
cloudinit 转solusvm 模版偷梁换柱完事
solusvm官方没更新模版了, 这次给遗留的机器加上最新系统的模版
由于给files.gallery开了全部权限, 防止文件泄露针对location /进行了限制访问.
server {
server_name gallery.XX.net;
index index.php;
root /home/gallery/web;
location =/ {}
location / { deny all;}
location /.well-known/acme-challenge/ { return 200; }
location ~ \.php(?:$|/) {
try_files $uri = 404;
fastcgi_pass unix:/dev/shm/php8-fpm.sock;
}
}
设定ssl证书
dnf install epel-release -y
dnf install certbot python3-certbot-nginx -y
certbot --nginx -d XXX.net --agree-tos -m [email protected]
echo "0 3 * * 6 /usr/bin/certbot renew --quiet"> /etc/cron.d/certbot
主要两个地方注意一下, cloudflare会传送一个CF-Connecting-IP的header参数为访客的真实ip,所以 read_ip读取它.
然后设定REMOTE_ADDR读取IP, 可以从FORWARDED也可以用CF-Connecting-IP参数
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22;
set_real_ip_from 104.16.0.0/12;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 131.0.72.0/22;
set_real_ip_from 141.101.64.0/18;
set_real_ip_from 162.158.0.0/15;
set_real_ip_from 172.64.0.0/13;
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 188.114.96.0/20;
set_real_ip_from 190.93.240.0/20;
set_real_ip_from 197.234.240.0/22;
set_real_ip_from 198.41.128.0/17;
real_ip_header CF-Connecting-IP;
proxy_set_header REMOTE_ADDR $HTTP_X_FORWARDED_FOR;
yum install snmp -y
cat>/etc/snmp/snmpd.conf<<EOF
sysLocation Sitting on the Dock of the Bay
sysContact Me <[email protected]>
sysServices 72
master agentx
view systemview included .1.3.6.1.2.1
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1
view systemview included .1.3.6.1.2.1.2.2.1.1
view systemonly included .1.3.6.1.2.1.1
view systemonly included .1.3.6.1.2.1.25.1
view systemview included .1.3.6.1.2.1.2.2.1
rocommunity public1611 default
rocommunity6 public1611 default -V systemonly
createUser snmpname SHA "123pwd" AES "123pwd"
rouser snmpname
usmSecurityLevel authPriv
usmUser snmpname - SHA "123pwd" AES "123pwd"
com2sec readonly default public1611
group MyROGroup v2c readonly
view all included .1 80
access MyROGroup "" any noauth exact all none none
rocommunity public1611
agentaddress udp:127.0.0.1:16100
EOF
Import Color Scheme into iTerm2:
- Open iTerm2.
- Go to
iTerm2 -> Preferences -> Profiles.
- In the
Colors tab, you will see a Color Presets dropdown. Open it.
- At the bottom of the dropdown, you'll find
Import...
https://raw.githubusercontent.com/mbadolato/iTerm2-Color-Schemes/master/schemes/Solarized%20Dark%20Higher%20Contrast.itermcolors
wget $(curl -s https://api.github.com/repos/ehang-io/nps/releases/latest | grep -oP '"browser_download_url": "\Khttps://[^"]+')
把ehang-io/nps换成你要的github ID和项目地址.
apt update
apt install -y build-essential autoconf automake pkg-config libtool cmake clang -y
apt install -y php8.1-dev php8.4-cli php8.4-common -y
apt install -y libssl-dev libcurl4-openssl-dev libpq-dev libsqlite3-dev libzstd-dev libbrotli-dev liburing-dev libssl-dev -y
git clone https://github.com/swoole/swoole-src.git && cd swoole-src
/usr/bin/phpize8.4
./configure \
--with-php-config=/usr/bin/php-config8.4 \
--enable-swoole \
--enable-sockets \
--enable-mysqlnd \
--enable-swoole-curl \
--enable-swoole-pgsql \
--enable-swoole-sqlite \
--enable-swoole-stdext \
--enable-zstd \
--enable-brotli \
--enable-uring-socket
make && make install
echo extension=swoole.so >/etc/php/8.4/cli/conf.d/20-swoole.ini
systemctl服务
[Unit]
Description=Swoole HTTP Server
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
ExecStart=/usr/bin/php /opt/start.php start swoole
ExecReload=/bin/kill -USR1 $MAINPID
# 自动重启策略
Restart=always
RestartSec=3
# 防止僵尸进程
KillMode=process
KillSignal=SIGTERM
TimeoutStopSec=30
# 资源限制
LimitNOFILE=1048576
LimitNPROC=65535
# 日志
StandardOutput=journal
StandardError=journal
User=www-data
Group=www-data
[Install]
WantedBy=multi-user.target
api.exchangerate.host 的API不能白嫖了, 找了个新的汇率接口api.vatcomply.com
原有代码
function exchange($from, $to)
{
try {
$result = file_get_contents('https://api.exchangerate.host/latest?symbols=' . $to . '&base=' . $from);
$result = json_decode($result, true);
return $result['rates'][$to];
} catch (Exception $e){
echo "Exchange error: ".$e;
return "Exchange error: ".$e;
}
}
更新后
function exchange($from, $to)
{
try {
$result = file_get_contents('https://api.vatcomply.com/rates?base='. $from);
$result = json_decode($result, true);
return $result['rates'][$to];
} catch (Exception $e){
echo "Exchange error: ".$e;
return "Exchange error: ".$e;
}
}
Segmentation fault
E: Sub-process /usr/bin/apt-listchanges --apt || test $? -lt 10 returned an error code (1)
E: Failure running script /usr/bin/apt-listchanges --apt || test $? -lt 10
修改/etc/apt/apt.conf.d/20listchanges文件,注释掉第一行.
#DPkg::Pre-Install-Pkgs { "/usr/bin/apt-listchanges --apt || test $? -lt 10"; };
先准备一个U盘格式化为FAT32格式
将bin pkg license等文件复制到设备上
enable
cd usb0:
dir
copy usb0:/XXXXX.SPA.bin bootflash:
copy usb0:/XXXXX.SPA.pkg bootflash:
copy usb0:/license.txt flash:
license smart reservation install file flash:license.txt
>conf t
#upgrade rom-monitor filename bootflash:XXXXX.SPA.pkg all
#no boot system flash bootflash:OLD_XXXXX.SPA.bin
#boot system flash bootflash:XXXXX.SPA.bin
#platform hardware throughput level 3500000
#do wr
#do show bootvar
#reload
智能许可: 16.9到最新的17.X所有版本
传统许可: 16.9和更低的版本
新版本用的是license smart , 以前的授权文件无法再使用, 所以要写入新签发的授权数据.