Skip to content

Instantly share code, notes, and snippets.

View unixzen's full-sized avatar
🎯
Focusing

Eugene unixzen

🎯
Focusing
View GitHub Profile
#!/usr/bin/env python3
import httpx
import os
import json
BASE_YC_GPT_URL = "https://llm.api.cloud.yandex.net/foundationModels/v1/completion"
calculator_tool = {
@unixzen
unixzen / ns-inet.sh
Created June 19, 2024 11:31 — forked from dpino/ns-inet.sh
Setup a network namespace with Internet access
#!/usr/bin/env bash
# set -x
if [[ $EUID -ne 0 ]]; then
echo "You must be root to run this script"
exit 1
fi
# Returns all available interfaces, except "lo" and "veth*".
@unixzen
unixzen / ns-inet.sh
Created June 19, 2024 11:31 — forked from programmer131/ns-inet.sh
Setup a network namespace with Internet access
IFACE=wlp2s0
NS="ns1"
VETH="veth1"
VPEER="vpeer1"
VETH_ADDR="10.200.1.1"
VPEER_ADDR="10.200.1.2"
ip li delete ${VETH} 2>/dev/null
# Remove namespace if it exists.
ip netns del $NS &>/dev/null

The netfilter hooks in the kernel and where they hook in the packet flow

The figure below calls out

  • The netfilter hooks
  • The order of table traversal
@unixzen
unixzen / wireguard.conf
Created June 16, 2023 07:40 — forked from nealfennimore/wireguard.conf
Wireguard VPN - Forward all traffic to server
# ------------------------------------------------
# Config files are located in /etc/wireguard/wg0
# ------------------------------------------------
# ---------- Server Config ----------
[Interface]
Address = 10.10.0.1/24 # IPV4 CIDR
Address = fd86:ea04:1111::1/64 # IPV6 CIDR
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE # Add forwarding when VPN is started
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE # Remove forwarding when VPN is shutdown
@unixzen
unixzen / openssh-7.6-ubuntu-16.04.sh
Created June 7, 2023 09:42 — forked from prbinu/openssh-7.6-ubuntu-16.04.sh
How to build (and install) OpenSSH 7.6 packages on Ubuntu-16.04
# on a fresh Ubuntu 16.04 host
sudo apt-get update
# copy Ubuntu source packages from http://archive.ubuntu.com/ubuntu/pool/main/o/openssh
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssh/openssh_7.6p1-4.dsc
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssh/openssh_7.6p1.orig.tar.gz
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssh/openssh_7.6p1.orig.tar.gz.asc
wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssh/openssh_7.6p1-4.debian.tar.xz
@unixzen
unixzen / openssh-7.4-ubuntu-16.04.sh
Created June 7, 2023 09:42 — forked from prbinu/openssh-7.4-ubuntu-16.04.sh
How to build (and install) OpenSSH 7.4 deb packages on Ubuntu-16.04
# on a fresh Ubuntu 16.04 host
sudo apt-get update
# copy the packages from https://launchpad.net/debian/+source/openssh/1:7.4p1-10+deb9u3
wget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/openssh/1:7.4p1-10/openssh_7.4p1-10.dsc
wget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/openssh/1:7.4p1-10/openssh_7.4p1.orig.tar.gz
wget https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/openssh/1:7.4p1-10/openssh_7.4p1-10.debian.tar.xz
tar -zxvf openssh_7.4p1.orig.tar.gz
@unixzen
unixzen / openssh-latest-build-install.md
Created June 2, 2023 08:37 — forked from jtmoon79/openssh-latest-build-install.md
OpenSSH: build and install the latest version
@unixzen
unixzen / setup.sh
Created February 22, 2023 13:51 — forked from QueuingKoala/setup.sh
Sub-CA example
# Assumptions: easyrsa3 available in current dir, and functional openssl.
# This basic example puts the "offline" and "sub" PKI dirs on the same system.
# A real-world setup would use different systems and transport the public components.
# Build root CA:
EASYRSA_PKI=offline ./easyrsa init-pki
EASYRSA_PKI=offline ./easyrsa build-ca nopass
# Build sub-CA request:
EASYRSA_PKI=sub ./easyrsa init-pki
@unixzen
unixzen / README.md
Created May 24, 2021 10:21 — forked from zoilomora/README.md
How to disable systemd-resolved in Ubuntu

How to disable systemd-resolved in Ubuntu

Stages

  • Disable and stop the systemd-resolved service:

      sudo systemctl disable systemd-resolved.service
      sudo systemctl stop systemd-resolved
    
  • Then put the following line in the [main] section of your /etc/NetworkManager/NetworkManager.conf: