Linux

Exposing Services Behind a Firewall

Synopsis

Sometimes you may find yourself in a situation in which you would like to host a service but sometimes you’re stuck behind a double NAT, or even just a firewall in which you do not control all of the rules for. Here I’m going to show you how to use Wireguard VPN to finagle around this issue and simply give your private server a public IP address. Important note: in order for this to work, you will need a publicly accessible VPS, preferably with a static IP address, i would recommend either AWS Lighsail or Linode as they are both cost-effective options with their cheapest tiers being bout $3.50/mo and $5/mo respectively (I like Linode’s speed more, they aren’t paying me to say this although I wish they were).

Read more >

Rate Limiting with IPTables

Synopsis

When hosting public servers, whether that be Web, SSH, or whatever you want to roll out, people’s biggest concerns are either automated attacks consuming resources and denying your access or those same attacks constantly attempting to authenticate to your application through brute forcing your authentication. I’m going to write this from the perspective of someone simply trying to secure a service that they expect a limited amount of use to, in my case ssh.

Read more >

Systemd Service Guide

When creating applications that you’d like to run over a continuous period of time, you’re eventually going to need to worry about timing, system integration, and startup/exit behavior, but while creating your own methods to do so I’m sure you’ll learn a lot about the Linux operating system, but often times its a bit more work than one would like just to get a simple application running. For this tutorial I’m going to show you how I created a service to run my Eva Unit-01 discord bot. Eva is a python script that runs out of a virtual environment. I would like for it to be run on startup with any issues or output logged to the systemd journal.

Read more >

/bin/bash^M: bad interpreter

Bash scripts are very sensitive to line endings which can cause some portability issues between windows and unix-like systems (depending on how the text editor encodes line breaks). If you would like to see the invisible characters that are making your life confusing simply type:

cat -v <FILE>

The easiest solution to this issue is a simple sed replace line:

sed -i -e 's/\r$//' <FILE>

Sed alternate delimiters

Sometimes when trying to replace text using the sed command line tool you will tun into the issue in which your text has the forward slash characters which can be a bit of a headache because thats what sed uses to delimit strings. Thankfully the delimiter is pretty flexible. I like to use the pipe “|” symbol, but pretty much any other symbol will work such as the tilde “`” or the colon “:” ex:

Read more >

Testing Drive Read/Write Speed Via Terminal

Just a quick example of how to use dd to test drive read/write speed. NOTE: Dont do this a lot or you could shorten the live of your drive since youre making arbitrary writes.

Reading

sudo dd if=/dev/zero of=/tmp/test.img bs=1G count=1 oflag=dsync

This command will write 1G of zeros to an arbitrary file of your choosing. Feel free to delete it when you’re done.

Your output will look a little like this.

Read more >