[SOLVED] Using OpenWrt as SDN-controlled switch with OpenDayLight

Hi. I'm currently working on my final project about SDN and using my OpenWRT router as SDN-controlled switch and using OpenDayLight as my SDN controller. I follow some of blog and articel. i had a few problems:

  1. I config /etc/config/network, I intend to use WAN port on my router as management-port, i already set it to static and given the static IP address but i somehow can't access it (via ssh, ping or web). here is my configuration:
config 'switch'
	option 'name' 'rt18366rb'
	option 'enable_vlan' '1'
	option 'enable_learning' '0'

config 'switch_vlan'
	option 'device' 'rt18366rb'
	option 'vlan' '1'
	option 'ports' '1 5t'

config 'switch_vlan'
	option 'device' 'rt18366rb'
	option 'vlan' '2'
	option 'ports' '2 5t'

config 'switch_vlan'
	option 'device' 'rt18366rb'
	option 'vlan' '4'
	option 'ports' '4 5t'

config 'interface'
	option 'ifname' 'eth0.4'
	option 'proto' 'static'

config 'interface'
	option 'ifname' 'eth0.3'
	option 'proto' 'static'

config 'interface'
	option 'ifname' 'eth0.2'
	option 'proto' 'static'

config 'interface Lan'
	option 'type' 'bridge'
	option 'ifname' 'eth0.1'
	option 'proto' 'static'
	option 'ipaddr' '192.168.1.1'
	option 'netmask' '255.255.255.0'

config 'interface' 'loopback'
	option 'ifname' 'lo'
	option 'proto' 'static'
	option 'ipaddr' '127.0.0.1'
	option 'netmask' '255.0.0.0'
  1. I already installed openvswitch package on my router, everytime my router reboot, the ovs-vsctl didn't start automatically, so i have to start/restart the openvswitch service manually to get the ovs-vsctl work.

Please help me solve this problem. Thanks for the advance!

You need to assign some IP/MASK for static protocol to work.

How do you start the server? Is there some init script or manually?

1 Like

Okay, so i tweak my configuration a bit and i'm able to gain access to my router through wan port. but when i check on luci and open the Network -> interface, i see some odd.

here my new config on /etc/config/network:

root@OpenWrt:~# 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 'fd94:1398:c83c::/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'
		option gateway '192.168.1.254'
		option dns '8.8.8.8'             
    	                                      
config device 'lan_dev'                   
        option name 'eth1'              
        option macaddr '98:de:d0:xx:xx:xx'

config interface 'lan3'
	option ifname 'eth1.3'
	option proto 'static'

config interface 'lan4'
	option ifname 'eth1.4'
	option proto 'static'

config interface 'lan5'
	option ifname 'eth1.5'
	option proto 'static'

config interface 'lan6'
	option ifname 'eth1.6'
	option proto 'static'


config interface 'wan'                         
    option ifname 'eth0'            
    option proto 'static'
	option ipaddr '192.168.2.1'
	option netmask '255.255.255.0'
	option gateway '192.168.1.254'
	option dns '192.168.1.254'
	option type 'bridge'

config device 'wan_dev'                        
        option name 'eth0'                   
        option macaddr '98:de:d0:xx:xx:xx'     
                                               
config interface 'wan6'                        
        option ifname 'eth0'                 
        option proto 'dhcpv6'                  
                                               
config switch                                  
        option name 'rtl8366rb'             
        option reset '1'              
        option enable_vlan '1'
		option enable_learning '0'            
                                          
config switch
        option device 'rtl8366rb'     
        option vlan '2'                        
        option ports '1 0t'        
                                  
config switch_vlan  
        option device 'rtl8366rb'  
        option vlan '3'               
        option ports '2 0t'      
                               
config switch_vlan 
        option device 'rtl8366rb'
        option vlan '4'           
        option ports '3 0t'      
                             
config switch_vlan  
        option device 'rtl8366rb'
        option vlan '5'          
        option ports '4 0t'       
                             
config switch_vlan 
        option device 'rtl8366rb'
        option vlan '6'          
        option ports '0 5t'

What do you mean by start the server?

Thanks for answering !

Try using proto manual instead of static on the LAN interfaces if you don't want to assign IP addresses.

Or it might be enough to add a "config device" for each vlan instead of configuring interfaces. See https://openwrt.org/docs/guide-user/network/vlan/switch_configuration

Hi. I already try what you said, using 'config device' solution. but it make my router inaccessible again. i tried the solution on this : https://openwrt.org/toh/tp-link/tl-wr1043nd (my router is wr1043ND v4) on the section of Use eth1.<VLAN ID> interface instead of eth0.<VLAN ID> for additional VLAN-s on v2.x, v3.x router hardware example. That solution seems so viable to me but it's still make my router inaccessible. And i already set IP address on the static interface that not yet have it before. here my current configuration:

root@(none):/rom/root# 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 'fd94:1398:c83c::/48'

config switch
#	option name 'rtl8366rb'
	option name 'switch0'
	option reset '1'
	option enable_vlan '1'
	option enable_learning '0'
	option enable_vlan4k '1'

config switch_vlan
	option device 'switch0'
	option vlan '5'
	option ports '0t 4'
	option vid '5'

config switch_vlan
	option device 'switch0'
	option vlan '4'
	option ports '3 0t'
	option vid '4'

config switch_vlan
	option device 'switch0'
	option vlan '3'
	option ports '2 0t'
	option vid '3'

config switch_vlan
	option device 'switch0'
	option vlan '1'
	option ports '0t 1'
	option vid '1'

config switch_vlan
	option device 'switch0'
	option vlan '2'
	option vid '2'
	option ports '5 6'

config device 'lan_dev1'
	option name 'eth1.1'
	option macaddr '98:de:d0:xx:xx:xx'

config device 'lan_dev2'
	option name 'eth1.3'
	option macaddr '98:de:d0:xx:xx:xx'

config device 'lan_dev3'
	option name 'eth1.4'
	option macaddr '98:de:d0:xx:xx:xx'

config device 'lan_dev4'
	option name 'eth1.5'
	option macaddr '98:de:d0:xx:xx:xx'

config device 'wan'
	option name 'eth0'
	option macaddr '98:de:d0:xx:xx:xx'

config interface 'lan1'
	option type 'bridge'
	option force_link '1'
	option ifname 'eth1.1'
	option proto 'static'
	option ipaddr '192.168.1.1'
	option netmask '255.255.255.0'
	option ip6assign '60'
	option gateway '192.168.1.254'
	option dns '8.8.8.8'

config interface 'lan2'
	option ifname 'eth1.3'
	option proto 'static'
	option ipaddr '192.168.3.1'
	option netmask '255.255.255.0'

config interface 'lan3'
	option ifname 'eth1.4'
	option proto 'static'
	option ipaddr '192.168.4.1'
	option netmask '255.255.255.0'
	
config interface 'lan4'
	option ifname 'eth1.5'
	option proto 'static'
	optiom ipaddr '192.168.5.1'
	option netmask '255.255.255.0'

config interafe 'wan'
	option type 'bridge'
	option ifname 'eth0'
	option proto 'static'
	option ipaddr '192.168.2.1'
	option netmask '255.255.255.0'
	option gateway '192.168.1.254'
	option dns '8.8.8.8'

config interface 'wan6'
	option ifname '@wan'
	option proto 'dhcpv6'

INPUT chain policy for wan zone is DENY by default. You need to open up access by editing /etc/config/firewall.

UPDATE: ICMP ping should work by default.

To start ovs daemons at boot time, try the following with recent versions of openvswitch package. More info can be found at the package README.md

  1. Edit /etc/config/openvswitch and enable ovs
  2. /etc/init.d/openvswitch enable

i think i already put firewall to accept anything, i could be wrong. here my firewall configuration:

root@(none):~# cat /etc/config/firewall
config defaults
	option syn_flood	1
	option input		ACCEPT
	option output		ACCEPT
	option forward		ACCEPT
# 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		ACCEPT
	option output		ACCEPT
	option forward		ACCEPT
	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		fc00::/6
	option dest_ip		fc00::/6
	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

config rule
	option name		Allow-IPSec-ESP
	option src		wan
	option dest		lan
	option proto		esp
	option target		ACCEPT

config rule
	option name		Allow-ISAKMP
	option src		wan
	option dest		lan
	option dest_port	500
	option proto		udp
	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

### 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

and i'm also can't ICMP ping too beside remote to the router normally (not through failsafe mode). And i know how to enable the ovs deamon. what i mean is, it's not automatically start everytime my router reboot, i have to do it manually. perhaps, like you mention, i forgot to enable it at /etc/init.d/openvswitch enable

Thanks for answering ! I'm really appreciate it !

The above does not look right. Gateway is supposed to be in the same subnet as that of the host. Please check your network setting with ip command. I am afraid the route for return traffic is wrong.

The initscript enable call should be done by default on installation. You can check content of /etc/rc.d/ to see whether openvswitch is there.

The gateway IP is my modem router IP. but currently i didn't use/connect it to. i've tried to connect to the WAN interface of my router and config my PC port with static IP that match with the subnet on what i write on the interface 'wan' config, but still can't access it and ping it. this is stressing me out xD

So, it is starting to get me crazy! i decided to restart everything from ground up using failsafe mode firstboot. and then i configure /etc/config/network and /etc/config/firewall according to my own knowledge and understanding after saw so many example from documentation, blog, and articel. I've come up with this configuration:

/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 'fdbc:261a:0d40::/48'

config interface 'lan1'
	option type 'bridge'
	option ifname 'eth0.1'
	option proto 'static'
	option ipaddr '192.168.1.1'
	option netmask '255.255.255.0'
	option ip6assign '60'

config device 'lan1_dev'
	option name 'eth0.1'
	option macaddr '98:de:d0:xx:xx:xx'

config interface 'lan2'
	option ifname 'eth0.3'
	option proto 'static'
	option ipaddr '192.168.3.1'
	option netmask '255.255.255.0'

config device 'lan2_dev'
	option name 'eth0.3'
	option macaddr '98:de:d0:xx:xx:xx'

config interface 'lan3'
	option ifname 'eth0.4'
	option proto 'static'
	option ipaddr '192.168.4.1'
	option netmask '255.255.255.0'

config device 'lan3_dev'
	option ifname 'eth0.4'
	option macaddr '98:de:d0:xx:xx:xx'

config interface 'lan4'
	option ifname 'eth0.5'
	option proto 'static'
	option ipaddr '192.168.5.1'
	option netmask '255.255.255.0'

config device 'lan4_dev'
	option ifname 'eth0.5'
	option macaddr '98:de:d0:xx:xx:xx'

config interface 'wan'
	option ifname 'eth0.2'
	option proto 'static'
	option ipaddr '192.168.2.1'
	option netmask '255.255.255.0'

config device 'wan_dev'
	option name 'eth0.2'
	option macaddr '98:de:d0:xx:xx:xx'

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

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

config switch_vlan
	option device 'switch0'
	option vlan '1'
	option ports '1 0t'

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

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

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

config switch_vlan
	option device 'switch0'
	option vlan '5'
	option ports '4 0t'
/etc/config/firewall

root@OpenWrt:~# cat /etc/config/firewall
config defaults
	option syn_flood	1
	option input		ACCEPT
	option output		ACCEPT
	option forward		ACCEPT
# Uncomment this line to disable ipv6 rules
#	option disable_ipv6	1

config zone
	option name		lan
	list   network		'lan1'
	list   network          'lan2'
	list   network          'lan3'
	list   network          'lan4'
	option input		ACCEPT
	option output		ACCEPT
	option forward		ACCEPT

config zone
	option name		wan
	list   network		'wan'
	list   network		'wan6'
	option input		ACCEPT
	option output		ACCEPT
	option forward		ACCEPT
	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		fc00::/6
	option dest_ip		fc00::/6
	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

config rule
	option name		Allow-IPSec-ESP
	option src		wan
	option dest		lan
	option proto		esp
	option target		ACCEPT

config rule
	option name		Allow-ISAKMP
	option src		wan
	option dest		lan
	option dest_port	500
	option proto		udp
	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

### 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

And the result with that configuration that i come up on my own is WORKING ! I'm really happy, so happy that i could be crying out loud. this problem have been on my mind ever since five days ago. I'm really respect and appreciate you guys all that have been answering and try to help me, i believe i couldn't come up with that without your guys answer. Here some screenshot from LuCi in network -> Interface and network -> Switches :

2 Likes

If your problem is solved, feel free to mark the relevant post as the solution; and edit the title to add "[SOLVED]" to the beginning (click the pencil behind the topic).

grafik

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.