代码改变世界

tomato固件 路由简单玩 BT 电驴 amule highId python 其实dd wrt也一样 含 amule_2.2.6-1_mipsel.ipk下载

2011-11-27 20:23  chen.simon  阅读(1644)  评论(0编辑  收藏  举报

tomato固件 其实dd wrt也一样

1. 安装软件(python为例)

拷贝路由etc的所有文件及,目录道 移动硬盘的etc

mount -o bind <移动硬盘etc路径> /tmp/etc
mount -o bind <移动硬盘opt路径> /opt

解压缩 opt.tar.gz(在http://code.google.com/p/oleg-for-mss-base/downloads/list 下载)

找到ipkg

ipkg装好后再装python


root@tomato:/tmp/mnt/MD2/route_sw/opt/program/python26# ipkg install http://www.cnblogs.com/http://www.cnblogs.com/ipkg_packages/python26_2.6.7-1_mipsel.ipk
Installing python26 (2.6.7-1) to root...
Installing bzip2 (1.0.6-1) to root...
Downloading http://ipkg.nslu2-linux.org/feeds/optware/oleg/cross/stable/bzip2_1.0.6-1_mipsel.ipk
An error ocurred, return value: 1.
Collected errors:
Package bzip2 wants to install file /opt/bin/bzcat

/opt/bin/bzcat 重命名这个 即可


root@tomato:/opt# cd bin/
root@tomato:/opt/bin# ll | grep "python"
-rwxr-xr-x 1 root root 6120 Jun 9 06:04 python2.6*
-rwxr-xr-x 1 root root 1418 Jun 9 06:04 python2.6-config*
root@tomato:/opt/bin# python2.6
Python 2.6.7 (r267:88850, Jun 8 2011, 22:01:39)
[GCC 4.1.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 1+1
2
>>>
>>> exit
Use exit() or Ctrl-D (i.e. EOF) to exit
>>>
root@tomato:/opt/bin#

表明python成功安装

 


2. 电驴highid的玩法
贴个安装包把 2.2.6 稳定版

amule_2.2.6-1_mipsel.ipk

https://files.cnblogs.com/simoncook/amule2.2.6.zip

1. 重设电驴的tcp和udp端口 10001 10002
  2. 在路由上设置端口转发
  3. 在路由上的防火墙中放开这些端口10001 10002 10004 10005
root@tomato:/tmp/home/root# iptables -A INPUT -p tcp --dport 10001 -j ACCEPT
root@tomato:/tmp/home/root# iptables -A INPUT -p tcp --dport 10002 -j ACCEPT
root@tomato:/tmp/home/root# iptables -A INPUT -p tcp --dport 10004 -j ACCEPT
root@tomato:/tmp/home/root# iptables -A INPUT -p tcp --dport 10005 -j ACCEPT
root@tomato:/tmp/home/root#


aMulecmd$ status
> eD2k: Connected to TV Underground No1 [193.169.86.73:4184] with HighID
> Kad: Connected (firewalled)
> Download: 2.84 kB/s
> Upload: 236 bytes/sec

 

3. 在公网测试你的ip 

nohup python2.6 pySocketServer.py &
这样就能是进程 即使 退出这个终端 依然在后台运行

今天跟mc联机测试了下
在公网也是能通过tcp联通

但是有三点

1. server端代码bind 0.0.0.0ip(如下)

2. 要在路由中设置端口转发

3. 要在路由中的防火墙里开放这个端口

 


如果用python写的server端代码
bind的ip地址写0.0.0.0

 1 import socket 
2 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
3 sock.bind(('0.0.0.0', 8666))
4 sock.listen(5)
5 while True:
6 connection,address = sock.accept()
7 try:
8 connection.settimeout(60)
9 buf = connection.recv(1024)
10 if buf == '1':
11 connection.send('welcome to server!')
12 else:
13 connection.send('please go out!')
14 except socket.timeout:
15 print 'time out'
16 connection.close()

 

 

测试客户端

1 import socket 
2 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
3 sock.connect(('你路由公网ip', 8666))
4 import time
5 time.sleep(2)
6 sock.send('1')
7 print sock.recv(1024)
8 sock.close()



 =====================

2011/11/28

今天晚上回来 

发现amule又变成低id了

尝试再加了一次 防火墙中的列表

root@tomato:/tmp/home/root# iptables -A INPUT -p tcp --dport 10001 -j ACCEPT
root@tomato:/tmp/home/root# iptables -A INPUT -p tcp --dport 10002 -j ACCEPT
root@tomato:/tmp/home/root# iptables -A INPUT -p tcp --dport 10003 -j ACCEPT
root@tomato:/tmp/home/root# iptables -A INPUT -p tcp --dport 10004 -j ACCEPT
root@tomato:/tmp/home/root# iptables -A INPUT -p tcp --dport 10005 -j ACCEPT

就ok了

 

可以用 iptables -L查看