2017年9月13日星期三

raspberry pi stuck when booting, after serial console print "EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)",solution is fsck ur cf/sd card file system

Directly power up/down(have not execute shutdown -h -P now in shell), my raspberry pi cannot startup finally... serial console info print like below, after that, the serial console have no responsed.
[ 5.546612] bcm2708_spi bcm2708_spi.0: master is unqueued, this is deprecated [ 5.681943] bcm2708_spi bcm2708_spi.0: SPI Controller at 0x20204000 (irq 80) [ 6.846068] bcm2708-i2s bcm2708-i2s.0: Failed to create debugfs directory [ 7.866923] usbcore: registered new interface driver rtl8192cu [ 10.152477] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
google tell me a solution: fsck file system on cf/sd card. http://raspberrypi.stackexchange.com/questions/24592/rpi-freezes-after-booting Alright, unplug cf/sd card and insert to a USB card reader, then mount it under my ubuntu 14.04 OS pc, then execute fsck, all done.
[ 5.546612] bcm2708_spi bcm2708_spi.0: master is unqueued, this is deprecated [ 5.681943] bcm2708_spi bcm2708_spi.0: SPI Controller at 0x20204000 (irq 80) [ 6.846068] bcm2708-i2s bcm2708-i2s.0: Failed to create debugfs directory [ 7.866923] usbcore: registered new interface driver rtl8192cu [ 10.152477] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)

Mapping remote ESXi VM serial port to local serial port via ethernet

Topology:
 VM(Linux with Serial Port /dev/ttyS0)---------Ethernet----------Login remote VM with Local Serial Port(PC with SerialPort /dev/ttyUSB0)

1. First of all, if the requirement is telnet to remote VM's serial port, the only thing you need to do is set esxi serial port as below, the use telnet ip 10001 to login, NOT need following all step next.

2. If the requirement is use remote serial port as same as local serial port, then download https://elifulkerson.com/projects/downloads/tsb-release/tsb-client.py script document is here: https://elifulkerson.com/projects/telnet-serial-bridge.php

3. Install python libary:pip install pyserial
Insert #!/usr/bin/python2.7  to tsc-client.py first line.
set file format to unix by vi/vim, :set ff=unix or :%s/^M//g (https://stackoverflow.com/questions/82726/convert-dos-line-endings-to-linux-line-endings-in-vim(https://stackoverflow.com/questions/82726/convert-dos-line-endings-to-linux-line-endings-in-vim)
sudo ./tsb-client.py -p '/dev/ttyS0' -r 57600 -b 1 -c 10001 -i [VM's esxi host ip]

2015年7月22日星期三

iptables filter DNS AAAA query on VPS

Host PC that support IPv6 protocol query a domain name procedure is send AAAA DNS query first, then A DNS record, that would delay response time, because most of website cannot support ipv6 and that they doesnot have ipv6 domain record, we need suppressed AAAA dns query before all of website enabled ipv6 protocol.
First I have tried to disable ipv6 on my host pc by executed "echo 1 > /proc/sys/net/ipv6/all/disable_ipv6​" but it not work, then I have trying to drop AAAA dns query on my intermediate NAT& VPN device, following is the method that work fine to me.
Reference:
http://stackoverflow.com/questions/14096966/can-iptables-allow-dns-queries-only-for-a-certain-domain-name​
https://github.com/oskar456/xt_dns/issues/1​

Method 1: Use iptables extension xt_dns to match dns query type

step 1. download xt_dns iptables extension module source code from here:
http://software.klolik.org/xt_dns/​​
or: https://github.com/oskar456/xt_dns​
step 2. Compile & install .so file(How to compile iptables xt mod? reference here: https://github.com/netoptimizer/IPTV-Analyzer/blob/master/iptables-module/README.compile)
step 3. insmod *.so file and added iptables rules depend on ur need, following url is example, don't forget save it.
​​​​​http://software.klolik.org/xt_dns/#example
Beacause I do not have permission to  insmod  iptables on my vps, I have use then next method right now, it's works fine.

Method 2: Use iptables --match-set(-m) option

iptables -N AAAA​
iptables -I FORWARD 1 -p udp -s 192.168.0.0/16 --dport 53 -j AAAA
iptables -A AAAA -m string --algo bm --from 40 --hex-string '|001c|' -j DROP
reference: 'man iptables-extensions' then search 'string'

2015年5月22日星期五

Use rsync clone VMs between ESXi

Before all, make sure enabled ssh and shell on esxi host already.

1. Download rsync for esxi binary file from:
https://damiendebin.net/blog/2013/12/06/esxi-5-dot-1-and-rsync/

2. ssh to esxi host and upload(use sftp) rsync-static.


3. Enable ssh port on esxi host firewall

Login vsphere client->Configuration->Security Profile->Properies->Secure Shell->ssh client, and check it on

4. Use rsync-static transfer vmdk files.
./rsync-static --partial --progress --rsh=ssh  -r 'root@x.x.x.x:/vmfs/volumes/datastore1/' .

Reference link:
https://www.digitalocean.com/community/tutorials/how-to-use-rsync-to-sync-local-and-remote-directories-on-a-vps