Monday, March 16, 2020

Duck DNS

Now it's easy to remember my internet-facing hosts with dynamic IP using DuckDNS

Monday, January 14, 2019

How to boot into Rescue Mode or Emergency Mode CentOS / RHEL / Ubuntu

This article explain Rescue Mode and Emergency and also explain how to boot Ubuntu into these modes.

This Article explain how to boot CentOS/ RHEL 7 into rescue or emergency mode

I found it very useful hence sharing here

Sunday, January 13, 2019

Play with Docker

The Play with Docker classroom  is a nice tool for newbies to learn containers/Docker. Give it a try 

Sunday, May 1, 2016

Rotating traffic captures using tcpdump

To avoid creating large traffic captures using tcpdump, there are couple of interesting switches in tcpdump command which enable one to create rotating traffic captures, compress it on the fly etc.

ni :specifies the network interface on which to capture traffic
-s :; indicates a capture of the full size of the packet
-vvv : verbose
-w  :  indicates the file name and location in which the capture will be saved
-C  :  indicates the size of each file, after reaching this size file will be rotated
-W  :  indicates the number of files that will be stored
-z  :  to compress the file


For example,

tcpdump -ni eth1 -C 20 -z gzip -w /tmp/trace.pcap

This would create a file named trace.pcap...trace.pcapX. After 20MB of data, (-C 20) tcpdump would create a file named trace.pcapX and so on. and compress the capture files after tcpdump finished writing to them.

tcpdump -pni eth0 -s0 -C 100 -W 10 -w /tmp/capture

In this example, tcpdump starts capturing into capture1 until it reaches capture10. When it filled up capture10 with 100MB of data, it starts again, overwriting capture1. This way, your captures
will never use more then 1000MB of disk space.

gdb all threads bt to file

Perform the following steps to collect a backtrace from a core dump for all threads.

Find the core file and the executable that created.

Start gdb in the directory where the log file should be created:

By default, gdb will create a logfile called gdb.txt in the current working directory when logging is enabled.  Optionally, specify a different logfile name with this command:

Enable logging by running the following commands:

(gdb) set height 0
(gdb) set logging file /tmp/thread_apply_all_bt.txt
(gdb) set logging on
Copying output to /tmp/thread_apply_all_bt.txt


Request a backtrace:

(gdb) thread apply all bt full


Exit gdb by running the quit command, or press Ctrl-D.
Collect the logfile.

Sunday, December 7, 2014

Docker and BusyBox

Ever heard of  Busybox or you are like me living in a cave. YAS today heard of it

BusyBox: The Swiss Army Knife of Embedded Linux

Its so tiny that the Docker image is only few mb in my case 2.433 MB

Dockerizing BusyBox

To Run BusyBox 
docker run --rm -it busybox

This will drop you into sh shell.

You can use Busybox to test your static binaries For example

1. Create a Dockerfile for a binary

From busybox
copy my-binary /my-binary
CMD ["/my-binary"]

2. Now build the image
docker build -t my-binary:v1 .

3. Finally run the container from the image to test your binary
docker run --rm -it my-binary:v1

Happy dockerizing

Oracle Linux Image for Docker

Everyone is talking about Docker these days, Oracle also took the notice and recently make Oracle Linux 6 and 7 images available for Docker.

Note: Oracle Linux is rebuild of RHEL same as Centos or Scientific Linux. ;)

Lets try to containerize the oracle linux OL7

1. Assuming Docker is already installed on your favorite Linux distro

2. Download the Oracle Linux image

3. Uncompress it , this will give oraclelinux-7.0.tar in the current directory
$ unxz oraclelinux-7.0.tar.xz

4. Load the image to your local Docker repository.
# docker load -i unxz oraclelinux-7.0.tar

5. check local image repo

# docker images

REPOSITORY           TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
oraclelinux          7.0                 5f1be1559ccf        3 weeks ago         265.2 MB
askhan/salt-minion   v1                  9b40143974c1        9 weeks ago         294.6 MB

6. Finally run container based on OL7 image
# docker run --rm -it --name oracle7 oraclelinux:7.0 bash

7. Now inside the container
[root@fcc43a277822 /]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.0 (Maipo)

Hey what this is RHEL...come on make your own Linux distro to better serve the community. (Oracle)