2013年8月2日星期五

更改DD-WRT默认管理端口和修改Nocatsplash端口的方法

telnet到路由,用nvram命令更改httpd以及ssh服务的端口。
具体方法是: 
代码:
# telnet 192.168.1.1
# nvram set rc_startup="
> killall httpd
> cd /www
> httpd -p 81 -h /www
> dropbear -b /tmp/loginprompt -r /tmp/root/.ssh/ssh_host_rsa_key -d /tmp/root/.ssh/ssh_host_dss_key -p 80
> "
# nvram commit
输入第二行(nvram set rc_startup=")后,提示符会从#变成>,这时候再输入需要自动执行的命令,最后输入双引号回车结束
nvram commit是把刚才需要执行的命令保存到路由的flash,这样掉电重启才有用
另外可以用nvram get rc_startup查看输入的命令是否正确)



DD-WRT开启Nocatsplash通告功能
root@Router:~# nvram show | grep NC_
NC_Verbosity=2
NC_RenewTimeout=0
NC_SplashURL=http://www.xin100.com/splash.html  #没法修改内置通告文件的内容,所以只好引用外部地址
NC_MaxMissedARP=5
NC_MACWhiteList=
NC_DocumentRoot=/www
NC_ifname=br0
NC_LeaseFile=/tmp/nocat.leases
NC_RouteOnly=1
NC_GatewayPort=5280
NC_SplashURLTimeout=180  #一个超时计时器,酌情调节。(单位是秒)
NC_IncludePorts=53 80 443  #这是允许的端口列表,只能在telnet下调,这么设置【nvram set NC_IncludePorts="53 80 443"】,内容加引号,端口之间用空格分隔。
NC_GatewayName=Free Wi-Fi
NC_ExcludePorts=  #排除端口,上面允许端口设置完了,这里就不要设了
NC_enable=1
size: 22038 bytes (10730 left)
NC_GatewayAddr=192.168.1.1  #网关地址(这个是本地LAN口IP)
NC_LoginTimeout=120  #又一个超时计时器,酌情调节。(单位是秒)
NC_GatewayMode=Open
NC_IdleTimeout=0
NC_ForcedRedirect=0
NC_AllowedWebHosts=acctc.com