pdnsForArchLinux

For avoiding dns resolving pollution, I need to configure pdnsd for my archlinux workstation, following are the steps:

# pacman -S pdnsd
# cp /usr/share/doc/pdnsd/pdnsd.conf /etc
# vim /etc/pdnsd.conf

The configuration file is listed as:

global {
	perm_cache=10240;
	cache_dir="/var/cache/pdnsd";
#	pid_file = /var/run/pdnsd.pid;
	run_as="pdnsd";
	server_ip = 127.0.0.1;  # Use eth0 here if you want to allow other
				# machines on your network to query pdnsd.
	server_port=53;
	status_ctl = on;
#	paranoid=on;       # This option reduces the chance of cache poisoning
	                   # but may make pdnsd less efficient, unfortunately.
	query_method=tcp_only;
	#min_ttl=15m;       # Retain cached entries at least 15 minutes.
	#max_ttl=1w;        # One week.
	#timeout=10;        # Global timeout option (10 seconds).
	#neg_domain_pol=on;
	#udpbufsize=1024;   # Upper limit on the size of UDP messages.
    neg_domain_pol = off;    
    paranoid = on;    
    par_queries = 1;    
    min_ttl = 1d;    
    max_ttl = 5d;    
    timeout = 10; 
}

# The following section is most appropriate if you have a fixed connection to
# the Internet and an ISP which provides good DNS servers.
server {
	label= "routine";
	ip = 223.5.5.5;  # Put your ISP's DNS-server address(es) here.
#	proxy_only=on;     # Do not query any name servers beside your ISP's.
	                   # This may be necessary if you are behind some
	                   # kind of firewall and cannot receive replies
	                   # from outside name servers.
	timeout=5;         # Server timeout; this may be much shorter
			   # that the global timeout option.
#	uptest=if;         # Test if the network interface is active.
#	interface=eth0;    # The name of the interface to check.
#	interval=10m;      # Check every 10 minutes.
#	purge_cache=off;   # Keep stale cache entries in case the ISP's
#			   # DNS servers go offline.
#	edns_query=yes;    # Use EDNS for outgoing queries to allow UDP messages
#			   # larger than 512 bytes. May cause trouble with some
#			   # legacy systems.
#	exclude=.thepiratebay.org,  # If your ISP censors certain names, you may
#		.thepiratebay.se,   # want to exclude them here, and provide an
#		.piratebay.org,	    # alternative server section below that will
#		.piratebay.se;	    # successfully resolve the names.
   reject = 74.125.127.102,
       74.125.155.102,  
       74.125.39.102,  
       74.125.39.113,  
       209.85.229.138,  
       128.121.126.139,  
       159.106.121.75,  
       169.132.13.103,  
       192.67.198.6,  
       202.106.1.2,  
       202.181.7.85,  
       203.161.230.171,  
       203.98.7.65,  
       207.12.88.98,  
       208.56.31.43,  
       209.145.54.50,  
       209.220.30.174,  
       209.36.73.33,  
       211.94.66.147,  
       213.169.251.35,  
       216.221.188.182,  
       216.234.179.13,  
       243.185.187.39,  
       37.61.54.158,  
       4.36.66.178,  
       46.82.174.68,  
       59.24.3.173,  
       64.33.88.161,  
       64.33.99.47,  
       64.66.163.251,  
       65.104.202.252,  
       65.160.219.113,  
       66.45.252.237,  
       69.55.52.253,  
       72.14.205.104,  
       72.14.205.99,  
       78.16.49.15,  
       8.7.198.45,  
       93.46.8.89,  
       37.61.54.158,  
       243.185.187.39,  
       190.93.247.4,  
       190.93.246.4,  
       190.93.245.4,  
       190.93.244.4,  
       65.49.2.178,  
       189.163.17.5,  
       23.89.5.60,  
       49.2.123.56,  
       54.76.135.1,  
       77.4.7.92,  
       118.5.49.6,  
       159.24.3.173,  
       188.5.4.96,  
       197.4.4.12,  
       220.250.64.24,  
       243.185.187.30,  
       249.129.46.48,  
       253.157.14.165;  
   reject_policy = fail;  
   exclude = ".google.com",  
       ".cn",
       ".baidu.com",
       ".qq.com",
       ".gstatic.com",  
       ".googleusercontent.com",  
       ".googlepages.com",  
       ".googlevideo.com",  
       ".googlecode.com",  
       ".googleapis.com",  
       ".googlesource.com",  
       ".googledrive.com",  
       ".ggpht.com",  
       ".youtube.com",  
       ".youtu.be",  
       ".ytimg.com",  
       ".twitter.com",  
       ".facebook.com",  
       ".fastly.net",  
       ".akamai.net",  
       ".akamaiedge.net",  
       ".akamaihd.net",  
       ".edgesuite.net",  
       ".edgekey.net";  
}

server {  
   # Better setup dns server(DON'T USE PORT 53) on your own vps for faster proxying  
   label = "special";
   ip = 208.67.222.222,208.67.220.220;
   port = 5353;
   proxy_only = on;  
   timeout = 5;  
}  

Then you have to enable and start the pdnsd service via:

# systemctl enable pdnsd
# systemctl start pdnsd
# vim /etc/resolv.con
nameserver 127.0.0.1
# chattr +i /etc/resolv.conf

you could use dig for testing your pdnsd configuration.

UseCrontabForRunningTasks

If I’d wanna to run the same tasks on several machine at the certain time, I could do following tricks:

# crontab -l
# crontab /root/mycron

While you could set non-password login among those machines, and transfer the same crontab files to these machine.

scp /root/mycron root@192.168.10.22:/root
scp /root/mycron root@192.168.10.2X:/root
scp /root/mycron root@192.168.10.2X:/root
scp /root/mycron root@192.168.10.2X:/root
scp /root/mycron root@192.168.10.2X:/root

You cron file would be seen like following:

# cat /root/mycron
59 14 * * * /root/benchmark.sh

this means the scripts of /root/benchmark.sh would be run at 14:59 AM. In this file you could do whatever you want.

/images/2018_01_04_17_18_39_448x169.jpg

SomeTips For Virtualbox

https://www.virtualbox.org/manual/ch09.html

9.11.4. Binding NAT sockets to a specific interface
By default, VirtualBox's NAT engine will route TCP/IP packets through the default interface assigned by the host's TCP/IP stack. (The technical reason for this is that the NAT engine uses sockets for communication.) If, for some reason, you want to change this behavior, you can tell the NAT engine to bind to a particular IP address instead. Use the following command:

VBoxManage modifyvm "VM name" --natbindip1 "10.45.0.2"
After this, all outgoing traffic will be sent through the interface with the IP address 10.45.0.2. Please make sure that this interface is up and running prior to this assignment.

Some reference topics:

https://forums.virtualbox.org/viewtopic.php?f=6&t=81631

https://forums.virtualbox.org/viewtopic.php?f=1&t=38879

HugoAndTravisConfiguration

hugo 升级到v0.33后,生成的静态网站里缺少了index.html等HTML文件,原因不明。恰好我在travis上的编译流程有些繁琐,每次都需要花费5分钟以上生成整个网站,于是我调研了一下更好的解决方案,用于生成博客静态网站。

Issue:

/images/2018_01_03_11_14_02_828x601.jpg

无法正常显示的网页:

/images/2018_01_03_11_14_25_829x531.jpg

准备

以前的hugo源代码我直接放在某个仓库里,建了两个分支source和master, source用于存放源代码,master则是编译后的静态网站结果,编译完成以后,直接发布在github page上。

每一次编译都需要推送代码到travis上,在travis的容器里安装好hugo, 安装hugo的方式是直接go get -u -v, 这样相当于每次编译网站都需要预先编译出来一个hugo,因而比较耗时。

为了避免这种繁琐的过程,我建立一个新的仓库,blogsource,将以前的仓库清空, 重新组织目录结构.

在github上建立一个token, 注意选中其repo选项:

/images/2018_01_03_11_14_38_674x523.jpg

得到的token如下,我们将复制这个数值,后面在travisCI中需要填到:

/images/2018_01_03_11_14_48_831x372.jpg

在travisci的环境变量中,手动添加我们刚才生成的token:

/images/2018_01_03_11_16_06_1247x346.jpg

代码重架构

目录架构如下:

/images/2018_01_03_11_17_20_681x240.jpg

其中binaries下是我们手动下载的hugo可执行文件,下载地址在:

https://github.com/gohugoio/hugo/releases

我这里选择的是v31.1的Linux-64.tar.gz, 下载完毕后,直接解压到此目录下即可。

hugo原有的配置文件不需要变化,所需要变化的是我们的.travis.yaml文件。

travis配置文件

简单起见,下面直接贴出源代码。

addons:
  apt:
    packages:
      - python-pygments

install:
  - rm -rf public || exit 0

script:
  - cd src
  - ../binaries/hugo --theme=hyde-a

deploy:
  provider: pages
  skip_cleanup: true
  local_dir: public
  github_token: $GITHUB_TOKEN # Set in travis-ci.org dashboard
  on:
    branch: master
  repo: purplepalmdash/purplepalmdash.github.io
  target_branch: master

注意到上面的deploy环节,使用到了我们上面生成的token, 而每次编译完成以后,直接推送到purplepalmdash/purplepalmdash.github.io仓库的master分支,按照github的说明,这个分支直接提供了博客网站。

更改一些源文件

现在github page已经完全支持https了,而之前我们的网站使用的是http方式,为此,我们的css文件配置需要有以下的修改,主要是在我的模板文件中定义:

/images/2018_01_03_11_22_13_1072x880.jpg

更改完毕以后,每次就可以使用https来访问网站了。

travisCI自编译

去掉以前的travisCI配置,更新一个新的配置.

/images/2018_01_03_11_23_37_482x392.jpg

完整的配置应该如下:

/images/2018_01_03_11_24_02_847x734.jpg

现在每次针对代码库blogsource的提交,将自动触发博客的编译,并自动更新最终的页面。

时间

每次的编译时间差不多在一分钟之内。

/images/2018_01_03_11_25_24_846x393.jpg

BeliveFuture

昨天的开发者头条年度开篇,用到了这首诗歌。这几年的时间里,大家知道的,国内的气氛每况愈 下,查点像样的资料,没个像样的梯子压根都到达不了公正一点的搜索引擎。房价高企,每次路过 像样点的小区都不敢看。这是我们所希望的将来吗?不是的。

所以,我只能坚定地相信未来,相信不屈不挠的努力,相信战胜死亡的年轻。相信未来、热爱生命 。2018年我将迎来小生命的诞生,希望我的努力能给ta拼出一片像样的天空。

当蜘蛛网无情地查封了我的炉台 
当灰烬的余烟叹息着贫困的悲哀 
我依然固执地铺平失望的灰烬 
用美丽的雪花写下:相信未来 

当我的紫葡萄化为深秋的露水 
当我的鲜花依偎在别人的情怀 
我依然固执地用凝霜的枯藤 
在凄凉的大地上写下:相信未来 

我要用手指那涌向天边的排浪 
我要用手掌那托住太阳的大海 
摇曳着曙光那枝温暖漂亮的笔杆 
用孩子的笔体写下:相信未来 

我之所以坚定地相信未来 
是我相信未来人们的眼睛 
她有拨开历史风尘的睫毛 
她有看透岁月篇章的瞳孔 

不管人们对于我们腐烂的皮肉 
那些迷途的惆怅、失败的苦痛 
是寄予感动的热泪、深切的同情 
还是给以轻蔑的微笑、辛辣的嘲讽 

我坚信人们对于我们的脊骨 
那无数次的探索、迷途、失败和成功 
一定会给予热情、客观、公正的评定 
是的,我焦急地等待着他们的评定 

朋友,坚定地相信未来吧 
相信不屈不挠的努力 
相信战胜死亡的年轻 
相信未来、热爱生命 

Arm64Emulation

Qemu Emulation

In archlinux, install packages via:

$ sudo pacman -S qemu-arch-extra
$ yaourt cloud-utils

Create the img via following command:

root@archiso ~/arm # cloud-localds my-seed.img my-user-data 
root@archiso ~/arm # cat my-user-data 
#cloud-config
password: enginexxx
chpasswd: { expire: False }
ssh_pwauth: True
ssh_authorized_keys:
 - ssh-rsa xxxxxx
timezone: Asia/Chongqing

Download the ubuntu image files in:

# wget http://cloud-images.ubuntu.com/daily/server/xenial/20171214/xenial-server-cloudimg-arm64-uefi1.img
# wget https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/QEMU_EFI.fd

Your folder will be displayed like:

# ls
my-seed.img   QEMU_EFI.fd  xenial-server-cloudimg-arm64-uefi1.img
my-user-data  start.sh
# cat start.sh
qemu-system-aarch64 \
    -smp 2 \
    -m 1024 \
    -M virt \
    -cpu cortex-a57 \
    -bios QEMU_EFI.fd \
    -nographic \
    -device virtio-blk-device,drive=image \
    -drive if=none,id=image,file=xenial-server-cloudimg-arm64-uefi1.img \
    -device virtio-blk-device,drive=cloud \
    -drive if=none,id=cloud,file=my-seed.img \
    -device virtio-net-device,netdev=user0 \
    -netdev user,id=user0 \
    -redir tcp:2222::22

start the shell script, then login with ssh -p2222 ubuntu@localhost, you will get an emulated arm environment.

The default size of the / partition is only 2G, need to growpart to 40G, the steps are listed as following(add 2 lines into the my-seed):

#cloud-config
growpart:
  mode: auto

Edit the mirrored pkgs via:

# vim /etc/apt/sources.list
deb http://192.168.0.100/arm64repo/mirror/ports.ubuntu.com/ xenial main restricted universe
deb http://192.168.0.100/arm64repo/mirror/ports.ubuntu.com/ xenial-updates main restricted universe
deb http://192.168.0.100/arm64repo/mirror/ports.ubuntu.com/ xenial-backports main restricted universe
deb http://192.168.0.100/arm64repo/mirror/ports.ubuntu.com/ xenial-security main restricted universe
deb http://192.168.0.100/arm64repo/mirror/ports.ubuntu.com/ xenial-proposed main restricted universe
# apt-get update

Enable the vnc:

# qemu-system-aarch64 ...... -vga std -vnc 127.0.0.1:33

BenchMark

In arm ubuntu64, do following for benchmark testing:

# apt-get install hpcc
# cp /usr/share/doc/hpcc/example/_hpccinf.txt hpccinf.txt
##### Edit this file
# hpcc

You could easily see the output.