Friday, January 17, 2020

2016 -> 2028 移民12年的计划与回顾

起因:

- 国家: 对中国局势及国际形势迷惑,老龄化问题,对未来国内的稳定发展担忧;

- 自然环境: 基本生活要素, 如雾霾, 自来水质量,食物安全等

- 社会环境: 公权力的"为人民服务"实际是“为权贵服务”, 法律也是约束百姓,而献身于权贵/流氓

- 家庭: 对家庭利益考虑,学区/直升/课外坑班等乱象,北京学霸后代云集等

- 个人: 对个人职业前景担忧, 华为35岁现象;希望从大北京走向地球村

- 日常: 对日常环境的不爽: 如小区/市区停车难, 上下班路上痛苦, 996, 社会戾气, etc.

- 时间: 渴望给自己更多时间, 能过主动管理的生活, 而不是被动的时间被挤压的人生

- 互联网: GFW, 信息封闭



3年回顾:



Cons:

- 最大的后悔是对父母考虑不够, 无法弥补的伤痛和遗憾!

- 收入持平或略降, 但消费能力明显降级, 导致时间充裕了但选择并不能相应增加, 还有金钱的制约

- 需要自己DIY的事情增多, 无形占据很多时间, 如一日3餐, 草坪, 房屋维护, etc

- 社交圈子局限性, 主要是语言(和老外)和背景限制(不同时代/方式的移民群体差异很大)

- 国内还留有很多事情需要请假处理, 时间很不够.

- 毕竟是少数人口,还是能察觉对华人的歧视.

- 朋友少,目前主要结交校友,讲中文同事和球友.

- 医疗效率较低,临床经验不及国内一线大医院

- 蔬菜偏贵



Pros:

- 房子换成国外的院子和民居, 所有权999年, 感觉终于在这个世界有自己的立足之地了.

- 空气, 水等确实提高了, 喝水可以放心喝,适合对空气敏感的人群

- 工作相对轻松, 不用996, 拥有8小时之外的自由, 工作不再是全部,毕竟只占1/3时间.

- 有更多时间陪伴家庭,有时间直面内心,发现和发展自己的真实愿望

- 小孩上学基本不用太操心, 主要督促数学/中文.

- 食物放心

- 社会比较有序,大家普遍遵守规则,效率高

- 互联网自由,同时能接触西方最新的科技应用,并能直接获得MS, Google等的技术支持

- 医疗公费,提供最根本最急需的保障



Solution:

- 多实践英语听说, 达到顺畅交流的能力,具备通行西方英语世界的语言能力

- 业务能力达到专家级(与国内自我钻研不同,更强调沟通,能得到西方重要公司的技术支援),增加收入

- 寻找Remote work机会, 从此具备时空的自由.

- 需要主动扩展圈子, 否则太局限, 同时考虑华人的凝聚力,从而增加朋友,也参与华人政治

- 提高DIY能力, 解决日常生活常见问题,还有做饭水平

- 培养健康的兴趣爱好和户外运动,提高健康水平

- 提高国际政治素养,学习世界历史.

Sunday, January 29, 2017

ebooks

http://gen.lib.rus.ec/foreignfiction/index.php?s=&f_lang=English&f_columns=1&f_ext=mobi&f_group=1

http://www.e-reading.club/bookbyauthor.php?author=19233

Thursday, February 4, 2016

设置openwrt透明翻墙

- 目的:

         设置路由器,使内网机器,包括无线手机等设备,不做代理设置,透明翻墙.

- 环境:

         宽带: 歌华cable modem.
         路由器: TPlink WR720N
         OS: openwrt

- 步骤1 歌华上网, 设置笔记本上网

         用网线直连cable modem
         reset modem
         笔记本lan口获得地址192.168.100.2, 访问http://192.168.100.1,得到modem状态信息
         稍候,笔记本可访问internet,同时无法访问http://192.168.100.1

- 步骤2 设置路由器上网

         WR720N => 8M flash + 64M RAM

         刷机 openwrt:
         如果第一次刷openwrt:
       http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/openwrt-ar71xx-generic-tl-wr720n-v3-squashfs-factory.bin
         如果已经是openwrt:
http://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/openwrt-ar71xx-generic-tl-wr720n-v3-squashfs-sysupgrade.bin
        
         拿到手已通过taobao刷成openwrt预发版, 所以更新为正式版:
         /sbin/sysupgrade openwrt-ar71xx-generic-tl-wr720n-v3-squashfs-sysupgrade.bin
        
         设置路由器:
         访问http://192.168.1.1/ 获得路由器状态设置, 打开wifi,设置密码等.

         验证:
        笔记本上,chrome访问baidu.com成功.

         拓展学习:
                  bridge原理

- 步骤3 设置路由器上的ssh代理翻墙服务

opkg update
cd /usr/bin
         rm ssh
         rm scp
opkg install openssh-client openssh-keygen

         ssh -D 0.0.0.0:7070 jackchen@s06.publicssh.org -qTfnN

        验证:
        笔记本上,chrome设置socks5代理为192.168.1.1:7070,访问twitter.com成功.

         拓展学习:
                  自动ssh密码登陆, 设置为开机服务:
                            sshpass -p XXXXXX ssh -D 0.0.0.0:7070 jackchen@s06.publicssh.org -qTfnN
                  ssh tunnel原理
                  opkg 用法:
                  opkg list-installed 这个子命令可以列出所有安装的软件
                  opkg files dnsmasq-full

- 步骤4 设置透明翻墙

1)   ipset

         opkg install ipset
         opkg install iptables-mod-nat-extra
         ipset -N GFW iphash

2)   pdnsd

root@OpenWrt:/ # cat /etc/pdnsd.conf

global {
        perm_cache=2048;
        cache_dir="/var/pdnsd";
#       pid_file = /var/run/pdnsd.pid;
        run_as="nobody";
        server_ip = any;  # Use eth0 here if you want to allow other
                                # machines on your network to query pdnsd.
        server_port = 443;
        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;
}

# This section is meant for resolving from root servers.
server {
        label = "root-servers";
        root_server = on; # Query the name servers listed below
                                # to obtain a full list of root servers.
        randomize_servers = on; # Give every root server an equal chance
                                # of being queried.
        ip =    208.67.222.222,
                208.67.220.220;
#               8.8.4.4;
        port = 443; #因为opendns的端口是443
        timeout = 5;
        uptest = query;         # Test availability using empty DNS queries.
#       query_test_name = .;    # To be used if remote servers ignore empty queries.
        interval = 30m;         # Test every half hour.
        ping_timeout = 300;     # Test should time out after 30 seconds.
        purge_cache = off;
#       edns_query = yes;       # Use EDNS for outgoing queries to allow UDP messages
                                # larger than 512 bytes. May cause trouble with some
                                # legacy systems.
        exclude = .localdomain;
        policy = included;
        preset = off;
}

3)   dnsmasq + GFW.list

         opkg remove dnsmasq
         opkg install dnsmasq-full # dnsmasq-full support ipset

-          设置 dnsmasq GFW list使用opendns进行解析:
vi /etc/dnsmasq.conf
conf-dir=/etc/dnsmasq.d
mkdir /etc/dnsmasq.d
mv GFW.conf /etc/dnsmasq.d

GFW.conf的格式
server=/.twitter.com/127.0.0.1#443
ipset=/.twitter.com/GFW
Note:
指定匹配域名的dns服务器信息, 本例用本机提供pdnsd服务,端口443;
将匹配域名解析的ip放入GFW ipset, 后面要对这个GFW ipsetiptable rules 转发.

GFW数据来源:
         - 解码脚本: gen_gfwlist_for_dnsmasq.py

         重启dnsmasq服务
         etc/init.d/dnsmasq restart

         检查ipset内容
         ipset list GFW
        
         Note: 需要先digGFW中某条域名, 否则列表为空, 因为没有解析过程, 也就没有匹配打GFW标签.
        
         dig @127.0.0.1  twitter.com
         /* 此处要用缺省地址/端口的dns服务, 也就是dnsmasq提供的dns服务 */
         dig @208.67.220.220 -p443 www.twitter.com  /* opendns443 udp查询 */
       dig @208.67.220.220 -p443 +tcp www.twitter.com /* opendns443 tcp查询 */
         dig @127.0.0.1 -p443 twitter.com /* 用本机的pdnsd 443 查询 */
       
         对比下污染的dns:
        

         至此, 已解决DNS污染的问题. 总结思路:
         - dnsmasq(转发pdnsd, 打标签)
         - pdnsd(通过tcp转发到opendns DNS)
         - 现在能解决的UDP dns解析污染的问题, 如果opendns被墙,则考虑将opendns IP手动加入ipset GFW.

         References:
         - https://use.opendns.com/  Put in the OpenDNS server addresses, 208.67.222.222 and 208.67.220.220, as your DNS server settings and save/apply.
         - http://www.jianshu.com/p/8b130d8ca804  ShadowSocks搭配pdnsdDNSmasq科学上网

         拓展学习:
                   ipset
                   DNSCrypt? https://www.opendns.com/about/innovations/dnscrypt/

4)   redsocks

用过squid的读者应该知道,用squidiptables来实现上面的需求很简单,首先在服务端squid.conf中的port选项后增加“transparent”字段,然后将相应请求用iptables redirect到端口即可。
iptables -t nat -A PREROUTING -p tcp --dport 80 -d xx.xx.xx.xx -j REDIRECT --to-port 3128
SSH建立的socks代理不具备这样的功能,只能通过第三方的软件来扩展。redsocks是我目前发现在这方面最好的软件。
redsocks的官方说明:
This tool allows you to redirect any TCP connection to SOCKS or HTTPS proxy using your firewall, so redirection is system-wide.

vi /etc/redsocks.conf
redsocks {
        local_ip = 0.0.0.0;
        local_port = 12345;
        ip = 127.0.0.1;
        port = 7070;
        type = socks5;
}
iptables -t nat -N REDSOCKS
iptables -t nat -A REDSOCKS -d 127.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -p tcp -j REDIRECT --to-ports 12345
#iptables -t nat -A OUTPUT -p tcp -j REDSOCKS
iptables -t nat -A OUTPUT -p tcp  -m set --match-set GFW dst -j REDIRECT --to-port 12345

5)   iptables设置自动转发到redsocks:

         iptables -t nat -A PREROUTING -p tcp -m set --match-set GFW dst -j REDIRECT --to-port 12345

         拓展学习:
                  iptables
                            - 转发?
                            - PREROUTING, INPUT, FORWARD, OUTPUT, POSTROUTING
                            - filter, nat, mangle, raw
            iptables -t nat -F    //清空nat表所有规则  
                  透明代理:
                            - shodowsocks
                            - redsocks
                            - squid

- 调试

         拓展学习:
                  tcpdump
                  netcat/socat
                  ngrep
         References:
                   http://wiki.openwrt.org/doc/devel/debugging OpenWRT Debugging

- References:

http://www.router008.com/OpenWrt-SSH.htmlWALL篇(三)OpenWrt SSH代理配置
http://107.191.119.228/blog/?p=304基于SSH Tunnel的科学上网思路