Artigos‎ > ‎Configuração de Hardware‎ > ‎OpenWrt‎ > ‎

WDS to implement a wireless network bridge (wireless repeater)


Primeiramente gostaria de salientar que não sou o autor principal do conteúdo deste artigo. A minha intenção é de mostrar o que outros autores tem realizado (referenciando links para o conteúdo original) neste blog até como um guia pessoal para uso próprio e ainda compartilhar minhas anotações e pequenas modificações que realizo no conteúdo, desejando que possa ajudar mais alguém em algum lugar.
First and foremost, I take no credit for any of this post’s content. I am really just taking what others have done (which I have links to bellow) and am putting it on my blog for a personal reference and hopefully the small changes that I made to their guides will help someone somewhere.

link: https://wiki.openwrt.org/doc/recipes/atheroswds
link: https://wiki.openwrt.org/doc/recipes/dumbap
link: http://linuxwireless.org/en/users/Documentation/iw/#Setting_up_a_WDS_peer


Acessing with SSH
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@192.168.1.1

Config remote wireless station

Contents of /etc/config/system

cat /etc/config/system

config system
option hostname 'OpenWrt'
option timezone 'UTC'

config timeserver 'ntp'
list server '0.openwrt.pool.ntp.org'
list server '1.openwrt.pool.ntp.org'
list server '2.openwrt.pool.ntp.org'
list server '3.openwrt.pool.ntp.org'
option enabled '1'
option enable_server '0'

config led 'led_power'
option name 'power'
option sysfs 'nexx:blue:power'
option default '0'

Change name to serial number and ntp servers to Brazil

vi /etc/config/system

config system
option hostname 'YS161919451F'
option zonename 'America/Sao Paulo'
    option timezone 'BRT3BRST,M10.3.0/0,M2.3.0/0'

config timeserver 'ntp'
list server 'c.st1.ntp.br'
list server 'b.st1.ntp.br'
list server 'd.st1.ntp.br'
list server 'a.ntp.br'
list server 'a.st1.ntp.br'
list server 'gps.ntp.br'
list server 'b.ntp.br'
list server 'c.ntp.br'
option enabled '1'
option enable_server '0'

config led 'led_power'
option name 'power'
option sysfs 'nexx:blue:power'
option default '0'


Contents of /etc/config/dhcp

cat /etc/config/dhcp


config dnsmasq
option domainneeded '1'
option boguspriv '1'
option filterwin2k '0'
option localise_queries '1'
option rebind_protection '1'
option rebind_localhost '1'
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'
option localservice '1'


config dhcp 'lan'
option interface 'lan'
option start '100'
option limit '150'
option leasetime '12h'
option dhcpv6 'server'
option ra 'server'


config dhcp 'wan'
option interface 'wan'
option ignore '1'


config odhcpd 'odhcpd'
option maindhcp '0'
option leasefile '/tmp/hosts/odhcpd'
option leasetrigger '/usr/sbin/odhcpd-update'

Find the config dhcp 'lan' section and add the line option ignore '1' to this section. 
Also change option dhcpv6 'server' to option dhcpv6 'disabled'.

config dnsmasq
option domainneeded '1'
option boguspriv '1'
option filterwin2k '0'
option localise_queries '1'
option rebind_protection '1'
option rebind_localhost '1'
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'
option localservice '1'


config dhcp 'lan'
option interface 'lan'
option ignore '1'
option start '100'
option limit '150'
option leasetime '12h'
option dhcpv6 'disabled'
option ra 'disabled'

config dhcp 'service'
option interface 'service'
option start '10'
option limit '15'
option leasetime '1h'
option dhcpv6 '
disabled'
option ra '
disabled'
option ignore '0'

config odhcpd 'odhcpd'
option maindhcp '0'
option leasefile '/tmp/hosts/odhcpd'
option leasetrigger '/usr/sbin/odhcpd-update'



Contents of /etc/config/network
cat /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 globals 'globals'
option ula_prefix 'fdb5:66cc:7d31::/48'


config interface 'lan'
option ifname 'eth0.1'
option force_link '1'
option macaddr '20:28:18:a2:2c:12'
option type 'bridge'
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
option ip6assign '60'


config interface 'wan'
option ifname 'eth0.2'
option force_link '1'
option macaddr '20:28:18:a2:2c:13'
option proto 'dhcp'


config interface 'wan6'
option ifname 'eth0.2'
option proto 'dhcpv6'


config switch
option name 'switch0'
option reset '1'
option enable_vlan '1'


config switch_vlan
option device 'switch0'
option vlan '1'
option ports '1 2 3 4 6t'


config switch_vlan
option device 'switch0'
option vlan '2'
option ports '0 6t'


Set the IP to an another address.
On switchless devices, simply bridge all ethernet interfaces together, remove the existing WAN interface - if any. On devices where WAN and LAN are separated by switch config, reconfigure the LAN VLAN to cover all ports, remove the existing WAN interface and its related VLAN - if any.
If you would like your AP to receive IPv6 as a host only and not for routing you have to tell dhcp6c not to request prefix deligation. If you do not do this the AP will reject basic IPv6 addresses. If you want to still be able to use ipv6 on the Router itself change the wan6 to lan6 and @wan to @lan

vi /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 globals 'globals'
option ula_prefix 'fdb5:66cc:7d31::/48'

config interface 'lan'
option ifname 'eth0.1'
option force_link '1'
option macaddr '20:28:18:a2:2c:12'
option type 'bridge'
option proto 'dhcp'
#option proto 'static'
#option ipaddr '192.168.1.6'
#option netmask '255.255.255.0'
#option ip6assign '60'
#option dns 192.168.1.1
#option gateway 192.168.1.1


config interface 'lan6'
option proto 'dhcpv6'
option ifname '@lan'
option reqprefix no


config interface 'service'
option proto 'static'
option ipaddr '192.168.8.1'
option netmask '255.255.255.0'



config switch
option name 'switch0'
option reset '1'
option enable_vlan '1'

config switch_vlan
option device 'switch0'
option vlan '1'
option ports '0 1 2 3 4 6t'

cat /etc/config/wireless
config wifi-device radio0
option type mac80211
option channel 11
option hwmode 11g
option path '10180000.wmac'
option htmode HT20
# REMOVE THIS LINE TO ENABLE WIFI:
option disabled 1


config wifi-iface
option device radio0
option network lan
option mode ap
option ssid OpenWrt
option encryption none


In the radio0 section, make sure that the wireless settings match the values in the access point.
Modify the wifi-iface section to include the desired SSID to which to connect (the same one as on the access point) and ensure WDS is enabled by setting this value to 1.
Create a new wifi-iface section and copy all the values from the existing interface, but make two changes: use mode 'ap' instead of 'sta' and leave out the WDS option or set it to 0.

vi /etc/config/wireless

config wifi-device radio0
option type mac80211
option hwmode 11g
option path '10180000.wmac'
option channel 1
option htmode HT40
option country '00'
option txpower '17'
option distance '30'

config wifi-iface
option device radio0
option network lan
option ssid 'casa'
option mode 'sta'
option wds '1'
#option bssid '90:F6:52:D4:F2:50'
option bssid '90:F6:52:57:57:F0'
option encryption 'psk-mixed+tkip+ccmp'
option disabled '0'
option key 'wifipassword'

config wifi-iface
option device radio0
option network lan
option ssid 'casa'
option mode 'ap'
option wds '0'
option encryption 'psk-mixed+tkip+ccmp'
option hidden '1'
option key 'wifipassword'

config wifi-iface
option device radio0
option network service
option mode ap
option ssid YS161919451F
option encryption none
option isolate 1
option hidden '1'


Contents of /etc/config/firewall
cat /etc/config/firewall
config defaults
option syn_flood 1
option input ACCEPT
option output ACCEPT
option forward REJECT
# Uncomment this line to disable ipv6 rules
# option disable_ipv6 1


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


config zone
option name wan
list network 'wan'
list network 'wan6'
option input REJECT
option output ACCEPT
option forward REJECT
option masq 1
option mtu_fix 1


config forwarding
option src lan
option dest wan


# We need to accept udp packets on port 68,
# see https://dev.openwrt.org/ticket/4108
config rule
option name Allow-DHCP-Renew
option src wan
option proto udp
option dest_port 68
option target ACCEPT
option family ipv4


# Allow IPv4 ping
config rule
option name Allow-Ping
option src wan
option proto icmp
option icmp_type echo-request
option family ipv4
option target ACCEPT


config rule
option name Allow-IGMP
option src wan
option proto igmp
option family ipv4
option target ACCEPT


# Allow DHCPv6 replies
# see https://dev.openwrt.org/ticket/10381
config rule
option name Allow-DHCPv6
option src wan
option proto udp
option src_ip fe80::/10
option src_port 547
option dest_ip fe80::/10
option dest_port 546
option family ipv6
option target ACCEPT


config rule
option name Allow-MLD
option src wan
option proto icmp
option src_ip fe80::/10
list icmp_type '130/0'
list icmp_type '131/0'
list icmp_type '132/0'
list icmp_type '143/0'
option family ipv6
option target ACCEPT


# Allow essential incoming IPv6 ICMP traffic
config rule
option name Allow-ICMPv6-Input
option src wan
option proto icmp
list icmp_type echo-request
list icmp_type echo-reply
list icmp_type destination-unreachable
list icmp_type packet-too-big
list icmp_type time-exceeded
list icmp_type bad-header
list icmp_type unknown-header-type
list icmp_type router-solicitation
list icmp_type neighbour-solicitation
list icmp_type router-advertisement
list icmp_type neighbour-advertisement
option limit 1000/sec
option family ipv6
option target ACCEPT


# Allow essential forwarded IPv6 ICMP traffic
config rule
option name Allow-ICMPv6-Forward
option src wan
option dest *
option proto icmp
list icmp_type echo-request
list icmp_type echo-reply
list icmp_type destination-unreachable
list icmp_type packet-too-big
list icmp_type time-exceeded
list icmp_type bad-header
list icmp_type unknown-header-type
option limit 1000/sec
option family ipv6
option target ACCEPT


# include a file with users custom iptables rules
config include
option path /etc/firewall.user




### EXAMPLE CONFIG SECTIONS
# do not allow a specific ip to access wan
#config rule
# option src lan
# option src_ip 192.168.45.2
# option dest wan
# option proto tcp
# option target REJECT


# block a specific mac on wan
#config rule
# option dest wan
# option src_mac 00:11:22:33:44:66
# option target REJECT


# block incoming ICMP traffic on a zone
#config rule
# option src lan
# option proto ICMP
# option target DROP


# port redirect port coming in on wan to lan
#config redirect
# option src wan
# option src_dport 80
# option dest lan
# option dest_ip 192.168.16.235
# option dest_port 80
# option proto tcp


# port redirect of remapped ssh port (22001) on wan
#config redirect
# option src wan
# option src_dport 22001
# option dest lan
# option dest_port 22
# option proto tcp


# allow IPsec/ESP and ISAKMP passthrough
config rule
option src wan
option dest lan
option proto esp
option target ACCEPT


config rule
option src wan
option dest lan
option dest_port 500
option proto udp
option target ACCEPT


### FULL CONFIG SECTIONS
#config rule
# option src lan
# option src_ip 192.168.45.2
# option src_mac 00:11:22:33:44:55
# option src_port 80
# option dest wan
# option dest_ip 194.25.2.129
# option dest_port 120
# option proto tcp
# option target REJECT


#config redirect
# option src lan
# option src_ip 192.168.45.2
# option src_mac 00:11:22:33:44:55
# option src_port 1024
# option src_dport 80
# option dest_ip 194.25.2.129
# option dest_port 120
# option proto tcp


Don't forget to add the newly created AP to the LAN firewall Zone.

vi /etc/config/firewall

config defaults
option syn_flood 1
option input ACCEPT
option output ACCEPT
option forward REJECT
option drop_invalid '1'

config zone
option name lan
list network 'lan'
list network 'lan6'
option input ACCEPT
option output ACCEPT
option forward ACCEPT


# include a file with users custom iptables rules
config include
option path /etc/firewall.user


config zone
        option name 'service'
        list network 'service'
        option forward 'REJECT'
        option family 'ipv4'
        list masq_dest '192.168.8.1/255.255.255.255'
        option input 'REJECT'
        option output 'ACCEPT'

config rule
        option src 'service'
        option src_port '67-68'
        option dest_port '67-68'
        option proto 'udp'
        option target 'ACCEPT'
        option name 'Allow DHCP request'

config rule
        option name 'Allow Ping'
        option src 'service'
        option proto 'icmp'
        option icmp_type 'echo-request'
        option target 'ACCEPT'

config rule
        option name 'Allow IGMP'
        option src 'service'
        option proto 'igmp'
        option target 'ACCEPT'


config rule                                         
        option src 'service'    
        option dest_port '53'                       
        option proto 'tcpudp' 
        option target 'ACCEPT'         
        option name 'Allow DNS Queries'

config rule                                    
        option enabled '1'    
        option target 'ACCEPT'                  
        option name 'Allow SSH'
        option proto 'tcp'     
        option dest_port '22'
        option src 'service' 

                                
config rule                     
        option src 'service'            
        option name 'Allow service -> http LAN'
        option proto 'tcp'              
        option dest_port '80'   
        option target 'ACCEPT'  
                                
config rule                                    
        option target 'ACCEPT'
        option src 'service'           
        option name 'Allow service -> https LAN'
        option proto 'tcp'             
        option dest_port '443'
                                               
config rule                   
        option src 'service'                    
        option name 'Deny service -> Other LAN'
        option proto 'all'    
        option target 'DROP'  
        option dest '*'                        



And Disable Firewall (optional):
/etc/init.d/firewall disable 
/etc/init.d/firewall stop



Multicast forwarding is necessary for DLNA and UPnP clients to work properly. For example PS3, xbox, TVs and stereos use DLNA to detect, communicate with and stream audio/video over the network. Since multicasting is turned off (multicast snooping is turned on) by default in newer OpenWrt releases, it must be activated. This would forward any multicast packets to all ports allowing your TV to find your DLNA capable NAS with movies. In large networks, this could cause some overhead which may not be desirable.
vi /etc/rc.local


# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

echo "0" > /sys/devices/virtual/net/br-lan/bridge/multicast_snooping

exit 0


Config Access Point

Only one change is needed from a normal wireless access point configuration. In the existing wifi-iface section that is being used, add a line with option wds '1'.
edit our  /etc/config/wireless file and disable wifi-iface STA mode and unhide wifi-iface AP mode. Also set this WDS to 1.

vi /etc/config/wireless

config wifi-device radio0
option type mac80211
option hwmode 11g
option path '10180000.wmac'
option channel 1
option htmode HT40
option country '00'
option txpower '17'
option distance '30'

config wifi-iface
option device radio0
option network lan
option ssid 'casa'
option mode 'sta'
option wds '1'
option bssid '90:F6:52:D4:F2:50'
option encryption 'psk-mixed+tkip+ccmp'
option disabled '1'
option key 'wifipassword'

config wifi-iface
option device radio0
option network lan
option ssid 'casa'
option mode 'ap'
option wds '1'
option encryption 'psk-mixed+tkip+ccmp'
option hidden '0'
option key 'wifipassword'

config wifi-iface
option device radio0
option network service
option mode ap
option ssid service
option encryption none
option isolate 1
option hidden '1'


Apply changes:

/etc/init.d/network reload

/etc/init.d/firewall restart

/etc/init.d/dnsmasq restart


To access each router in "service" mode connect to wifi ssid ( YS161919451F , YS160708032F ) and point browser to http://192.168.8.1. Then login with your root password at luci interface. It is not very safe if you have an hacker close to you, but is very handy.

On the router you should config these MAC Address to have reserved client dhcp:
router YS160708032F = 20:28:18:a1:e5:2e
router YS161919451F = 20:28:18:a2:2c:12