Skip to content

Instantly share code, notes, and snippets.

@fjrti
fjrti / cidr.py
Created August 30, 2020 08:34
cidr list
# -*- coding: utf-8 -*-
from netaddr import IPNetwork
import click
@click.command()
@click.argument('cidr')
@click.option('--seperator', '-s', default=',', help='List seperator.')
@click.option('--file', '-f', default=False, help='txt file output path.')
@click.option('--range/--no-range', default=False, help='Output first and last IP Addresses')
@fjrti
fjrti / qemu-vm
Created January 3, 2021 14:07
qemu
#!/bin/sh
#if use drive which if=ide, set root to /dev/sda1
#if use drive which if=virtio, set root to /dev/vda1
P9PATH=~/work/xxxx-repo/xxxx/test
~/work/qemu-run-arm64/qemu/aarch64-softmmu/qemu-system-aarch64 \
-s -cpu cortex-a57 -machine virt \
-trace enable=wd_dummy_v2_* \
#!/bin/bash
vip=172.21.15.128
stime=15
run_wrk_short() {
echo "==== short connection: with $1 task, $2 connection =="
wrk2 -H "Connection: Close" -t $1 -c $2 -d 30s -R 30000 http://$vip --latency
sleep $stime
}
@fjrti
fjrti / tetris.sh
Last active February 20, 2022 01:41
#!/bin/bash
APP_NAME="${0##*[\\/]}"
APP_VERSION="1.0"
#颜色定义
iSumColor=7 #颜色总数
cRed=1 #红色
cGreen=2 #绿色
cYellow=3 #×××
@fjrti
fjrti / iptables.txt
Created March 22, 2021 12:04
iptables.txt
# Generated by iptables-save v1.6.1 on Mon Oct 26 11:55:22 2020
*raw
:PREROUTING ACCEPT [5751065:1174679472]
:OUTPUT ACCEPT [5736441:1152388541]
:CILIUM_OUTPUT_raw - [0:0]
:CILIUM_PRE_raw - [0:0]
-A PREROUTING -m comment --comment "cilium-feeder: CILIUM_PRE_raw" -j CILIUM_PRE_raw
-A OUTPUT -m comment --comment "cilium-feeder: CILIUM_OUTPUT_raw" -j CILIUM_OUTPUT_raw
-A CILIUM_OUTPUT_raw -o lxc+ -m mark --mark 0xa00/0xfffffeff -m comment --comment "cilium: NOTRACK for proxy return traffic" -j NOTRACK
-A CILIUM_OUTPUT_raw -o cilium_host -m mark --mark 0xa00/0xfffffeff -m comment --comment "cilium: NOTRACK for proxy return traffic" -j NOTRACK
#!/bin/bash
ISO=GoboLinux-016.01-x86_64.iso
IMG=sda.img
OUTIFACE=wlan0
NETWORK_OPTS="-net nic,macaddr=E0:06:E6:CE:FF:EE,model=virtio -net tap,ifname=tap1,script=no"
KVM_OPTS="-enable-kvm -cpu host -daemonize"
BOOT_DRIVE="$1"
@fjrti
fjrti / service.yaml
Created August 11, 2021 13:11
k8s service yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-dp
labels:
app: nginx
spec:
replicas: 2
selector:
matchLabels:
# 重置kubeadm
echo "----------------重置系统环境--------------------"
sudo kubeadm reset
# 重置iptables
iptables -F && iptables -t nat -F && iptables -t mangle -F && iptables -X
sudo sysctl net.bridge.bridge-nf-call-iptables=1
# 重置网卡信息
sudo ip link del cni0
#! /bin/bash
# Usage: ./who_is_listening.sh <PORT>
echo "What process is listening to $1"
lsof -nP -i4TCP:$1 | grep LISTEN
#! /bin/bash
# Usage: ./who_is_listening.sh <PORT>
echo "What process is listening to $1"
lsof -nP -i4TCP:$1 | grep LISTEN