Skip to content

Instantly share code, notes, and snippets.

View aoaim's full-sized avatar
🤯
I'm all tied up!

Michael Clark aoaim

🤯
I'm all tied up!
  • Mars
  • 01:39 (UTC +08:00)
View GitHub Profile
@aoaim
aoaim / UFW_ban_country.md
Created March 10, 2023 08:39 — forked from jasonruyle/UFW_ban_country.md
UFW to block countries

If you want to SSH to a VPS which is running openVPN do the following:
source: https://serverfault.com/questions/659955/allowing-ssh-on-a-server-with-an-active-openvpn-client

Enable

The problem is that the default gateway gets changed by OpenVPN, and that breaks your current SSH connection unless you set up appropriate routes before you start OpenVPN.

What follows works for me. It uses iptables and ip (iproute2). Below, it is assumed that the default gateway interface before OpenVPN is started is "eth0". The idea is to ensure that when a connection to eth0 is made, even if eth0 is not the default gateway interface anymore, response packets for the connection go back on eth0 again.

You could use the same number for the connection mark, firewall mark and routing table. I used distinct numbers to make the diffences between them more apparent.

@aoaim
aoaim / sources.list
Created May 13, 2024 07:22
Ubuntu 22.04 LTS /etc/apt/sources.list
deb http://archive.ubuntu.com/ubuntu jammy main restricted
# deb-src http://archive.ubuntu.com/ubuntu jammy main restricted
deb http://ubuntu.mirror.constant.com jammy main restricted
# deb-src http://ubuntu.mirror.constant.com jammy main restricted
deb http://archive.ubuntu.com/ubuntu jammy-updates main restricted
# deb-src http://archive.ubuntu.com/ubuntu jammy-updates main restricted
deb http://ubuntu.mirror.constant.com jammy-updates main restricted
@aoaim
aoaim / autoupdate_setup.sh
Created November 21, 2024 06:21
设置debian自动更新
#!/bin/bash
# 1. 创建脚本文件 /root/apt-update.sh
echo '#!/bin/bash' | sudo tee /root/apt-update.sh > /dev/null
echo 'apt update && apt upgrade -y && apt autoremove -y' | sudo tee -a /root/apt-update.sh > /dev/null
# 2. 自动在 crontab 最后添加任务
(crontab -l; echo '0 */12 * * * /root/apt-update.sh') | sort - | uniq - | crontab -
# 3. 赋予权限