Skip to content

Instantly share code, notes, and snippets.

View psammarco's full-sized avatar

Pietro Sammarco psammarco

View GitHub Profile

Say you have one or more KVM guests on Proxmox which have one or more virtual interfaces which subnet is different than the HOST one, and you happen to want to reach those interfaces from within LAN for whatever reason...

To accomplish this we will be creating a simple bash script as well as creating a systemd service to have it executed on boot.

/usr/lib/systemd/scripts/routing_tables.sh

#!/bin/bash

vmID=100
#!/bin/bash
workdir=/tmp/qemu-kvm
bin=/usr/local/opt/qemu-kvm/bin
lib=/usr/local/opt/qemu-kvm/lib
libextra=/usr/lib
share=/usr/share/qemu
rootfs="/dev/root"
ar=/usr/local/opt/qemu-kvm/bin/ar
NOTE!!! Since we removed the static variable path, we now need to export it manually for the script to work!!!
@psammarco
psammarco / xmrig-screen.sh
Last active March 12, 2020 22:34
xmrig execution cron script
#!/bin/bash
#
# This script checks if xmrig is running, logs the status, and if found not to be running,
# opens a detached screen window and execute a second script which contains the xmrig command line.
#
# @latrinelove
logdir=/opt/local/xmrig/logs
scriptsdir=/opt/local/xmrig/scripts
In order for a Ryzen 3000 SOC temperature to be logged under "sensors", a kernel 5.4.X or newer is required as it contains the instructions needed for these CPUs.
Alternatively the SOC instruction patches can be applied to a earlier kernel, however this guide won't be covering that.
Note: This won't work if your motherboard comes with a NCT chip.
I am assuming you are on Debian Buster and know how to resolve basic apt dependencies.
A. Downloading the kernel sources and setting up the build environment;
# cd /usr/src
# wget https://git.kernel.org/torvalds/t/linux-5.4-rc1.tar.gz

Keybase proof

I hereby claim:

  • I am psammarco on github.

  • I am latrinelove (https://keybase.io/latrinelove) on keybase.

  • I have a public key ASCZdxVvCY7jLWGFqxd4LPO_i0sGtZE3WGKidQQr8KefTAo

This howto will show you how to create a etherstub and add a vnic on top of it. See a etherstub as a virtswitch which is indipendent from the phsycal NICs.
1. Create a ETHERSTUB
NB: ETHSTUBNAME must end with a number; for instance a valid name would be happyether69
# nictagadm add -l ETHSTUBNAME
2. Now lets create a dummy VNIC on the ETHERSTUB
# dladm create-vnic -l ETHSTUBNAME VNICNAME -m MACADDR
# At this point I am quite confident you know what bhyve is, right? Well if not, I am sorry, you are missing out!
# Bhyve stands for BSD Hypervisor, and was initially developed by NetApp and later gifted to the FreeBSD project.
# Bhyve has seen a serious evolution and improvement over the course of the past years,
# and it has been merged into SmartOS illumos since awhile now.
# This guide will show you how to setup a new Bhyve zone in SmartOS illumos.
1. Create a .json file and add the following, man vmadm(1m) for reference;
>>>
{
AlpineLinux OpenVPN router setup
In this guide I will be assuming you have a AlpineLinux client which connects to a OpenVPN server, and you want NAT its traffic through a network interface which will act as gw for another subnet.
Keep in mind this is a basic setup and you will need to edit stuff according to your configuration and needs. But all in all, should work!
1. Install the openvpn client, the isc-dhcp-server and iptables
# apk update && apk add openvpn dhcp-server-vanilla iptables
2. Load the tun module and add it to /etc/modules
# modprobe tun
Quick basic setup guide on linux container zones in OmniOSce illumos.
1. Install the lx package
> sudo pkg update
> sudo pkg install lx
2. Download a "container_native" rootfs from the following joynet's image repository: https://images.joyent.com/images
a. Look for the uuid of the image from the json template, for instance: {"uuid": "3dbbdcca-2eab-11e8-b925-23bf77789921"}, and add it to the download url as shown next;
b. Also note down the kernel version from the json template as it will be needed from zonecfg when setting up the zone;
> curl -o centOS7.4_container_native.zss.gz https://images.joyent.com/images/3dbbdcca-2eab-11e8-b925-23bf77789921/file
This was tested on ESXi 6.5, but should work from 5 onwards.
The descriptor is basically a text file that contains geometry parameters which point out to the image that actually cotain the data,
usally called "VM0-flat.vmdk".
This is a last resort method when unable to restore the actual descriptor .vmdk file.
1) SSH into your ESXi host and head to /vmfs/volumes/datastore/VM
>>>
# ls -l virt_switch0-flat.vmdk