How to set up wireless network on OpenWrt + OVS router?

2.1k views Asked by At

I flashed OpenWrt + Open Vswitch on a router: TP-link AC1750

I want to add a controller (floodlight) listens on the router and all devices connected to the wireless network can be seen on floodlight.

I have read the document on openwrt.org to learn the terms about the configuration file: /etc/config/network. But I still have some basic questions hope anyone can help me out. Thanks!

  1. What is the device of Wifi? Is it wan/wan6?
  2. What is br-lan in ifconfig output? Why its ip is 192.168.1.1? Does this mean any devices connected by wireless network are connected to br-lan? And I don’t know where to find the configuration of it.
  3. On the architecture of the router in the picture, why br-lan is bridge between wifi and eth1? In the default configuration file, wan/wan6 should be on eth0, right? I’m kinda confused by comparing them.
  4. I add a bridge named ‘mybridge’ with ove-vsctl. But when I add port on it with ovs-vsctl add-port mybridge {wlan0, eth1}, there is error reported? But if I add eth0, there is no error anymore.

Because only ovs bridge can be listened by controller, I believe I have to use ovs-vsctl create a bridge to replace the function of br-lan. But I don’t know where to start. Except questions above, anybody could show me the direction to do this please? Thanks.

The ifconfig output:

br-lan    Link encap:Ethernet  HWaddr A4:2B:B0:DC:64:34
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fd40:41e7:b9c0::1/60 Scope:Global
          inet6 addr: fe80::a62b:b0ff:fedc:6434/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:151654 errors:0 dropped:0 overruns:0 frame:0
          TX packets:236631 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:15601422 (14.8 MiB)  TX bytes:251291293 (239.6 MiB)

eth0      Link encap:Ethernet  HWaddr A4:2B:B0:DC:64:35
          inet addr:192.168.0.106  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::a62b:b0ff:fedc:6435/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1083749 errors:0 dropped:0 overruns:0 frame:0
          TX packets:150544 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:433298836 (413.2 MiB)  TX bytes:18665423 (17.7 MiB)
          Interrupt:4

eth1      Link encap:Ethernet  HWaddr A4:2B:B0:DC:64:34
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:3 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9727 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:335 (335.0 B)  TX bytes:676714 (660.8 KiB)
          Interrupt:5

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:905 errors:0 dropped:0 overruns:0 frame:0
          TX packets:905 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:85370 (83.3 KiB)  TX bytes:85370 (83.3 KiB)

wlan0     Link encap:Ethernet  HWaddr A4:2B:B0:DC:64:33
          inet6 addr: fe80::a62b:b0ff:fedc:6433/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:153653 errors:0 dropped:0 overruns:0 frame:0
          TX packets:223631 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:17983679 (17.1 MiB)  TX bytes:256128206 (244.2 MiB)

The default /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 'fd40:41e7:b9c0::/48'

config interface 'lan'
        option ifname 'eth1'
        option force_link '1'
        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'
        option proto 'dhcp'

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

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '1 2'
        
config switch_vlan
        option device 'switch0'
        option vlan '1'
        option ports '0 2 3 4 5'

config switch_vlan
        option device 'switch0'
        option vlan '2'
        option ports '1 6'

The structure of the router:

Default figure of the router

1

There are 1 answers

0
Leo On BEST ANSWER

I figured it out. Here is the steps:

I created a new bridge by

ovs-vsctl add-br mybridge

Then I compared /etc/config/wireless and /etc/config/network, I found wireless device is connected to interface 'lan' and 'eth1', just like the figure I attacked above. So I think interface 'lan' could equal to 'br-lan' to some extent. Then in /etc/config/network, I modified:

config interface 'lan'
        option ifname 'eth1 mybridge'
        option force_link '1'
        option type 'bridge'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask '255.255.255.0'
        option ip6assign '60'

And set controller on 'mybridge' by:

ovs-vsctl set-controller mybridge tcp:ip:port

Finally I can see the devices connected to the router on controller side and push flows about the devices.