九原山区

WR703N OpenWrt 配置流程

下载安装

访问WR703N在OpenWrt的Wiki页,然后在Flashing一节中找到下载链接:squashfs-factory.bin,下载后别忘了比对md5[1]

进入路由器管理界面,出厂配置为http://192.168.1.1,用户名和密码均为admin,然后进入固件更新,选择下载的文件,然后更新。

等待一段时间(~~2min),然后重启路由。

P.S. 官方固件不带WebUI,所以需要对Linux系统较为熟悉,否则可以选择国内有人编译的带LuCI和中文支持的版本,Google即可。

初始配置[2]

首先用一根网线将703N的Lan口和你电脑相连,电脑上设置为DHCP模式。然后

telent 192.168.1.1

成功后出现OpenWrt的欢迎界面:

BusyBox v1.19.4 (2012-05-05 05:41:33 MST) built-in shell (ash)
Enter 'help' for a list of built-in commands.

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------

然后更改root密码:

passwd root

更改root密码后dropbear(SSH 服务)就运行了,输入exit退出telent,然后

ssh root@192.168.1.1

以后就可以通过ssh管理OpenWrt.

网络配置

OpenWrt官方的固件是不带LuCl的,所以初始的网络设定需要在命令行下完成 首先备份相关配置,防止出错:

cp /etc/config ~/ -r

然后用vi修改相关配置(不会用vim的同学悲剧了)。 首先修改/etc/config/wireless文件,注释掉

# option disabled 1

然后修改/etc/config/network文件[3],首先修改lan接口配置,注释掉此行:

# option ifname 'eth0'

然后增加wan接口,如果你上级网络是DHCP的,则文件的末尾添加:

config interface 'wan'
    option ifname 'eth0'
    option proto 'dhcp'

如果你上级网络是静态IP,则在文件的末尾添加:

config interface 'wan'
    option ifname 'eth0'
    option proto 'static'
    option ipaddr '10.22.33.124'
    option netmask '255.255.255.0'
    option gateway '10.22.33.1'
    option dns '202.113.16.10'

然后将路由器的Lan/Wan口接到上级网络中,重启路由器。这时便可以通过电脑寻找SSID为 OpenWrt的无线网络,加入后便可以通过:

ssh root@192.168.1.1

来连接路由器。此时703N为无线路由模式,电脑便可以通过703N上网了。

安装软件

然后便可以用大名鼎鼎的opkg包管理系统。主要命令:

# 查看帮助
opkg help
# 更新数据库,必做
opkg update
# 列出已安装的包
opkg list-installed
# 安装LuCI,我就不选择装了,命令行很好
# 参见 http://wiki.openwrt.org/doc/howto/luci.essentials
opkg install luci

各种配置以后补充。暂时先这么用着。另外703N的RAM只有32M,ROM只有4M,所以能做的事情很少。倒是有人换RAM和ROM芯片的,淘宝上RAM和ROM加倍的只卖150元,喜欢OpenWrt的同学可以考虑一下。

TODO

  1. VPN 无痛翻墙
  2. GoAgent 无痛翻墙
  3. 无线中继
  4. 脱机下载
  5. 3G无线网卡支持

F.A.Q

  1. 无线加密,修改/etc/config/wireless文件,参见[4]。配置wpa加密需要修改config wifi-iface段。

     option ssid OpenWrt
     option encryption psk2
     option key        'secret passphrase'
    
  2. 出现路由端可以ping可以上网,而电脑不能上的问题。电脑端ping结果:

     From 192.168.1.1: icmp_seq=1 Destination Port Unreachable
    

    这时只需要重启firewall服务即可。

     /etc/init.d/firewall restart
    

参考文献

  1. http://wiki.openwrt.org/toh/tp-link/tl-wr703n
  2. http://wiki.openwrt.org/doc/howto/firstlogin
  3. http://wiki.openwrt.org/doc/uci/network
  4. http://wiki.openwrt.org/doc/uci/wireless
Comments

ArchBang 2011.11 安装笔记

ArchBang是一个不错的Archlinux定制版本,但它最新的iso为2011.11版。而Archlinux在此后有一些需要手动升级的部分,见News,如果不按照News上的步骤来,很有可能就会出现各种奇妙的问题。

本文就简单把ArchBang的相关配置流程过一遍,大家只需要Ctrl+CCtrl+V即可。

安装更新

ArchBang安装完成进入桌面后,第一步先删除掉显卡驱动

#移除所有显卡驱动(直到下一节安装驱动,不要重启。。。当然重启倒也没什么)
sudo pacman -R xf86-video-apm xf86-video-ark xf86-video-ast\
xf86-video-ati xf86-video-chips xf86-video-cirrus\
xf86-video-dummy xf86-video-fbdev xf86-video-glint\
xf86-video-i128 xf86-video-i740 xf86-video-intel\
xf86-video-mach64 xf86-video-mga xf86-video-neomagic\
xf86-video-nv xf86-video-r128 xf86-video-rendition\
xf86-video-s3 xf86-video-s3virge xf86-video-savage\
xf86-video-siliconmotion xf86-video-sis xf86-video-sisusb\
xf86-video-tdfx xf86-video-trident xf86-video-tseng\
xf86-video-v4l xf86-video-vesa xf86-video-vmware\
xf86-video-voodoo xf86-video-xgi xf86-video-xgixp\
ati-dri intel-dri mach64-dri mga-dri r128-dri\
savage-dri sis-dri tdfx-dri

然后更新系统,步骤如下:

pacman -Syy
pacman -S pacman
mv /etc/pacman.conf.pacnew /etc/pacman.conf
pacman-key --init
pacman -S filesystem --force
#因为cairo系列主干已经merge了Ubuntu的补丁,故去除掉*-ubuntu。
#如果不想移除的话,务必要重新编译安装cairo-ubuntu
pacman -S --asdeps freetype2 libxft cairo fontconfig
pacman -S librsvg
pacman -Syu

配置系统

  1. 配置显卡驱动

     rm /etc/X11/xorg.conf.d/20-gpudriver.conf
     #找到显卡型号
     lspci | grep VGA
     #搜索软件包
     pacman -Ss xf86-video | less
     #安装相应的驱动
     pacman -S your_video_driver
     #删掉内核参数'nomodeset'(开启KMS)
     nano /boot/grub/menu.lst 
    
  2. 安装yaourt

     wget https://aur.archlinux.org/packages/pa/package-query/package-query.tar.gz
     wget https://aur.archlinux.org/packages/ya/yaourt/yaourt.tar.gz
     tar zxvf xx.tar.gz
     makepkg -s
     sudo pacman -U xx.xz
     #[可选]加速makepkg
     sudo pacman -S axel
     #edit /etc/makepkg.conf
     DLAGENTS=('ftp::/usr/bin/axel -n 20 -a -o %o %u'
               'http::/usr/bin/axel -a -n 20 -o %o %u'
               'https::/usr/bin/axel -a -n 20 -o %o %u'
               ...
    
  3. 安装VIM

     sudo pacman -S gvim
     #中文文档
     yaourt -S aur/vimcdoc-svn
     #基本vimrc
     set nocompatible
     syntax enable
     set encoding=utf-8
     set showcmd                     " display incomplete commands
     filetype plugin indent on       " load file type plugins + indentation
    
     "" Whitespace
     set nowrap                      " don't wrap lines
     set tabstop=2 shiftwidth=2      " a tab is two spaces
     set expandtab                   " use spaces, not tabs
     set backspace=indent,eol,start  " backspace through everything in insert mode
    
     "" Searching
     set hlsearch                    " highlight matches
     set incsearch                   " incremental searching
     set ignorecase                  " searches are case insensitive...
     set smartcase                   " ... unless they contain at least one capital letter
    
  4. 中文配置

     #[可选]add locale to `.xinitrc`(for slim)
     export LANG=zh_CN.UTF-8
     export LC_ALL="zh_CN.UTF-8"
     #view font list
     fc-list | sed 's,:.*,,' | sort -u
     #install wqy-microhei
     yaourt -S aur/wqy-microhei
    
  5. fcitx输入法

     sudo pacman -S fcitx
     #add this to `.profile`(通用)/`.xinitrc`(slim/startx)/`.xprofile`(gdm/kdm)
     #setup XIM environment, needn't if use SCIM as    gtk-immodules
     export XMODIFIERS="@im=fcitx"
     export GTK_IM_MODULE=xim
     export QT_IM_MODULE=xim
     #add this to `.config/openbox/autostart`
     killall fcitx
     fcitx &
     #英文locale下fcitx会在gtk2程序内无法激活,解决办法见下一节
    

Bugs

  1. 英文locale下fcitx会在gtk2程序内无法激活

     #http://fcitx.github.com/handbook/faq.html#ctrl_space
     gtk-query-immodules-2.0 > /etc/gtk-2.0/gtk.immodules
     #edit gtk.immodules
     "xim" "X Input Method" "gtk20" "/usr/share/locale" "en:ko:ja:th:zh"
    
  2. (Maybe)IPV6 not work.

     vim /etc/modprobe.d/modprobe.conf
     #comment next line
     blacklist ipv6
    
Comments

Octopress在ArchLinux上的安装笔记

使用GoAgent加速安装

国内尤其是教育网出国的速度很慢,而且还要时不时受墙的干扰。感谢Google和GoAgent,给了这些迷途羔羊以光明。

安装GoAgent[3]的过程此处不提,只谈谈如何在命令行设置http代理,此时curl/wget/rvm/gem/bundle均会自动适用。

# 设定http和https代理,指向GoAgent
export http_proxy='http://127.0.0.1:8087'
export https_proxy=$http_proxy
# 让curl永久忽略SSL错误
echo insecure >> ~/.curlrc
# 让git clone时忽略SSL错误(必须clone的是https源)
export GIT_SSL_NO_VERIFY=true
# 全局设定
git config --global http.sslVerify false
# OK,其他的不用设定了,比如rvm 会调用curl来下载。

安装Ruby环境

#安装 git
sudo pacman -S git
#安装 rvm[2]
curl https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable
# 在 .bashrc/.zshrc 加入RVM函数
echo '[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm' >> ~/.zshrc
source ~/.zshrc
# 安装依赖包(下面命令会输出一个指南,直接复制其中的命令就行):
rvm requirements
# 比如ArchLinux上一步会输出:
sudo pacman -Sy --noconfirm gcc patch curl zlib readline libxml2 libxslt git autoconf automake diffutils make libtool bison subversion
# 安装ruby 1.9.2 并使用
rvm install 1.9.2 && rvm use 1.9.2
# 保持rubygems最新
rvm rubygems latest
# 检查ruby版本是否为1.9.2
ruby -v

安装Octopress

# clone octopress
git clone https://github.com/imathis/octopress.git octopress
cd octopress
# 安装依赖
gem install bundler
bundle install
# 安装默认主题
rake install
# 设定octopress,参见[4]
# ......
# 生成博客
rake generate #生成
rake watch    #实时观察变更
rake preview  #在http://localhost:4000上预览
# 配置github
rake setup_github_pages #按提示操作即可
# 推送博客
rake deploy
# 或者
rake push

Bugs

  1. rake generate时报错

     rake aborted!
     You have already activated rake 0.9.2.2, but your Gemfile requires rake 0.9.2. Using bundle exec may solve this.
    

    这是因为Gemfile.lock不更新的原因,用bundle update可更新,但octopress不推荐更新Gemfile.lock。解决办法是用以下命令来替代:

     # 其他rake命令也要如此,直到上游更新了Gemfile.lock。
     bundle exec rake generate
    
  2. 其余可能出现的bug:

    1. http://blog.gonzih.org/blog/2011/09/21/fix-octopress-pygments-error-on-arch-linux/
    2. http://jgarber.lighthouseapp.com/projects/13054/tickets/245-error-installing-redcloth-428

Reference

  1. http://octopress.org/docs
  2. http://beginrescueend.com/rvm/install/
  3. https://code.google.com/p/goagent/
  4. http://octopress.org/docs/configuring/
Comments

HuamiDroid – 花密Android版本(自用)

花密原始项目:https://code.google.com/p/flower-password/

花密介绍参见我的上一篇文章

整个项目主要是自用,本来也想像模像样的写个android版本的,后来正好想起PhoneGap,于是偷懒直接用这个了(不直接用webview的原因是复制功能不好实现)

开发时间,包括下载phonegap,看文档,下剪贴板扩展。。。剪裁整个花密web版的页面,只要1个小时。

以后有时间了就自己做个页面好了,不过现在整个页面的版权还归原始花密项目所有。

P.S. PhoneGap还是有点慢,打开应用的时候有点延迟。

项目地址: https://github.com/ninehills/HuamiDroid

Comments

花密Python CLI版本

最近CSDN、天涯等一大批网站帐号、邮箱以及明文密码泄漏,再次提醒大家注意密码安全。

当下比较安全的密码方案是用LastPass/KeePass之类的软件生成随机密码,然后用主密钥加密保存。但这样有个很大的缺点,就是在移动设备或公共电脑等不方便访问加密数据库的时候,随机密码则过于复杂,无法使用。

吾的解决办法就是依然用LastPass保存密码,但用单独的密码生成器来生成随机密码。

PASSWORD = getPass(password, identifier)

其中password是简单的记忆密码,identifier是各个网站和应用的标识字。然后通过不可逆的getPass方法便得到密码PASSWORD。这样即使某个网站的密码泄漏,也不会泄漏记忆密码,从而保证了其他网站密码的安全性。

花密

getPass方法有现成的实现,就是HMAC,本文标题中的花密则是基于HMAC上的自定义算法,主要是能够生成包含大写字母的16位密码,更适合做密码使用。同时花密还提供了在线版、离线版、Userscript插件版、Chrome扩展版、Windows软件版等多个版本,当然本文也提供了CLI版本,适合在控制台上使用。

好了,闲话不多说,花密的其他版本很容易在官方主页上找到(这里),而本人提供的CLI版本在这里,需要Python 2.6+环境。

使用方法

$ git clone git://github.com/ninehills/huami-cli.git
$ cd huami-cli
$ ./huami.py KEY
Password:
KEF2342511421312

可以结合xclip,比如

./huami.py KEY | xclip -i

便可将密码复制到X剪切板。

其他

花密的加密办法在吾看来有几处不令人满意的地方:

  • 生成的密码不含特殊字符
  • 生成密码的位数为16位,在某些网站不能使用
  • HMAC的key和msg的概念貌似让作者给弄反了,虽然吾也不知道这样会不会对安全有影响。

所以如果不想使用他人的加密算法的话,可以自己在花密的基础上定制自己的算法,因为一切都是BSD授权的,所以尽可以自由修改。而这也是开源软件的优势所在。

Comments