Skip to content

Instantly share code, notes, and snippets.

View raphaunix's full-sized avatar
🦡
I may be slow to respond.

raphaunix

🦡
I may be slow to respond.
View GitHub Profile
@raphaunix
raphaunix / device_state.sh
Last active October 8, 2021 17:08
Quick adjustment
#!/bin/sh
set -u
ECHO=/bin/echo
GREP=/bin/grep
CUT=/usr/bin/cut
CAT=/bin/cat
MOUNTPOINT=/bin/mountpoint
LSBLK=/bin/lsblk
@raphaunix
raphaunix / s.sh
Last active October 17, 2019 20:39
s.sh
#!/bin/sh
# Usage:
# sudo su -c 'wget -O- https://gist.githubusercontent.com/raphaunix/008199de5b728f963b1379ff14e7e177/raw/s.sh | sudo bash -s'
# sudo su -c 'curl -s https://gist.githubusercontent.com/raphaunix/008199de5b728f963b1379ff14e7e177/raw/s.sh | bash -s --'
set -eu
clear
CRED='\e[1m\e[31m'
CEND='\e[0m\e[0m'
iptables -I INPUT -p tcp -m tcp --dport 7308 -m state --state NEW -j LOG --log-level 1 --log-prefix "New Connection "
tail -f syslog | awk -F'SRC=' '{print $2}' | awk -F' ' '{print $1}'
yum update
error: rpmdb: BDB0113 Thread/process 22428/140499342686208 failed: BDB1507 Thread died in Berkeley DB library
error: db5 error(-30973) from dbenv->failchk: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery
error: cannot open Packages index using db5 - (-30973)
error: cannot open Packages database in /var/lib/rpm
CRITICAL:yum.main:
[SOLVED]
sudo rm -f /var/lib/rpm/__db* && db_verify /var/lib/rpm/Packages && rpm --rebuilddb && yum clean all && yum update
@raphaunix
raphaunix / SELinux Centos
Created November 7, 2017 02:12
[SOLVED] - "Job for zabbix-agent.service failed because a configured resource limit was exceeded. See "systemctl status zabbix-agent.service" and "journalctl -xe" for details."
"Job for zabbix-agent.service failed because a configured resource limit was exceeded. See "systemctl status zabbix-agent.service" and "journalctl -xe" for details."
[SOLVED]
sudo setenforce 0
fallocate -l 4G /swapfile && chmod 600 /swapfile && mkswap /swapfile && swapon /swapfile && swapon -s && printf "%s\n" "/swapfile none swap sw 0 0" >> /etc/fstab && cat /etc/fstab
Checking the number of login attempts coming from an ip:
debian/ubuntu:
cat /var/log/auth.log | grep -o '[0-9]\{0,3\}\.[0-9]\{0,3\}\.[0-9]\{0,3\}\.[0-9]\{0,3\}' | cut -d " " -f 1 | sort | uniq -c | sort -unr
rhel/centos:
cat /var/log/secure | grep -o '[0-9]\{0,3\}\.[0-9]\{0,3\}\.[0-9]\{0,3\}\.[0-9]\{0,3\}' | cut -d " " -f 1 | sort | uniq -c | sort -unr
Dropping ip attacker with iptables:
iptables -I INPUT -s IPATTACKER -j DROP && service iptables restart && clear; iptables -L
@raphaunix
raphaunix / DDOS check
Created November 7, 2017 01:36
DDOS check
DDOS check:
netstat -anp |grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
Dropping ip attacker with iptables:
iptables -I INPUT -s IPATTACKER -j DROP && service iptables restart && clear; iptables -L
@raphaunix
raphaunix / java.net.NoRouteToHostException SOLVED
Last active August 20, 2017 13:57
java.net.NoRouteToHostException SOLVED
SOLVED
java.net.NoRouteToHostException
cat /proc/sys/net/ipv4/ip_local_port_range
32768 - 61000
Solution
1. Lowest waiting time to release the door, the default is 60, modified to 15 ~ 30s
echo 30 >/proc/sys/net/ipv4/tcp_fin_timeout