Skip to content

Instantly share code, notes, and snippets.

View kai-phan's full-sized avatar
👋
Hi there!

Vinh Quy Phan kai-phan

👋
Hi there!
View GitHub Profile
For years it’s been simple to set up DNS on a Linux machine. Just add a couple of entries to /etc/resolv.conf and you’re done.
# Use Google's public DNS servers.
nameserver 8.8.4.4
nameserver 8.8.8.8
But things change and now it’s not that simple. If you now edit /etc/resolv.conf on Ubuntu you’ll find that the edits are ephemeral. If you restart (or even hibernate) your machine then they’ll be overwritten by default content.
nameserver 127.0.0.53
search Home
This is pretty simple to fix though.
@kai-phan
kai-phan / linux-dns.md
Created January 20, 2025 13:44 — forked from roulette6/linux-dns.md
Linux managing DNS servers (LPIC-2)

Linux managing DNS servers (LPIC-2)

Quick command reference

lsb_release -d          # get Linux distro and version
cat /etc/centos-release

# ubuntu
sudo /etc/init.d/bind9 {start | stop | restart}

sudo -u bind rndc status

@kai-phan
kai-phan / linux-networking-tools.md
Created January 12, 2025 16:59 — forked from miglen/linux-networking-tools.md
Linux networking tools

List of Linux networking tools

netstat (ss)

Displays contents of /proc/net files. It works with the Linux Network Subsystem, it will tell you what the status of ports are ie. open, closed, waiting, masquerade connections. It will also display various other things. It has many different options. Netstat (Network Statistic) command display connection info, routing table information etc. To displays routing table information use option as -r.

Sample output:

Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)    
tcp4 0 0 127.0.0.1.62132 127.0.0.1.http ESTABLISHED
@kai-phan
kai-phan / control-flow-1.js
Created November 12, 2024 17:37 — forked from ptdecker/control-flow-1.js
Node.js Serial Execution of an Async Function
/* Control Flow 1 - Repetitive Serial Execution of an Asynchronous Function
*
* Based on:
* - http://book.mixu.net/node/ch7.html
* - https://github.com/mixu
*
* Revised to use "typeof(first_item) != 'undefined'" based upon comments from 'Israel'
*
* Characteristics:
* - Flow control construct 'series' is recursive
@kai-phan
kai-phan / net-watcher-v2.js
Created November 12, 2024 17:35 — forked from ptdecker/net-watcher-v2.js
Automatically cleaning up a socket on Ubuntu 14.04 when 'Ctrl-C' is used to terminate node.js
/* This addresses a problem with the 'net-watcher.js' example in Jim Wilson's
* "Node.js The Right Way" book when running his 'net-watcher.js' example under
* Ubuntu 14.04 (and probably some other *nixs too).
*/
'use strict';
const
fs = require('fs'),
net = require('net'),
@kai-phan
kai-phan / worker-modify-css-js.js
Created November 7, 2024 17:17 — forked from Nooshu/worker-modify-css-js.js
Make a CF worker modify a CSS file and / or a JavaScript file on the fly.
// set the site we are modifying
const site = 'www.example.com';
// do this on a fetch
addEventListener('fetch', event => {
const request = event.request
const url = new URL(request.url)
event.respondWith(handleRequest(request))
});
@kai-phan
kai-phan / linux_network_commands.md
Created November 2, 2024 18:25 — forked from mnishiguchi/linux_network_commands.md
Linux - Network commands

Linux - Network commands

Routing tables

  • Servers maintain routing tables containing the addresses of each node in the network.
  • The IP Routing protocols enable routers to build up a forwarding table that correlates final destinations with the next hop addresses.

Common utilities

@kai-phan
kai-phan / linux_networking.sh
Created November 2, 2024 18:23 — forked from cmccormack/linux_networking.sh
Linux Networking Commands
# View device IP Address(es)
ip -o address show [interface] | awk '{print $4}' # Prints the IP address(es) of a single interface
ip address # Displays all interfaces
ifconfig # (deprecated)
hostname -I # Displays only IP addresses
# DNS name and resolution
host
dig
/etc/hosts # Add manual DNS record to hostname mappings (normally checked before configured DNS server(s))
@kai-phan
kai-phan / LinuxNetworkCommand.md
Created November 2, 2024 18:22 — forked from royki/LinuxNetworkCommand.md
Linux Network Command

Linux Network Command

  1. ifconfig - ifconfig (interface configurator) command is use to initialize an interface, assign IP Address to interface and enable or disable interface on demand. With this command you can view IP Address and Hardware / MAC address assign to interface and also MTU (Maximum transmission unit) size.
    • interface name
    • mask
    • loopback address
  • ifconfig -a
    • ifconfig with interface (eth0) command only shows specific interface details like IP Address, MAC Address etc. with -a options will display all available interface details if it is disable also.
  • ifconfig -v
  • ifconfig -s
@kai-phan
kai-phan / Experimental Docker structure.md
Created October 25, 2024 13:13 — forked from shinsenter/Experimental Docker structure.md
Docker structure for deploying to multiple environments

Beginning

There are many approaches to implementing a reuse of a common preset for Docker services for multiple environments, such as production and local environments.

This makes it possible to ensure the highest consistency for different environments with the same code-base. Implementing reuse of docker compose options also makes it easier to manage them.

I found on github a project called serversideup/spin. They took an approach using a feature called Docker overrides, to change some properties of common services for different environments.

After reading through their documentation, I realized that there are a few real-life cases where this project can not implement (or is difficult to archive).