Assign Fixed Name to The Network Interface on Raspbian

I had this problem when adding a new usb wifi dongle for my raspberry setup. That it sometimes gets assigned with wlan0 name. I expect that wlan0 name should be assigned to the built-in wifi card device, hence the wifi dongle should get wlan1 name instead. But that’s not the case. This leads to problem, since I need this naming to be deterministic for my network configuration (e.g: which device acts as wifi client vs which one as access point, which one does support 5 Ghz band vs only support 2.4 GHz band).

Fortunately there are ways to solve this.

Predictable Network Interface Names

The straightforward way to enable this is via raspi-config. This feature provides a predictable naming mechanism by generating the name from device firmware/topology/location information1.

Assigning fixed names based on firmware/topology/location information has the big advantage that the names are fully automatic, fully predictable, that they stay fixed even if hardware is added or removed (i.e. no reenumeration takes place) and that broken hardware can be replaced seamlessly. That said, they admittedly are sometimes harder to read than the “eth0” or “wlan0” everybody is used to. Example: “enp5s0”

In the Network Options, enable predictable network device name, and reboot.

sudo raspi-config

This solution is simple and easy. However, the assigned name (something like this wlp3s0 enp0s31f6) are harder to remember compared to the old naming wlan0, wlan1, and eth0. Which comes for me to seek another simple solution that can achieve this classic naming.

Read more →

How to Backup and Restore Your Raspberry Pi Image

I have been using my raspberry pi for almost a month. During this time, I have configured a lot on it: installing required softwares and tools for work, configuring the network and hotspot, etc.

Considering the amount of time and effort spent, it is very important for me to backup the raspberry. In fact, the first day I received my raspberry pi, after having setup so many things, I accidentally disconnect the power cable causing my raspberry didn’t boot at all.

All my effort were vanished 😱

After that incident, I quickly researched how to take a snapshot, clone it on another microsd card and successfully booted from it.

So here we go, the step by step using Debian/Ubuntu:

Read more →

How to Assign Static IP to Network Interface uap0 RaspAP

So recently I encountered intermittent problem when running the RaspAP on my raspberry pi. The problem is on the interface uap0, created by RaspAP for Hotspot access point. This interface supposed to have static ip 192.168.50.1.

However, sometimes it gets assigned with entirely different ip range (e.g: 168.x.x.x) when I messed up with RaspAP’s setting.

Although I am still looking at the root cause of this issue (it is very hard to reproduce), I already have mitigation solution to remedy this problem:

Assign uap0 static ip using ifconfig

sudo ifconfig uap0 192.168.50.1 netmask 255.255.255.0 up

Then restart the raspap-service

sudo systemctl restart raspap.service

Assign uap0 ip via RaspAP Web Interface

The other way than using terminal access above is using the RaspAP web interface. Just point your browser to the raspberry’s RaspAP url. On Configure Networking menu, select uap0 tab then configure like below:

Set empty for the rest of configuration (e.g: default gateway, dns, etc).

Then click Save Setting and Apply Setting.

Read more →

Troubleshooting Cheatsheet when Debugging Service in Kubernetes

Gain Shell Access to Pod (similar to ssh)

kubectl exec -it <pod> -- bash

This only working if the pod contains bash. Change bash to sh if bash not found.

Temporary Spawn Ubuntu Pod

Sometimes it is impossible to gain shell access to the existing running pod. The reason maybe: no shell binary in the pod or even we don’t have no access to the pod. The other way that we can try is spawning a pod temporarily then we can use this pod to debug the running service.

kubectl run -i \
    --tty busybox \
    --image=ubuntu \
    --restart=Never \
    -- bash

In that pod, you can use apt to install common utilities to debug service:

apt update -y
apt install -y dnsutils curl netcat

After finish, don’t forget to delete the pod

kubectl delete pod busybox
Read more →

Moving The Blog to The New Domain

Yesterday I got a notification email saying my blog domain: agung.io will be expired soon. I planned to renew, however the price is quite hefty: 60 USD (around IDR 900k), double in price than my first year of renting this domain.

Since I want to keep my blog setup cost as low as possible without sacrificing many things, I excercised how easy it is to move my blog to a new domain. So, I purchased new cheap domain agung.tech with only USD 3 for the first year in GoDaddy. There are 2 outcome from my experiment of migrating this blog to new domain:

  • either it is really painful and error prone process, hence I would keep paying the 60 buck to continue using agung.io domain, or
  • it is relatively easy, so it is better to use the new agung.tech domain for this blog

Result

It was super easy and quick. In fact, I managed to migrate this in 1-2 hours. The migration process basically involved few configuration changes. It also worth to mention that my blog content doesn’t have any hardcoding of the blog domain to link resources (e.g: image resources).

The Migration Process

To give you some context, I use:

  • GitHub to put my blog content, using hugo
  • Netlify to host the blog. Domain agung.io is also managed within the Netlify.
  • New domain agung.tech is purchased on GoDaddy.

Transfer DNS Control from GoDaddy to Netlify

Just to be clear, the main reason why I delegate the DNS control to Netlify is to keep my life simple. Rather than managing the DNS from GoDaddy, but using Netlify to manage the blog, I’d instead choose Netlify for both.

The easy way (I would say the only way, but CMIIW) to do this is by configure the NS record of agung.tech in GoDaddy to Netlify’s nameservers.

Note that this can take some times to propagate. To check it:

dig agung.tech -t NS

When it is already reflected, in the ANSWER SECTION it should print out the new nameservers.

;; ANSWER SECTION:
agung.tech.             3600    IN      NS      dns1.p04.nsone.net.
agung.tech.             3600    IN      NS      dns2.p04.nsone.net.
agung.tech.             3600    IN      NS      dns3.p04.nsone.net.
agung.tech.             3600    IN      NS      dns4.p04.nsone.net.

Then, I added agung.tech in Netlify domain setting so I can start configuring the DNS there.

Points blog.agung.tech to My Netlify Blog Domain

By default, Netlify will give your blog the netlify.com domain. For instance, my blog domain is agung.netlify.com.

So I added CNAME record of blog.agung.tech to agung.netlify.com. This basically means that agung.netlify.com is the canonical name of blog.agung.tech, hence will return the same IP location

Configure Netlify Custom Domain

In order for Netlify able to route the new domain to my site, I added blog.agung.tech in the Custom Domain list. Even I set it as Primary Domain.

Change Hugo BaseURL

In the config.toml, it was set to

baseURL = "https://blog.agung.io/"

I changed to

baseURL = "https://blog.agung.tech/"

Now, I can access my blog via the new domain.

However, there is one more step to properly routing someone who access my blog via old domain to the new domain.

Read more →