V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
lvii
V2EX  ›  Linux

TP Link wr703n bridged AP 桥接模式无法连接外网

  •  
  •   lvii · 2013-06-23 11:55:44 +08:00 · 7973 次点击
    这是一个创建于 3970 天前的主题,其中的信息可能已经有所发展或是发生改变。
    各位兄台 tp link wr703n 刷好 openwrt 后,使用 bridged AP 桥接模式提供无线访问

    上层路由器:192.168.1.111
    wr703n 路由器:192.168.11

    遇到的问题是:

    连接 wr703n 无线的手机,可以通过 wr703n 的网桥,到上层的路由器 dhcp 获取地址
    对于 wr703n 设置静态管理地址后,内网(192.168.x.x)中可以相互 ping 通的
    但是无法访问公网,就没法安装 openwrt 的软件包了

    无法更新软件源:

    root@OpenWrt:# opkg update
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/Packages.gz.
    dwget: can't connect to remote host (78.24.191.177): Connection timed out
    Collected errors:
    * opkg_download: Failed to download http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages
    /Packages.gz, wget returned 1

    wr703n 网络配置:

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

    config interface 'lan'
    option ifname 'eth0'
    option type 'bridge'
    option proto 'static'
    option iPad dr '192.168.1.11' ## wr703n 管理地址
    option netmask '255.255.255.0'
    option gateway '192.168.1.111' ## 上层路由器管理地址
    option dns '192.168.1.111'

    wr703n 的路由表:

    root@OpenWrt:~# route -n
    Kernel IP routing table
    Destination Gateway Genmask Flags Metric Ref Use Iface
    0.0.0.0 192.168.1.111 0.0.0.0 UG 0 0 0 br-lan
    192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 br-lan

    wr703n 的 ifconfig:

    root@OpenWrt:~# ifconfig
    br-lan Link encap:Ethernet HWaddr B0:48:7A:3A:EE:72
    inet addr:192.168.1.11 Bcast:192.168.1.255 Mask:255.255.255.0
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:4938 errors:0 dropped:21 overruns:0 frame:0
    TX packets:4902 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:528760 (516.3 KiB) TX bytes:1187467 (1.1 MiB)

    eth0 Link encap:Ethernet HWaddr B0:48:7A:3A:EE:72
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:1311161 errors:0 dropped:0 overruns:0 frame:0
    TX packets:821647 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:1418076662 (1.3 GiB) TX bytes:88868501 (84.7 MiB)
    Interrupt:4

    lo Link encap:Local Loopback
    inet addr:127.0.0.1 Mask:255.0.0.0
    UP LOOPBACK RUNNING MTU:16436 Metric:1
    RX packets:415564 errors:0 dropped:0 overruns:0 frame:0
    TX packets:415564 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:0
    RX bytes:34076148 (32.4 MiB) TX bytes:34076148 (32.4 MiB)

    wlan0 Link encap:Ethernet HWaddr B0:48:7A:3A:EE:72
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:558 errors:0 dropped:0 overruns:0 frame:0
    TX packets:559 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:32
    RX bytes:86849 (84.8 KiB) TX bytes:206857 (202.0 KiB)

    wr703n 的网桥设备:

    # brctl show
    bridge name bridge id STP enabled interfaces
    br-lan 8000.b0487a3aee72 no eth0
    wlan0
    15 条回复    2016-02-20 17:31:44 +08:00
    dndx
        1
    dndx  
       2013-06-23 13:57:20 +08:00
    首先赞一下 LZ ,虽然排版有点乱但是提供的信息很足,让问题更容易回答。

    dwget: can't connect to remote host (78.24.191.177): Connection timed out

    78.24.191.177 的确是 OpenWrt 的 IP 。既然可以解析出地址,看来你的互联网连接没有问题。

    先试着 ping 8.8.8.8 看看有没有回显。

    如果有回显,说明是 OpenWrt 的服务器不稳定或者被墙了。

    如果没回显,ping 192.168.1.111 确保到出口路由器的链路畅通。
    dndx
        2
    dndx  
       2013-06-23 13:59:27 +08:00
    另外你的 /etc/config/network

    option iPad dr '192.168.1.11' ## wr703n 管理地址

    不知道是不是拷贝的时候出了问题。应该是:

    option iPad dr '192.168.1.11' ## wr703n 管理地址

    写配置文件就别开自动更正了。。
    11138
        3
    11138  
       2013-06-23 14:07:30 +08:00
    @dndx 你说的“应该是”和上面的一样啊。
    dndx
        4
    dndx  
       2013-06-23 14:08:22 +08:00
    option iPad dr '192.168.1.11' ## wr703n 管理地址

    @11138
    dndx
        5
    dndx  
       2013-06-23 14:09:02 +08:00
    @11138 -.- 我懂了

    是万恶的 NSTextField。。。
    11138
        6
    11138  
       2013-06-23 14:11:48 +08:00
    @dndx 我还以为我眼睛花了 ^_^
    csx163
        7
    csx163  
       2013-06-23 14:16:59 +08:00
    我一般是下载到本地然后开http,wget到路由器安装的
    lvii
        8
    lvii  
    OP
       2013-06-23 17:01:23 +08:00
    @dndx 关于 DNS 我之前也排查过,后面只能设置为上层路由的管理地址,才能正确解析

    在 openwrt 上面 ping 上层路由器,以及内网都是 OK 的,因为 192.168.1.x 的路由
    网关是上层路由,所以链路是通的,没有问题的。

    --------------------------------------

    配置文件,我都是 copy 过的,不知道格式为何变成这样子了。-_-#

    --------------------------------------

    关于 DNS :

    option dns '192.168.1.111'

    bridged AP 模式需要设置为上层路由器的地址,由上层路由器代理解析地址:

    # cat /etc/resolv.conf
    # Interface lan
    nameserver 192.168.1.111

    # opkg update
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/Packages.gz.
    wget: can't connect to remote host (78.24.191.177): Connection timed out
    ...

    错误提示显示已经解析出 openwrt.org 的 IP 地址(78.24.191.177),DNS 解析是没有问题的
    问题应该出在路由上面的

    下面的两个输出都表示 DNS 解析是正常的:

    # ping openwrt.org
    PING openwrt.org (78.24.191.177): 56 data bytes
    ^C
    --- openwrt.org ping statistics ---
    7 packets transmitted, 0 packets received, 100% packet loss

    # nslookup openwrt.org
    Server: 192.168.1.111
    Address 1: 192.168.1.111

    Name: openwrt.org
    Address 1: 78.24.191.177 openwrt.org

    如果换成 google 或 电信的 DNS ,直接连 DNS 解析都是失败的:wget: bad address 'downloads.openwrt.org'

    # opkg update
    Downloading http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/Packages.gz.
    wget: bad address 'downloads.openwrt.org'
    Collected errors:
    * opkg_download: Failed to download http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/Packages.gz, wget returned 1.

    因为出不了 公网,设置外网的 DNS 服务器,根本没用:

    # ping 8.8.4.4
    PING 8.8.4.4 (8.8.4.4): 56 data bytes
    ^C
    --- 8.8.4.4 ping statistics ---
    4 packets transmitted, 0 packets received, 100% packet loss

    # nslookup openwrt.org 8.8.8.8
    Server: 8.8.8.8
    Address 1: 8.8.8.8

    nslookup: can't resolve 'openwrt.org': Name or service not known

    # traceroute 8.8.4.4
    traceroute to 8.8.4.4 (8.8.4.4), 30 hops max, 38 byte packets
    1 * * *
    2 * * *
    3^C
    dndx
        9
    dndx  
       2013-06-23 18:04:53 +08:00   ❤️ 1
    @lvii 我刚刚做了测试,78.24.191.177 是可以 ping 通的。

    PING 78.24.191.177 (78.24.191.177): 56 data bytes
    64 bytes from 78.24.191.177: icmp_seq=0 ttl=43 time=460.022 ms
    64 bytes from 78.24.191.177: icmp_seq=1 ttl=43 time=711.312 ms
    64 bytes from 78.24.191.177: icmp_seq=2 ttl=43 time=633.477 ms
    ^C
    --- 78.24.191.177 ping statistics ---
    3 packets transmitted, 3 packets received, 0.0% packet loss
    round-trip min/avg/max/stddev = 460.022/601.604/711.312/105.035 ms

    现在的情况看,几乎可以断定是上层路由器的配置问题。比如是不是设了 MAC 过滤或者防火墙之类的。

    还有一种可能是 OpenWrt iptables 的问题,运行 iptables -L -v 检查一下。
    dndx
        10
    dndx  
       2013-06-23 18:05:51 +08:00
    @lvii 另外可以运行 traceroute 8.8.8.8 看连接是在哪里断的。
    lvii
        11
    lvii  
    OP
       2013-06-23 18:26:45 +08:00
    @dndx 兄,一语点醒。。。

    现在的情况看,几乎可以断定是上层路由器的配置问题。
    比如是不是设了 MAC 过滤或者防火墙之类的。


    上层路由做了 mac 访问限制,我添加 mac 之后,可以访问了

    -------------------------------------------------

    还有一个问题:使用 bridged AP 模式,管理地址可否再多设置一个虚拟地址:
    现在在家中使用的都是 192.168.x.x 这种,如果到办公室:

    办公室 DHCP(10.x.x.x) --有线--> wr703n(192.168.x.x) --无线--> 笔记本(10.x.x.x)

    如果要管理 openwrt 需要将笔记本 IP 手动改为 192.168.x.x 段的,然后连接到 wr703n
    进行管理,但是此时 wr703n 使用的是 192.168.x.x 段的,是无法访问外网的

    如果设置为和办公网的 10.x.x.x 网段按理可以(需要明天验证)
    那可否在 openwrt 种再添加一个虚拟网卡,配置一个办公网地址
    通过它可以在连接到办公网内的时候可以登录 openwrt 进行管理。

    谢谢!
    dndx
        12
    dndx  
       2013-06-23 20:23:02 +08:00
    @lvii 试试

    config interface 'lan-work'
    option ifname 'eth0:1'
    option type 'bridge'
    option proto 'static'
    option iPad dr '***'
    option netmask '***'
    option gateway '***' ## 上层路由器管理地址
    option dns '***'

    如果不行,用这种方法:

    http://wiki.openwrt.org/doc/uci/network#aliases
    dndx
        13
    dndx  
       2013-06-23 20:23:31 +08:00
    @lvii iPad dr 自行校正吧,我已经无力吐槽了。。
    lvii
        14
    lvii  
    OP
       2013-06-25 13:51:46 +08:00
    @dndx 使用 IP alias 搞定办公室的网络配置,thx ...

    http://lvii.github.io/network/2013/06/24/tp-link-wr703n-openwrt-bridged-ap-mode/
    cyqsd
        15
    cyqsd  
       2016-02-20 17:31:44 +08:00
    看见这个帖子真是相见恨晚啊。。。。看见大家聊了这么多,想的都是对的,解决的办法就是在 openwrt 里面输入一句 route add default gw 192.168.1.1 br-lan
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   980 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 226ms · UTC 21:55 · PVG 05:55 · LAX 14:55 · JFK 17:55
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.