NetworkManager Conflict with DNS Caching?

NetworkManager is a program for providing detection and configuration for systems to automatically connect to network. Your network can easily be shared to others using it. But If you want to implement DNS caching on your machine, you will find it annoying. I used to face conflict between NetworkManager/ConnectionSharing and DNS Caching, but now I find a workaround.


My DNS Caching Configure

/etc/NetworkManager/NetworkManager.conf
[main]
dhcp=dhclient
dns=dnsmasq

It works, but you need root privilege to start networksharing, like ...

C Tips

The reminder operator (%) in C

I’ve found the reminder operator in C very annoying. For example, if you have a ≡ 1 (mod n), then there are three kinds of result in c:

a%n == n+1 // if a < 0 && n < 0
a%n == 1-n // if a < 0 && n > 0
a%n == 1 // if a > 0 

Determine System Type Using Compiler Predefined Macros

How to list compiler predefined macros

Clang/LLVM:
clang -dM -E -x c /dev/null     
clang++ -dM -E -x c++ /dev/null
GNU GCC/G++:
gcc -dM -E -x c /dev/null   
g++ -dM -E -x c++ /dev/null 

Linux ramdom syscall not found

According linux man page, I wrote codes as below:

#include <linux/random.h>
......
#ifdef __linux__
    unsigned char buf[2 * LOOP_MAX * sizeof(int)];
    int *p = (int *)buf;
    result = getrandom(buf, LOOP_MAX * sizeof(int), 0);

Linux Tips

Under construction

Linux port usage:

Update: netstat has replaced by 'ip -s' or ss in newer system.

netstat - a command-line tool that displays network connections,
 routing tables, and a number of network interface statistics.

fuser - a command line tool to identify processes using files or sockets.

lsof - a command line tool to list open files under Linux / UNIX to report
 a list of all open files and the processes that opened them.

/proc/$pid/ file system - Under Linux /proc includes a directory for
 each running process (including kernel proc...

How to debug stripped binaries with GDB

references: https://reverseengineering.stackexchange.com/questions/1935/how-to-handle-stripped-binaries-with-gdb-no-source-no-symbols-and-gdb-only-sho

Tricks you should know

Press return/enter will run last command

Commands can be abbreviated as long as they are unambiguous.

eg:

b for break (despite bt and backtrace)
c or cont...

Running ARM Applications on Native Linux

Today I’ve got a Linux application running on aarch64 architecture. But I don’t have any aarch64 (ARM64) architecture devices. So I’ve found a way to run it on my native Linux (without VM).
QEMU is a generic and open source machine emulator and virtualizer. Thanks to QEMU, we can running almost any other architecture applications on your native Linux host.

As for ARM (Arch Linux):

Preparetion: You need installing some packages first.
QEMU
Glibc(runtime)
<...