2016年9月14日星期三

Debian安装wordpress好简单啊

rt

openwrt完整备份(转自v2ex)

第一种方法:

1.cat /proc/mtd
查看 firmware 分区所对应的 mtd 设备,比如:
dev:    size   erasesize  name
mtd0: 00040000 00020000 "u-boot"
mtd1: 00040000 00020000 "u-boot-env"
mtd2: 00040000 00020000 "caldata"
mtd3: 00080000 00020000 "pot"
mtd4: 00200000 00020000 "language"
mtd5: 00080000 00020000 "config"
mtd6: 00300000 00020000 "traffic_meter"
mtd7: 00200000 00020000 "kernel"
mtd8: 07700000 00020000 "ubi"
mtd9: 07900000 00020000 "firmware"
mtd10: 00040000 00020000 "caldata_backup"
这里就是mtd9
2.dd if=/dev/mtd9 of=/tmp/firmware_backup.bin
得到固件备份文件 firmware_backup.bin,在/tmp 目录下
3.恢复该固件:
firmware_backup.bin 上传至 /tmp,使用命令 mtd -r write /tmp/firmware_backup.bin firmware 即可恢复,恢复完成路由器会自行重启。

第二种方法:

如果在没有重刷固件的情况下,我建议仅对 /overlay 进行打包并备份:
tar -czvf /tmp/overlay_backup.tar.gz /overlay
然后下次直接将 overlay_backup.tar.gz 上传至 /tmp ,然后清空 /overlay 并恢复备份:
rm -rvf /overlay/* 

cd / && tar -xzvf /tmp/overlay_backup.tar.gz

openwrt支持ipv6的配置

系统:15.05
     /ect/config/network:

config interface 'loopback'
        option ifname 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config globals 'globals'
        option ula_prefix 'fd3c:2dd9:5114::/48'

config interface 'lan'
        option ifname 'eth0'
        option force_link '1'
        option type 'bridge'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask '255.255.255.0'
        option ip6assign '60'

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

config interface 'wan6'
        option ifname 'eth1'
        option proto 'dhcpv6'

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '1'

config switch_vlan
        option device 'switch0'
        option vlan '1'
        option ports '0 1 2 3 4'

/etc/config/dhcp:


config dnsmasq
        option domainneeded '1'
        option boguspriv '1'
        option filterwin2k '0'
        option localise_queries '1'
        option rebind_protection '1'
        option rebind_localhost '1'
        option local '/lan/'
        option domain 'lan'
        option expandhosts '1'
        option nonegcache '0'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option resolvfile '/tmp/resolv.conf.auto'
        option localservice '1'

config dhcp 'lan'
        option interface 'lan'
        option start '100'
        option limit '150'
        option leasetime '12h'
        option dhcpv6 'hybrid'
        option ra 'hybrid'
        option ndp 'hybrid'

config dhcp 'wan'
        option interface 'wan'
        option ignore '1'

config odhcpd 'odhcpd'
        option maindhcp '0'
        option leasefile '/tmp/hosts/odhcpd'
        option leasetrigger '/usr/sbin/odhcpd-update'

config dhcp 'wan6'
        option interface 'wan'
        option dhcpv6 'hybrid'
        option ra 'hybrid'
        option ndp 'hybrid'
        option master '1'

利用supervisor实现shadowsocks-libev的多用户

系统:Debian 8
安装shadowsocks-libev的过程就不再说了。

首先,安装supervisor:

apt-get update
apt-get install supervisor

之后,进行配置:

1、显示配置文件示例:

echo_supervisord_conf

2、保存配置文件: 

echo_supervisord_conf > /etc/supervisord.conf
rm -rf  /etc/supervisor

3、修改配置文件:

vim /etc/supervisord.conf
一般只需要添加程序段就行了:
 [program:ssuser1]  (画横线的地方是进程名字,随便定义。)
command:ss-server -c /etc/shadowsocks-libev/user1_config.json -u -A
process_name=ssuser1
redirect_stderr=true    
stdout_logfile_maxbytes=1MB 
stdout_logfile_backups=1 

 [program:ssuser2]  (画横线的地方是进程名字,随便定义。)
command:ss-server -c /etc/shadowsocks-libev/user2_config.json -u -A
process_name=ssuser1
redirect_stderr=true    
stdout_logfile_maxbytes=1MB 
stdout_logfile_backups=1


4、设置supervisor开机启动

vim /etc/rc.local
添加下面命令:
supervisord -c /etc/supervisord.conf
exit 0


5、通过supervisorctl进行管理

supervisorctl:
add命令可以使你添加到配置文件的进程生效;
clear命令可以清空日志;
fg命令可以使进程前台;
open命令可以连接到supervisord;
quit和exit命令可以离开supervisorctl命令窗;
remove可以从配置中移除进程;
restart,start,stop等命令可以重启,启动,停止进程;
avail命令显示所有正在管理的进程;
maintail查看supervisor日志;
pid命令用来获取supervisord或管理的进程的pid;
reload命令重启supervisord;
reread重新载入配置文件;
shutdown命令关闭supervisord;
status命令可以查看所有管理的进程的状态;
tail命令可以查看进程的输出;
version命令可以查看supervisord的版本。

2016年9月13日星期二

OpenWrt的DNS相关设置



一、 WANDNS设置。

WANDNS主要控制路由器访问网络使用的DNS服务器。例如,路由器安装软件需要访问网络,那么所使用的DNS服务器就是这个。
这个设置也相对简单。
登录到192.168.1.1,选择网络->接口,点击WAN口后面的修改,然后取消勾选使用端局通告的DNS服务器,再在“使用自定义的DNS服务器”后面填上要使用的DNS服务器(例如1.2.4.88.8.8.8等)。之后保存并应用就可以了。




回到状态页面,就可以看到DNS修改成功了。

二、 LANDNS设置

LANDNS主要控制连接到路由器的设备使用的DNS。例如,连到路由的电脑上网时使用的DNS服务器就在这里设置。
首先ssh到路由器上,修改以下几个文件。
我把修改好的配置贴出来:
1/etc/config/dhcp  (注:不需要ipv6的话只要修改config dnsmasq下面的内容就可以了。后面的我之前为了使用ipv6做了修改。)
config dnsmasq
        option domainneeded '1'
        option boguspriv '1'
        option localise_queries '1'
        option rebind_protection '1'
        option rebind_localhost '1'
        option local '/lan/'
        option domain 'lan'
        option expandhosts '1'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option resolvfile '/etc/resolv.dnsmasq.conf'   (如果希望和WAN口保持一致,就不用修改这一行了,下面的第2步也可以跳过。)
        option localservice '1'
        option cachelocal '1'
        option cachesize '5000'
        option dhcpleasemax '20'
        option expandhosts '1'
        option filterwin2k '1'
        option nonegcache '1'
        option strictorder '1'
config dhcp 'lan'
        option interface 'lan'
        option start '100'
        option limit '150'
        option leasetime '24h'
        option dhcpv6 'hybrid'
        option ra 'hybrid'
        option ndp 'hybrid'

config dhcp 'wan'
        option interface 'wan'
        option ignore '1'

config odhcpd 'odhcpd'
        option maindhcp '0'
        option leasefile '/tmp/hosts/odhcpd'
option leasetrigger '/usr/sbin/odhcpd-update'

config dhcp 'wan6'
        option interface 'wan'
        option dhcpv6 'hybrid'
        option ra 'hybrid'
        option ndp 'hybrid'
        option master '1'
2、新建/etc/resolv.dnsmasq.conf:   (注:nameserver可以根据自己的需要添加或删除或修改)
nameserver 1.2.4.8
nameserver 8.8.8.8
nameserver 2001:4860:4860::8888        
3、在web界面(系统->启动项)重启dnsmasq

三、为192.168.1.1设置域名

我想通过o.cn访问路由器管理界面,怎么办?
ssh到路由器上,修改/etc/hosts,添加一行:
192.168.1.1 o.cn
之后再重启dnsmasq,通过浏览器输入o.cn就进入192.168.1.1了。
~