找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 70445|回复: 72

openwrt 里面的*和 * 设置教程,终于可以方便上网了

 火.. [复制链接]
发表于 2014-5-16 16:19 | 显示全部楼层 |阅读模式
增加简单版本,

1 使用 haxc 大大的 r38621:版本固件 因为在 服务->菜单里面 有red------------sock2, s-s, pdnsd (实际上不需要red------------sock2) , 还有在服务->菜单 里面的每个项 名词就是叫luci菜单.   意思是首先需要在openwrt里面命令行安装某个服务功能,然后再安装luci的界面部分. 这样就可以通过路由菜单就能控制了.

绝版 r38621 下载 http://pan.baidu.com/s/1kTspLqf (里面有两个版本 一个针对水星MW4530r 的 一个是针对 TP-link WDR4320 我教程里面刷的是 openwrt-ar71xx-generic-tl-wdr4310-v1-squashfs-factory38621-16m)

2 设置s-s 按下面的图设置就可以.

注意不要设置 SOCK5 启动,就是不要勾选启动.  只要透明代理勾选即可.   端口号按图上设置即可, 也可以自己随便设置,大于10000比较好,以免冲突


这里有一些公益的服务器https://www.s-s.net/

3 关闭 red------------sock2(red------------sock)  因为s-s 1.4.2后本身就带了透明代理功能


4 设置pdnsd
ip 改为8.8.8.8 google DNS 即可 其实不改也可以. 或换其他的DNS.
端口号要改成1053



此时已经可以上国外的网站了,但只有三个网站上不去youtbue,facebook,twitter

5 设置dnsmasq
修改/etc/dnsmasq.conf   在该文件里面最后 加入一行 conf-dir=/etc/dnsmasq.d

然后新建一个目录 mkdir /etc/dnsmasq.d
/etc/dnsmasq.d目录里面新建一个文件 vim gfw.conf


写入  以下DNS

#Google and Youtube
server=/.google.com/127.0.0.1#1053
server=/.google.com.hk/127.0.0.1#1053
server=/.gstatic.com/127.0.0.1#1053
server=/.ggpht.com/127.0.0.1#1053
server=/.googleusercontent.com/127.0.0.1#1053
server=/.appspot.com/127.0.0.1#1053
server=/.googlecode.com/127.0.0.1#1053
server=/.googleapis.com/127.0.0.1#1053
server=/.gmail.com/127.0.0.1#1053
server=/.google-analytics.com/127.0.0.1#1053
server=/.youtube.com/127.0.0.1#1053
server=/.googlevideo.com/127.0.0.1#1053
server=/.youtube-nocookie.com/127.0.0.1#1053
server=/.ytimg.com/127.0.0.1#1053
server=/.blogspot.com/127.0.0.1#1053
server=/.blogger.com/127.0.0.1#1053

#FaceBook
server=/.facebook.com/127.0.0.1#1053
server=/.thefacebook.com/127.0.0.1#1053
server=/.facebook.net/127.0.0.1#1053
server=/.fbcdn.net/127.0.0.1#1053
server=/.akamaihd.net/127.0.0.1#1053

#Twitter
server=/.twitter.com/127.0.0.1#1053
server=/.t.co/127.0.0.1#1053
server=/.bitly.com/127.0.0.1#1053
server=/.twimg.com/127.0.0.1#1053
server=/.tinypic.com/127.0.0.1#1053
server=/.yfrog.com/127.0.0.1#1053



保存后  重启 pdnsd 和 dnsmasq

/etc/init.d/pdnsd restart
/etc/init.d/dnsmasq restart


设置 pdnsd的路由器开机自动启动  (也可以在路由器界面 “系统”-》“启动项” 设置 重启和开机启动)
/etc/init.d/pdnsd restart  enable


一切完成 真不容易啊。



以下是复杂的详细版本



在经历和翻遍了网站上所有教程后终于有所收获,可以路由器自动上上不去的网站了。

刷了12.09.1 r38621 by Haxc | 后  其实就可以fan 打倒美帝的,但我在菜单设置好后 s-s 和 red------------sock  后 就是无法自动fan 打倒美帝 为什么呢? 因为DNS的问题,这个时候只有youtbue,facebook,twitter上不了,其他网站已经可以上了, 这个问题困扰了我很久,直到发现实际就这三个网站上不去才发现DNS的问题。
这里有几个概念要先说一下,

1 s-s 需要实现在美国架设一个服务端,  这里是把s-s-libev-polarssl: 客户端安装到路由器上。
http://s-s.org/en/download/clients.html 这里可以下载对应的网卡版本 我的是4530R用
  (最新版本是1.4.6 https://github.com/madeye/s-s-libev

Haxc 的有的版本里面已经带了s-s,不是最新版本。但也可以使用 ,可以在路由器 菜单 系统-》 软件包 或启动项 里面查看 是否安装。
Haxc 在有的版本里面还有设置界面  在服务-》菜单里面有 s-s  菜单项

(注意,手动安装s-s后 启动会失败,我哭啊,原因是需要polarssl的lib文件, ssh命令 进入 /usr/lib 目录 复制  libpolarssl.so.1.2.5 文件几次 名字复制为 libpolarssl.so.3 和 libpolarssl.so.5  命令为 “cp libpolarssl.so.1.2.5  libpolarssl.so.5” 和 “cp libpolarssl.so.1.2.5  libpolarssl.so.3” 这样s-s 就启动正常了, 具体是libpolarssl.so.5 还是 libpolarssl.so.3 还是libpolarssl.so.2  与下载的安装s-s-libev-polarssl 库有关,1.4.4需要3,1.4.5需要5 建议多复制几份)


注意:s-s 有两种手动命令行的启动方式,(这里说的不包括 有设置luci界面的,  即不包括在服务-》菜单里面有 s-s  菜单项
一般默认的就是 ss-local 或 /etc/init.d/s-s start  这是需要先配置一下配置文件。启动后 一般监听1080端口
另一种方式是违禁软件edir 启动,就是自动开启一个透明代理,  实际上就是把red---socks的功能集成了。

注意:这里说一下s-s配置文件, 同时还要注意你的路由器刷Haxc固件 “服务”菜单里面是否带有s-s 的菜单可以直接设置。
因为 默认情况下如果手动安装 opkg install s-s-libev-polarssl 是不会带有 ‘服务’ 菜单里面s-s菜单项设置的。 这样配置文件在 /etc/s-s.json
配置文件格式 请看 https://github.com/madeye/shadow ... es/s-s.json
附上我的服务器地址
{
    "server":"162.243.204.115",
    "server_port":8388,
    "local_port":1080,
    "local_addr":"127.0.0.1",
    "password":"jinwyp2011",
    "timeout":600,
    "method":"table"
}


如果固件Haxc版本带有“服务”-》s-s luci菜单的,那么配置文件是在/etc/config/s-s 下面 如果在服务-》s-s 菜单 修改配置就会保存到这里/etc/config/s-s


再次注意:(我要疯了啊) 如果手动安装的情况下 使用ss-local 或 /etc/init.d/s-s start 那么默认会使用 /etc/s-s.json 配置,
需要注意里面的 "local_port":1080,  这个是设置 本地端口的配置。
使用 ss-local 启动可以指定参数 例如 ss-local -c /etc/s-s.json  -v
但如果使用违禁软件edir 启动,同样集成了red------------sock2 的透明代理功能,但代理的端口在哪呢? 其实还是 "local_port":1080,指定的,  所以建议另存一份配置 例如 /etc/违禁软件edir.json
把里面的"local_port":1080,  改称"local_port":12345,   
然后使用 违禁软件edir -c /etc/违禁软件edir.json  -v  启动 这样透明代理的配置和端口是12345 区分开了。



2 red------------sock 或red------------sock2 在Haxc固件中一般已经集成到 “服务” -》red------------sock2 菜单中,实际上如果使用上面的 违禁软件edir -c /etc/违禁软件edir.json  -v  启动后 就根本不需要red------------sock了,只有用ss-local启动才需要red------------sock2  同时 本地端口可以设置成12345.  代理ip是127.0.0.1,代理端口是1080
那么如果Haxc固件中集成了 服务-》 s-s 菜单的需要启动red------------sock吗?  在s-s 菜单配置中,有一项 透明代理的复选款,如果不勾 就需要red------------sock配合开启,如果勾了 就不需要red------------sock启动了。


在ssh命令行 可以通过 “netstat -tupln | grep 1”   来查看 s-s 和 red------------sock 是否启动了,
查看端口1开头的 就是我们设置的1080或 12345透明代理端口是否开启。 注意使用违禁软件edir启动后不会有1080端口,只有一个12345透明代理的端口。



到这里,理论上已经可以fan 打倒美帝了,如果是用ss-local启动的可以配合 chrome的switchysharp 代理插件 设置成路由器的代理 192.168.1.1 端口1080 就可以fan 打倒美帝了,firefox可以使用foxproxy插件 ,还可以在插件自定义规则判断 国内网站不走代理,国外网站走代理。

但是对于一般用户 还是不能做到自动fan 打倒美帝。  所以还要设置iptables

3 设置 iptables

注意 如果用了Haxc路由固件,如果服务-》里面有red---socks 并运行了red---socks 后 (如果red------------sock未运行可以在 “系统”-》 启动项 开启 red------------sock 项来运行)
会自动在iptables 里面 加入一条red---socks的规则链, 这个时候也就是说 如果 启动了ss-local 和 red---socks 你已经可以 上国外的网站了 例如slideshare.net 已经全部正常使用   但除了youtbue,facebook,twitter 这三个网站 (坑爹啊,我就是要上这三个啊)
查看iptables 可以到 路由器管理界面的 “状态“-》防火墙 查看, crtl+f 搜索 red------------sock 就能看到 有一个转发到端口11111或12345的规则 (redir port 11111) 端口是在”服务“-》red------------sock2里面设置的。

----------这里我有一个问题 想问Haxc 就是red------------sock设置和 s-s的luci界面的设置后的iptables的规则保存到哪个配置文件中了?  答案是路径在/etc/init.d/s-s


还,如果使用了违禁软件edir 启动就不需要 启动red------------sock了, 但iptables 还是需要设置,因为不启动red------------sock就没有red---socks的规则链了,
这时候需要手动编辑 /etc/firewall.user 文件,(如果用的是luci界面的就可以直接到/etc/init.d/s-s里面,而不是/etc/firewall.user 里面)然后里面加入 4楼提供的iptables  注意 转发的端口 需要改成 违禁软件edir 的配置文件 /etc/违禁软件edir.json 里面的端口就可以了。


4 为了上youtbue,facebook,twitter 这三个网站  我们还需要修改DNS
需要安装 pdnsd 这是一个dns 中转的功能包 同时还要配合dnsmasq 这个功能包 (dnsmasq 路由器固件都已经安装,可以在 “系统”-》 软件包 里面查找 已安装的包 看看dnsmasq 是否安装)
安装 pdnsd 命令 (有的Haxc版本固件中已经安装,同时菜单“服务”-》pdnsd 也有该菜单)
opkg update
opkg install pdnsd  
opkg install pdnsd  iptables-mod-nat-extra


然后修改 /etc/pdnsd.conf 这个文件 (如果 Haxc版本固件中已经安装 同时菜单“服务”-》pdnsd 也有该菜单话 配置文件就在 /etc/config/pdnsd 里面
注意以下红色字段的修改  8.8.8.8 用的是google的DNS服务器(参考这篇文章 http://hong.im/2014/03/16/config ... ct-foreign-traffic/

global {
        perm_cache=1024;
        cache_dir="/var/pdnsd";
#        pid_file = /var/run/pdnsd.pid;
        run_as="nobody";
        server_port = 1053;    # 使用 1053 作为 dns 端口, 默认是 53,一定要修改否则会跟默认 dnsmasq 冲突
    server_ip = any;    # 设置成 any 表示绑定在任何可用地址,其实不设置问题也不大。

#        server_ip = 127.0.0.1;  # Use eth0 here if you want to allow other
                                # machines on your network to query pdnsd.
        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;   # Upper limit on the size of UDP messages.
}

server {
        label= "myisp";
        ip = 8.8.8.8;  # Put your ISP's DNS-server address(es) here.
#        proxy_only=on;     # Do not query any name servers beside your ISP's.
                           # This may be necessary if you are behind some
                           # kind of firewall and cannot receive replies
                           # from outside name servers.
        timeout=4;         # Server timeout; this may be much shorter
                           # that the global timeout option.
        uptest=if;         # Test if the network interface is active.
        interface=eth0;    # The name of the interface to check.
        interval=10m;      # Check every 10 minutes.
        purge_cache=off;   # Keep stale cache entries in case the ISP's
                           # DNS servers go offline.
        edns_query=yes;    # Use EDNS for outgoing queries to allow UDP messages
                           # larger than 512 bytes. May cause trouble with some
                           # legacy systems.
#        exclude=.thepiratebay.org,  # If your ISP censors certain names, you may
#                .thepiratebay.se,   # want to exclude them here, and provide an
#                .piratebay.org,            # alternative server section below that will
#                .piratebay.se;            # successfully resolve the names.
}


# 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 = 8.8.8.8;     # This list will be expanded to the full
                                                                         # list on start up.
        timeout = 5;
        uptest = none;         # 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;
}



然后还要 修改/etc/dnsmasq.conf   在该文件里面最后 加入一行 conf-dir=/etc/dnsmasq.d

然后新建一个目录 mkdir /etc/dnsmasq.d /etc/dnsmasq.d目录里面新建一个文件 vim gfw.conf


写入  以下DNS

#Google and Youtube
server=/.google.com/127.0.0.1#1053
server=/.google.com.hk/127.0.0.1#1053
server=/.gstatic.com/127.0.0.1#1053
server=/.ggpht.com/127.0.0.1#1053
server=/.googleusercontent.com/127.0.0.1#1053
server=/.appspot.com/127.0.0.1#1053
server=/.googlecode.com/127.0.0.1#1053
server=/.googleapis.com/127.0.0.1#1053
server=/.gmail.com/127.0.0.1#1053
server=/.google-analytics.com/127.0.0.1#1053
server=/.youtube.com/127.0.0.1#1053
server=/.googlevideo.com/127.0.0.1#1053
server=/.youtube-nocookie.com/127.0.0.1#1053
server=/.ytimg.com/127.0.0.1#1053
server=/.blogspot.com/127.0.0.1#1053
server=/.blogger.com/127.0.0.1#1053

#FaceBook
server=/.facebook.com/127.0.0.1#1053
server=/.thefacebook.com/127.0.0.1#1053
server=/.facebook.net/127.0.0.1#1053
server=/.fbcdn.net/127.0.0.1#1053
server=/.akamaihd.net/127.0.0.1#1053

#Twitter
server=/.twitter.com/127.0.0.1#1053
server=/.t.co/127.0.0.1#1053
server=/.bitly.com/127.0.0.1#1053
server=/.twimg.com/127.0.0.1#1053
server=/.tinypic.com/127.0.0.1#1053
server=/.yfrog.com/127.0.0.1#1053



保存后  重启 pdnsd 和 dnsmasq

/etc/init.d/pdnsd restart
/etc/init.d/dnsmasq restart


设置 pdnsd的路由器开机自动启动  (也可以在路由器界面 “系统”-》“启动项” 设置 重启和开机启动)
/etc/init.d/pdnsd restart  enable


一切完成 真不容易啊。



几个问题

1 pdnsd,s-s 这两个在Haxc 最新版固件r40431 没有加入 能否加入, s-s 用最新的版本的1.4.5 我测试没有问题了
2 pdnsd,s-s 这两个如果我要自己加上 “服务”的网页的菜单如何做? 之前r38621的版本里面有的,但最新的40431里面没有了
3 red---socks2 运行后会自动在iptables 里面创建一个规则链  red---socks, 请问是在哪个文件配置的。
4 由于 s-s 最新版本加入了 违禁软件edir 自己就能创建一个透明的代理,所以实际上可以不用red---socks了。但需要创建相应的iptables 如何做?


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×

点评

太牛叉了 支持你 恩山有你而精彩 加油吧小伙伴们  发表于 2014-7-1 22:09

评分

参与人数 3恩山币 +3 收起 理由
antium + 1 赞一个,你是我的呕像!
haibo_zhou + 1 卤煮 有QQ没得 我这个始终未运行 帮我看看
wyf88 + 1 强大的恩山!(以下重复1万次)

查看全部评分

我的恩山、我的无线 The best wifi forum is right here.
 楼主| 发表于 2014-5-17 14:57 | 显示全部楼层
顶一下
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2014-5-17 18:24 | 显示全部楼层
帮顶,我也想知道
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2014-5-17 20:58 | 显示全部楼层
丰花 发表于 2014-5-17 18:24
帮顶,我也想知道

刚好 这几天折腾过。
1.你这个 运行的是ss-local吧,想要透明代理 要以ss-redir方式运行。
2.透明代理需要安装 iptables-mod-nat-extra
3. iptables 见附件
iptables -t nat -N SHADOWSOCKS # 在 nat 表中创建新链
#!/bin/sh
#refer https://github.com/madeye/shadowsocks-libevhttps://gist.github.com/wen-long/8644243
######################################################################
#    shadowsocks  二维码 扫描出来的是base64加密的,解密出来 的格式是这样
#        method:password@hostname:port
#    1. ss-server:服务器端,部署在远程服务器,提供 shadowsocks 服务。
#    2. ss-local:客户端,提供本地 socks5 协议代理。
#    3. ss-redir:客户端,提供本地透明代理,需要与 NAT 配合使用,具体使用方法参见文档。
#    iptables-mod-nat-extra
#    清空整个链 iptables -F 链名比如iptables -t nat -F SHADOWSOCKS
#    删除指定的用户自定义链 iptables -X 链名 比如 iptables -t nat -X SHADOWSOCKS
#    从所选链中删除规则 iptables -D 链名 规则详情 比如 iptables -t nat -D SHADOWSOCKS -d 223.223.192.0/255.255.240.0 -j RETURN
#   
######################################################################
# 在 nat 表中创建新链
iptables -t nat -N SHADOWSOCKS

# Do not redirect traffic to the followign address ranges

#   排除shadowsocks 服务器ip
iptables -t nat -A SHADOWSOCKS -d 69.163.40.124 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 192.3.18.91 -j RETURN

# Ignore LANs IP address 局域网ip
# See Wikipedia and RFC5735 for full list of reserved networks.

iptables -t nat -A SHADOWSOCKS -d 0.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 10.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 127.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 169.254.0.0/16 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 172.16.0.0/12 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 192.168.0.0/16 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 224.0.0.0/4 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 240.0.0.0/4 -j RETURN

# Ignore Asia IP address 亚洲ip
iptables -t nat -A SHADOWSOCKS -d 1.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 14.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 27.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 36.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 39.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 42.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 49.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 58.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 59.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 60.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 61.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 101.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 103.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 106.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 110.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 111.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 112.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 113.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 114.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 115.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 116.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 117.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 118.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 119.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 120.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 121.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 122.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 123.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 124.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 125.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 126.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 169.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 175.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 180.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 182.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 183.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 202.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 203.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 210.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 211.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 218.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 219.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 220.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 221.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 222.0.0.0/8 -j RETURN
iptables -t nat -A SHADOWSOCKS -d 223.0.0.0/8 -j RETURN

# Redirect normal HTTP and HTTPS traffic
# Anything else should be redirected to shadowsocks's local port   其他ip 流量定向到shadowsocks的 本地监听端口,这里12345,改成自己的
iptables -t nat -A SHADOWSOCKS -p tcp -j REDIRECT --to-ports 12345  # 别超过65535

# Apply the rules   在 PREROUTING 链前插入 SHADOWSOCKS 链,使其生效
iptables -t nat -I PREROUTING -p tcp -j SHADOWSOCKS

# Start the shadowsocks-redir 启动shadowsocks 注意透明代理是 ss-redir 不是ss-local
ss-redir -c /etc/shadowsocks.json -f /var/run/shadowsocks.pid





本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×

点评

马克!!备忘!  详情 回复 发表于 2014-12-22 14:11
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2014-5-17 20:59 | 显示全部楼层
回复到4楼了,你看下
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2014-5-17 22:41 | 显示全部楼层
本帖最后由 jinwyp 于 2014-5-17 22:43 编辑

主要我是刷的 https://www.right.com.cn/forum/thread-102073-1-1.html

OpenWrt | OpenWrt Attitude Adjustment 12.09.1 r39154 by Haxc | 负载: 0.33 0.22 0.18

按照 网站教程的iptables 死活不行, shasowsocks 和redsock 都是正常运行 进程里面都有, 而且如果在浏览器按照代理也可以翻WALL,就是不能全自动翻WALL
是不是要清空原来的iptables, 原来的ipables 有一大堆规则,看不懂


附上目前的规则,就是r39154 带的 再加上 shadowsocks 的后添加的规则, 死活无法自动翻WALL

表: Filter

链 INPUT (策略: ACCEPT, 数据包: 0, 流量: 0.00 B)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        33        2.78 KB        delegate_input        all        --        *        *        0.0.0.0/0        0.0.0.0/0        -

链 FORWARD (策略: DROP, 数据包: 0, 流量: 0.00 B)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        0        0.00 B        delegate_forward        all        --        *        *        0.0.0.0/0        0.0.0.0/0        -

链 OUTPUT (策略: ACCEPT, 数据包: 0, 流量: 0.00 B)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        28        3.21 KB        delegate_output        all        --        *        *        0.0.0.0/0        0.0.0.0/0        -

链 delegate_forward (引用: 1)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        0        0.00 B        forwarding_rule        all        --        *        *        0.0.0.0/0        0.0.0.0/0        /* user chain for forwarding */
2        0        0.00 B        ACCEPT        all        --        *        *        0.0.0.0/0        0.0.0.0/0        ctstate RELATED,ESTABLISHED
3        0        0.00 B        zone_lan_forward        all        --        br-lan        *        0.0.0.0/0        0.0.0.0/0        -
4        0        0.00 B        zone_wan_forward        all        --        pppoe-wan        *        0.0.0.0/0        0.0.0.0/0        -
5        0        0.00 B        reject        all        --        *        *        0.0.0.0/0        0.0.0.0/0        -

链 delegate_input (引用: 1)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        0        0.00 B        ACCEPT        all        --        lo        *        0.0.0.0/0        0.0.0.0/0        -
2        33        2.78 KB        input_rule        all        --        *        *        0.0.0.0/0        0.0.0.0/0        /* user chain for input */
3        25        2.23 KB        ACCEPT        all        --        *        *        0.0.0.0/0        0.0.0.0/0        ctstate RELATED,ESTABLISHED
4        7        448.00 B        syn_flood        tcp        --        *        *        0.0.0.0/0        0.0.0.0/0        tcp flags:0x17/0x02
5        8        564.00 B        zone_lan_input        all        --        br-lan        *        0.0.0.0/0        0.0.0.0/0        -
6        0        0.00 B        zone_wan_input        all        --        pppoe-wan        *        0.0.0.0/0        0.0.0.0/0        -

链 delegate_output (引用: 1)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        0        0.00 B        ACCEPT        all        --        *        lo        0.0.0.0/0        0.0.0.0/0        -
2        28        3.21 KB        output_rule        all        --        *        *        0.0.0.0/0        0.0.0.0/0        /* user chain for output */
3        20        2.01 KB        ACCEPT        all        --        *        *        0.0.0.0/0        0.0.0.0/0        ctstate RELATED,ESTABLISHED
4        2        808.00 B        zone_lan_output        all        --        *        br-lan        0.0.0.0/0        0.0.0.0/0        -
5        6        424.00 B        zone_wan_output        all        --        *        pppoe-wan        0.0.0.0/0        0.0.0.0/0        -

链 reject (引用: 3)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        0        0.00 B        REJECT        tcp        --        *        *        0.0.0.0/0        0.0.0.0/0        reject-with tcp-reset
2        0        0.00 B        REJECT        all        --        *        *        0.0.0.0/0        0.0.0.0/0        reject-with icmp-port-unreachable

链 syn_flood (引用: 1)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        7        448.00 B        RETURN        tcp        --        *        *        0.0.0.0/0        0.0.0.0/0        tcp flags:0x17/0x02 limit: avg 25/sec burst 50
2        0        0.00 B        DROP        all        --        *        *        0.0.0.0/0        0.0.0.0/0        -

链 zone_lan_dest_ACCEPT (引用: 1)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        2        808.00 B        ACCEPT        all        --        *        br-lan        0.0.0.0/0        0.0.0.0/0        -

链 zone_lan_forward (引用: 1)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        0        0.00 B        forwarding_lan_rule        all        --        *        *        0.0.0.0/0        0.0.0.0/0        /* user chain for forwarding */
2        0        0.00 B        zone_wan_dest_ACCEPT        all        --        *        *        0.0.0.0/0        0.0.0.0/0        /* forwarding lan -> wan */
3        0        0.00 B        zone_lan_src_REJECT        all        --        *        *        0.0.0.0/0        0.0.0.0/0        -

链 zone_lan_input (引用: 1)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        8        564.00 B        input_lan_rule        all        --        *        *        0.0.0.0/0        0.0.0.0/0        /* user chain for input */
2        8        564.00 B        zone_lan_src_ACCEPT        all        --        *        *        0.0.0.0/0        0.0.0.0/0        -

链 zone_lan_output (引用: 1)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        2        808.00 B        output_lan_rule        all        --        *        *        0.0.0.0/0        0.0.0.0/0        /* user chain for output */
2        2        808.00 B        zone_lan_dest_ACCEPT        all        --        *        *        0.0.0.0/0        0.0.0.0/0        -

链 zone_lan_src_ACCEPT (引用: 1)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        8        564.00 B        ACCEPT        all        --        br-lan        *        0.0.0.0/0        0.0.0.0/0        -

链 zone_lan_src_REJECT (引用: 1)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        0        0.00 B        reject        all        --        br-lan        *        0.0.0.0/0        0.0.0.0/0        -

链 zone_wan_dest_ACCEPT (引用: 2)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        6        424.00 B        ACCEPT        all        --        *        pppoe-wan        0.0.0.0/0        0.0.0.0/0        -

链 zone_wan_forward (引用: 1)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        0        0.00 B        MINIUPNPD        all        --        *        *        0.0.0.0/0        0.0.0.0/0        -
2        0        0.00 B        forwarding_wan_rule        all        --        *        *        0.0.0.0/0        0.0.0.0/0        /* user chain for forwarding */
3        0        0.00 B        zone_wan_src_REJECT        all        --        *        *        0.0.0.0/0        0.0.0.0/0        -

链 zone_wan_input (引用: 1)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        0        0.00 B        input_wan_rule        all        --        *        *        0.0.0.0/0        0.0.0.0/0        /* user chain for input */
2        0        0.00 B        ACCEPT        udp        --        *        *        0.0.0.0/0        0.0.0.0/0        udp dpt:68 /* Allow-DHCP-Renew */
3        0        0.00 B        ACCEPT        icmp        --        *        *        0.0.0.0/0        0.0.0.0/0        icmp type 8 /* Allow-Ping */
4        0        0.00 B        ACCEPT        tcp        --        *        *        0.0.0.0/0        0.0.0.0/0        tcp dpt:51413 /* 51413 */
5        0        0.00 B        ACCEPT        udp        --        *        *        0.0.0.0/0        0.0.0.0/0        udp dpt:51413 /* 51413 */
6        0        0.00 B        ACCEPT        tcp        --        *        *        0.0.0.0/0        0.0.0.0/0        tcp dpt:9091 /* 9091 */
7        0        0.00 B        ACCEPT        tcp        --        *        *        0.0.0.0/0        0.0.0.0/0        tcp dpt:9000 /* 9000 */
8        0        0.00 B        ACCEPT        udp        --        *        *        0.0.0.0/0        0.0.0.0/0        udp dpt:9000 /* 9000 */
9        0        0.00 B        ACCEPT        tcp        --        *        *        0.0.0.0/0        0.0.0.0/0        tcp dpt:6800 /* 6800 */
10        0        0.00 B        ACCEPT        udp        --        *        *        0.0.0.0/0        0.0.0.0/0        udp dpt:6800 /* 6800 */
11        0        0.00 B        zone_wan_src_REJECT        all        --        *        *        0.0.0.0/0        0.0.0.0/0        -

链 zone_wan_output (引用: 1)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        6        424.00 B        output_wan_rule        all        --        *        *        0.0.0.0/0        0.0.0.0/0        /* user chain for output */
2        6        424.00 B        zone_wan_dest_ACCEPT        all        --        *        *        0.0.0.0/0        0.0.0.0/0        -

链 zone_wan_src_REJECT (引用: 2)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        0        0.00 B        reject        all        --        pppoe-wan        *        0.0.0.0/0        0.0.0.0/0        -

表: NAT

链 PREROUTING (策略: ACCEPT, 数据包: 6, 流量: 436.00 B)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        8        564.00 B        SHADOWSOCKS        tcp        --        *        *        0.0.0.0/0        0.0.0.0/0        -
2        6        436.00 B        delegate_prerouting        all        --        *        *        0.0.0.0/0        0.0.0.0/0        -

链 POSTROUTING (策略: ACCEPT, 数据包: 0, 流量: 0.00 B)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        7        524.00 B        delegate_postrouting        all        --        *        *        0.0.0.0/0        0.0.0.0/0        -

链 SHADOWSOCKS (引用: 1)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        0        0.00 B        RETURN        tcp        --        *        *        0.0.0.0/0        0.0.0.0/0        tcp dpt:8388
2        0        0.00 B        RETURN        all        --        *        *        0.0.0.0/0        162.243.204.115        -
3        0        0.00 B        RETURN        all        --        *        *        0.0.0.0/0        8.8.0.0/16        -
4        0        0.00 B        RETURN        all        --        *        *        0.0.0.0/0        0.0.0.0/8        -
5        0        0.00 B        RETURN        all        --        *        *        0.0.0.0/0        10.0.0.0/8        -
6        0        0.00 B        RETURN        all        --        *        *        0.0.0.0/0        127.0.0.0/8        -
7        0        0.00 B        RETURN        all        --        *        *        0.0.0.0/0        169.254.0.0/16        -
8        0        0.00 B        RETURN        all        --        *        *        0.0.0.0/0        172.16.0.0/12        -
9        6        436.00 B        RETURN        all        --        *        *        0.0.0.0/0        192.168.0.0/16        -
10        0        0.00 B        RETURN        all        --        *        *        0.0.0.0/0        224.0.0.0/4        -
11        0        0.00 B        RETURN        all        --        *        *        0.0.0.0/0        240.0.0.0/4        -
12        0        0.00 B        RETURN        all        --        *        *        0.0.0.0/0        0.0.0.0/7        -
13        2        128.00 B        REDIRECT        tcp        --        *        *        0.0.0.0/0        0.0.0.0/0        redir ports 12345

链 delegate_postrouting (引用: 1)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        7        524.00 B        postrouting_rule        all        --        *        *        0.0.0.0/0        0.0.0.0/0        /* user chain for postrouting */
2        1        100.00 B        zone_lan_postrouting        all        --        *        br-lan        0.0.0.0/0        0.0.0.0/0        -
3        6        424.00 B        zone_wan_postrouting        all        --        *        pppoe-wan        0.0.0.0/0        0.0.0.0/0        -

链 delegate_prerouting (引用: 1)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        6        436.00 B        prerouting_rule        all        --        *        *        0.0.0.0/0        0.0.0.0/0        /* user chain for prerouting */
2        6        436.00 B        zone_lan_prerouting        all        --        br-lan        *        0.0.0.0/0        0.0.0.0/0        -
3        0        0.00 B        zone_wan_prerouting        all        --        pppoe-wan        *        0.0.0.0/0        0.0.0.0/0        -

链 zone_lan_postrouting (引用: 1)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        1        100.00 B        postrouting_lan_rule        all        --        *        *        0.0.0.0/0        0.0.0.0/0        /* user chain for postrouting */

链 zone_lan_prerouting (引用: 1)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        6        436.00 B        prerouting_lan_rule        all        --        *        *        0.0.0.0/0        0.0.0.0/0        /* user chain for prerouting */

链 zone_wan_postrouting (引用: 1)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        6        424.00 B        postrouting_wan_rule        all        --        *        *        0.0.0.0/0        0.0.0.0/0        /* user chain for postrouting */
2        6        424.00 B        MASQUERADE        all        --        *        *        0.0.0.0/0        0.0.0.0/0        -

链 zone_wan_prerouting (引用: 1)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        0        0.00 B        MINIUPNPD        all        --        *        *        0.0.0.0/0        0.0.0.0/0        -
2        0        0.00 B        prerouting_wan_rule        all        --        *        *        0.0.0.0/0        0.0.0.0/0        /* user chain for prerouting */

表: Mangle

链 PREROUTING (策略: ACCEPT, 数据包: 33, 流量: 2.78 KB)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        33        2.78 KB        fwmark        all        --        *        *        0.0.0.0/0        0.0.0.0/0        -

链 FORWARD (策略: ACCEPT, 数据包: 0, 流量: 0.00 B)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        0        0.00 B        mssfix        all        --        *        *        0.0.0.0/0        0.0.0.0/0        -

链 mssfix (引用: 1)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        0        0.00 B        TCPMSS        tcp        --        *        pppoe-wan        0.0.0.0/0        0.0.0.0/0        tcp flags:0x06/0x02 /* wan (mtu_fix) */ TCPMSS clamp to PMTU

表: Raw

链 PREROUTING (策略: ACCEPT, 数据包: 36, 流量: 2.93 KB)
规则 #        数据包        流量        目标        协议        标识        入口        出口        源地址        目标地址        选项
1        36        2.93 KB        notrack        all        --        *        *        0.0.0.0/0        0.0.0.0/0        -
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2014-5-17 23:38 | 显示全部楼层
iorip2 发表于 2014-5-17 20:59
回复到4楼了,你看下

/etc/shadowsocks.json 配置文件内容是什么样的?
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2014-5-18 00:28 | 显示全部楼层
原来发现 已经设置成功,但是twitter, facebook, youtube 上不去,不知道为什么?
其他国外网站 例如slideshare.net 已经全部正常使用 太奇怪了,用chrome的时候swithsharp也能上twiiter啊,
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2014-5-18 01:51 | 显示全部楼层
搞定了 最后问题还是dns 污染问题,上不了 twitter facebook,youtube, 已经用pdnsd 搞定
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2014-5-19 11:20 | 显示全部楼层
问一下  这两个问题?
1 pdnsd,shadowsocks 这两个如果我要自己加上 “服务”的网页的菜单如何做? 之前r38621的版本里面有的,但最新的40431里面没有了
2 redsocks2 运行后会自动在iptables 里面创建一个规则链  REDSOCKS, 请问是在哪个文件配置的?

点评

安装luci-shadowsocks 就有了  发表于 2014-5-19 13:21
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2014-5-19 13:44 | 显示全部楼层
redsocks2 运行后会自动在iptables 里面创建一个规则链  REDSOCKS, 请问是在哪个文件配置的?
原来在这里  已经找到了

https://github.com/ravageralpha/ ... tc/init.d/redsocks2
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2014-5-19 13:55 来自手机 | 显示全部楼层
不会编译你也只能走弯路了
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2014-5-19 17:13 | 显示全部楼层
感谢这样的教程!很详细!想在8M里装,请问总共需要多大空间?
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2014-5-19 17:15 | 显示全部楼层
这个NB,AR71**

巴法络G450H可以刷吗???
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2014-5-19 19:13 | 显示全部楼层

很好,支持

本帖最后由 pupie 于 2014-5-19 20:35 编辑

很好,支持。
利用dnsmasq判断特定域名用本地pdnsd解析的话,还可以用dnscrypt-proxy解析,而且dnsscrypt的查询流量是加密的,也支持tcp、udp方式链接上级dns。

原dnsmasq中配置文件端口改程dnscrypt-proxy的端口即可。
#Google and Youtube
server=/.google.com/127.0.0.1#2053
server=/.google.com.hk/127.0.0.1#2053

。。。。
后面省略

而且dnscrypt配置更简单
/etc/config/dnscrypt-proxy
config dnscrypt-proxy
        option address         '127.0.0.1'
        option port            '2053'
        option resolver        'opendns'
        option resolvers_list  '/usr/share/dnscrypt-proxy/dnscrypt-resolvers.csv'


点评

mark 备忘  详情 回复 发表于 2014-11-30 15:11
码克 备忘  详情 回复 发表于 2014-10-11 16:21
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-25 04:12

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表