Skip to content

Instantly share code, notes, and snippets.

@holys
Last active December 11, 2015 06:58
Show Gist options
  • Select an option

  • Save holys/4562794 to your computer and use it in GitHub Desktop.

Select an option

Save holys/4562794 to your computer and use it in GitHub Desktop.
设置WDS
@holys
Copy link
Author

holys commented Jan 18, 2013

TP-Link WR740N 和 TP-Link WR703N 组成WDS

  • WDS的原理

  • 设备

    1. TP-Link WR740N, 为原生系统, 作为主路由. MAC:14:E6:E4:31:8E:F2, SSID: Holy
    2. TP-Link WR703N , 已刷OpenWRT, 作为client路由. MAC: 8c:21:0a:da:99:36, SSID: OpenWRT
  • 准备工作

    1. 设置主路由.
      登录到路由管理界面,找到无线设置--> 基本设置
      设置好SSID, 信道选特定的值,可以随意,总之要具体的值.
      开启WDS功能, 扫描目标路由. 找到你的目标, 选14:E6:E4:31:8E:F2加密方式, 填密码, 具体如下图.

    主路由设置完毕,需要重启才生效.

  1. 设置client 路由.

ssh 进去 openwrt系统.
配置主要参考这里

一共是4个文件需要修改, 分别是

  • /etc/config/network #修改ip 为192.168.1.2
  • /etc/config/wireless #主要的修改之处, 见下文
  • /etc/config/dhcp # config dhcp lan 处 添加option ignore 1, 即client禁用dhcp功能
  • /etc/config/firewall # config zone lan 处 修改 option forward 值为 ACCEPT.

/etc/config/wireless

root@OpenWrt:/etc/config# cat wireless

config wifi-device  radio0
    option type     mac80211
    option channel  11
    option macaddr  8c:21:0a:da:99:36
    option hwmode   11ng
    option htmode   HT20
    list ht_capab   SHORT-GI-20
    list ht_capab   SHORT-GI-40
    list ht_capab   RX-STBC1
    list ht_capab   DSSS_CCK-40
    # REMOVE THIS LINE TO ENABLE WIFI:
    #option disabled 1

config wifi-ifce
    option device radio0
    option ssid   Holy
    option mode  wds
    option wds   1
    option network  lan
    option bssid   14:E6:E4:31:8E:F2
    option encryption  psk2
    option key  'your_password'

config wifi-iface
    option device   radio0
    option network  lan
    option mode     ap
    option ssid     OpenWRT
    option encryption psk2
    option key 'your_password'

/etc/config/network

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

config interface 'lan'
    option ifname 'eth0'
    option stp    '1'
    option type 'bridge'
    option proto 'static'
    option ipaddr '192.168.1.2'
    option netmask '255.255.255.0'

/etc/config/dhcp

config dnsmasq
    option domainneeded 1
    option boguspriv    1
    option filterwin2k  0  # enable for dial on demand
    option localise_queries 1
    option rebind_protection 1  # disable if upstream must serve RFC1918 addresses
    option rebind_localhost 1  # enable for RBL checking and similar services
    #list rebind_domain example.lan  # whitelist RFC1918 responses for domains
    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'
    #list server        '/mycompany.local/1.2.3.4'
    #option nonwildcard 1
    #list interface     br-lan
    #list notinterface  lo
    #list bogusnxdomain     '64.94.110.11'

config dhcp lan
    option interface    lan
    option start    100
    option limit    150
    option leasetime    12h
    option ignore   1

config dhcp wan
    option interface    wan
    option ignore   1

/etc/config/firewall
文件内容比较长,这里贴出主要内容.

...

config zone
    option name     lan
    option network      'lan'
    option input        ACCEPT
    option output       ACCEPT
    option forward      ACCEPT  
...

最后, 重启client 路由器. 如无意外, 手机连接到client路由器(本身是没有插网线的), 发现可以上网了 !!!

个人对原理不太懂, 于是有个疑问, 为什么在client路由上ping 不了外网呢,比如 baidu.com ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment