Turn router into switch

I got a new router, so I'd like to turn my old router, ASUS RT-N16, into a switch. It has 4 LAN ports and 1 WAN port on the back.

(Later I'll also make it an access point, but I want to get it working as a switch first.)

I followed the instructions on Bridged AP and Dumb AP. I disabled dnsmasq, firewall, and dhcp. My /etc/config/network is at the end of this post.

When I connect my laptop directly to the new router, I can ssh to my RT-N16 LEDE box just fine. But when I connect my laptop (wired) to the RT-N16 LEDE box, it can't even get an IP address.

How can I get it working as a switch?

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 'fdb3:20ff:3899::/48'

config interface 'lan'
	option type 'bridge'
	option ifname 'eth0'
	option proto 'static'
	option ipaddr '192.168.1.2'
	option netmask '255.255.255.0'
	option gateway 192.168.1.1
	option dns 192.168.1.1
	option ip6assign '60'

When you plug in to the Asus, you use a LAN port right? The Asus is also connected to your new router through one of its LAN ports?

Reconfigure the hardware Ethernet switch so that all switch ports are in the same VLAN. Your /etc/config/network should have a switch configuration section. If you removed it you may want to reset to defaults (firstboot) and start over.

Until you do this you can still use the router as a switch on the 4 LAN ports. The WAN port will not be usable.

1 Like

@Borromini Yep, I have a cable from an ASUS LAN port to the rest of my home network, and I can ssh to the ASUS.

@mk24 My /etc/config/network didn't have a switch section, and I've done reset / firstboot a couple times. :slight_smile: "Until you do this you can still use the router as a switch on the 4 LAN ports." The problem is, I currently can't use the router as a switch on the 4 LAN ports.

I'll look into the VLAN / switch stuff. Thanks!

Since it has one CPU port, the default setup to use as a router should be something like eth0.1 the 4 LAN ports, in the LAN network, and eth0.2 the WAN port, in the WAN network.

Using plain eth0 is not recommended unless you have changed the switch configuration to make everything one VLAN with the CPU port untagged.

@mk24

Thanks again.

The 4 LAN ports use a Broadcom BCM53115 switch, but the WAN port is integrated into the Broadcom BCM4718 platform, according to this page: https://wiki.openwrt.org/toh/hwdata/asus/asus_rt-n16

ls -l /sys/class/net
lrwxrwxrwx     Oct 17 17:52 br-lan -> ../../devices/virtual/net/br-lan
lrwxrwxrwx     Jan  1  1970 eth0 -> ../../devices/bcma0:2/net/eth0
lrwxrwxrwx     Jan  1  1970 lo -> ../../devices/virtual/net/lo
lrwxrwxrwx     Dec 16 17:00 wlan0 -> ../../devices/bcma0:1/net/wlan0

Using plain eth0 is not recommended unless you have changed the switch configuration to make everything one VLAN with the CPU port untagged.

Having one VLAN with the CPU port untagged sounds great to me. How do I set that up? In /etc/config/network, have one "config switch" section and one "config switch_vlan" section?

VLAN1 is understood as a Switch's and a LAN's "default LAN."

As @mk24 stated, make all switch ports LAN (e.g. untagged of eth0.1), and just add a LAN IP, gateway and DNS - then you have your basic managed switch.

Here's the configs I use for my WRT1900ACS, which is configured as a smart switch

  • /etc/config/dhcp
    #
    
        ##::[[---  LEDE LAN DHCP Config  ---]]::##
    
    ####################################################
                 ##----- DNS Server -----##
    ####################################################
    
        # DNS Masq #
    #---------------------------------------------------
    config dnsmasq
        option  domain                  'WRT'
        option  local                   '/lan/'
        option  leasefile               '/tmp/dhcp.leases'
        option  resolvfile              '/tmp/resolv.conf.auto'
        option  localise_queries        1
        option  readethers              1
        option  localservice            1
        option  logquerries             1
        option  domainneeded            1
        option  filterwin2k             0
        option  authoritative           0
        option  rebind_protection       0
        option  sequential_ip           1
        option  nonwildcard             0
    
    ####################################################
               ##----- oDHCPd Server -----##
    ####################################################
    
        # oDHCPd #
    #---------------------------------------------------
    config odhcpd 'odhcpd'
        option  maindhcp            0
        option  leasefile           '/tmp/hosts/odhcpd'
        option  leasetrigger        '/usr/sbin/odhcpd-update'
        option  loglevel            4
    
    ####################################################
               ##----- DHCP Settings -----##
    ####################################################
    
        # LAN: Home Network #
    #---------------------------------------------------
    config dhcp 'lan'
        option  interface           'lan'
        option  leasetime           '24h'
        option  dhcpv6              'server'
        option  ra                  'server'
        option  ra_management       1
        option  start               40
        option  limit               10
        option  force               1
    
    

  • /etc/config/firewall
    #
    
      ##::[[---  LEDE LAN Firewall Config  ---]]::##
    
    ####################################################
                 ##----- Scripts -----##
    ####################################################
    
    config include
        option  path            '/etc/firewall.user'
    
    ####################################################
            ##----- Blocked IPs & MACs -----##
    ####################################################
    
        # Devices #
    #---------------------------------------------------
    
    ####################################################
              ##----- Default Zone -----##
    ####################################################
    
    config defaults
        option  input                 'ACCEPT'
        option  output                'ACCEPT'
        option  forward               'ACCEPT'
        option  custom_chains         1
        option  drop_invalid          0
        option  synflood_protect      0
        option  tcp_syncookies        1
    
    ####################################################
                 ##----- Zones -----##
    ####################################################
    
        # LAN #
    #---------------------------------------------------
    config zone
        option  name            'lan'
        option  network         'lan'
        option  input           'ACCEPT'
        option  output          'ACCEPT'
        option  forward         'ACCEPT'
    
    

  • /etc/config/network
    #
    
      ##::[[---  LEDE LAN Network Config  ---]]::##
    
    ####################################################
                   ##----- Global -----##
    ####################################################
    
        # Globals #
    #---------------------------------------------------
    config globals 'globals'
        option  ula_prefix     'fde1:a11b:b64f::/48'
    
    ####################################################
            ##----- Active Networks w/ LAN-----##
    ####################################################
    
        # Loopback #
    #---------------------------------------------------
    config interface 'loopback'
        option  ifname          'lo'
        option  proto           'static'
        option  ipaddr          127.0.0.1
        option  netmask         255.0.0.0
    
        # LAN: Home Network #
    #---------------------------------------------------
    config interface 'lan'
        option  ifname          'eth0.1 eth1.2'
        option  _orig_ifname    'eth0.1'
        option  type            'bridge'
        option  _orig_bridge    'true'
        option  proto           'static'
        option  ip6assign       60
        option  ipaddr          192.168.20.1
        option  netmask         255.255.255.192
        option  broadcast       192.168.20.63
        option  dns             192.168.20.62
        option  gateway         192.168.20.62
        option  force_link      1
    
    ####################################################
              ##----- Virtual Switches -----##
    ####################################################
    
        # vSwitches #
    #---------------------------------------------------
    
      # Switch 0:
    config switch
        option  name            'switch0'
        option  reset           1
        option  enable_vlan     1
    
        # vLANs #
    #---------------------------------------------------
    
      # 1: LAN
    config switch_vlan
        option  device          'switch0'
        option  vlan            1
        option  ports           '0 1 2 3 4 5t 6t'
    
    ####################################################
         ##----- Inactive Networks for WAN -----##
    ####################################################
    
        # LAN #
    #---------------------------------------------------
    #config interface 'lan'
    #   option  ifname          'eth0.1'
    #   option  type            'bridge'
    #   option  proto           'static'
    #   option  ip6assign       60
    #   option  ipaddr          192.168.20.1
    #   option  netmask         255.255.255.192
    #   option  broadcast       192.168.20.63
    #   option  dns             '208.67.222.222 208.67.220.220'
    #   option  force_link      1
    
        # WAN #
    #---------------------------------------------------
    #config interface 'wan'
    #   option  ifname          'eth1.2'
    #   option  proto           'dhcp'
    
    #config interface 'wan6'
    #   option  ifname          'eth1.2'
    #   option  proto           'dhcpv6'
    
    ####################################################
         ##----- Inactive Virtual Switches -----##
    ####################################################
    
        # vLANs #
    #---------------------------------------------------
    
      # 2: WAN:
    #config switch_vlan
    #   option  device          'switch0'
    #   option  vlan            2
    #   option  ports           '4 6t'
    
    
    • Where 192.168.20.62 is the LAN IP of your WAN facing router

.
Here's how I've laid out my file system, of which allows for an easy switch back to a router, and vice versa

  • I recommend saving all your WAN configs to either external storage, or /etc/config/WAN/
    • Files specific for WAN:

      • ddns
      • dhcp
      • firewall
      • network
      • qos
      • sqm
      /etc/config:
           0 drwxr-xr-x    2 root     root           162 Oct  1 06:01 LAN
           0 drwxr-xr-x    1 root     root           304 Oct  1 06:01 WAN
          12 -rw-r--r--    1 root     root          9992 Oct  1 06:01 adblock
           4 -rw-r--r--    1 root     root          1176 Oct  1 06:01 aria2
           4 -rw-r--r--    1 root     root           148 Jan 18 20:38 attendedsysupgrade
           4 -rw-r--r--    1 root     root           494 Oct  1 06:01 cshark
           4 -rw-r--r--    1 root     root           590 Jan 18 20:38 ddns
          12 -rw-r--r--    1 root     root          9871 Oct  1 12:48 dhcp
           4 -rw-r--r--    1 root     root           462 Oct  1 06:01 dropbear
           4 -rw-r--r--    1 root     root           720 Oct  1 06:01 etherwake
          16 -rw-r--r--    1 root     root         12691 Oct  1 12:26 firewall
           4 -rw-r--r--    1 root     root           941 Oct  1 06:01 fstab
           4 -rw-r--r--    1 root     root           379 Oct  1 06:01 hd-idle
           4 -rw-r--r--    1 root     root           797 Jan 18 20:38 luci
           8 -rw-r--r--    1 root     root          6578 Oct  1 06:01 luci_statistics
           8 -rw-r--r--    1 root     root          6065 Oct  1 12:42 network
           4 -rw-r--r--    1 root     root          3906 Oct  1 06:01 openvpn
           4 -rw-------    1 root     root           743 Oct  1 06:01 openwisp
           4 -rw-r--r--    1 root     root           366 Oct  1 06:01 p910nd
           4 -rw-r--r--    1 root     root          3276 Oct  1 06:01 qos
           4 -rw-------    1 root     root            97 Oct  1 06:01 rpcd
           4 -rw-r--r--    1 root     root           820 Oct  1 06:01 samba
           1 -rw-r--r--    1 root     root           939 Oct  1 06:01 sqm
           4 -rw-------    1 root     root           174 Oct  1 06:01 sysstat
           4 -rw-r--r--    1 root     root          2738 Oct  1 06:01 system
           4 -rw-r--r--    1 root     root           115 Jan 18 20:38 ubootenv
           4 -rw-r--r--    1 root     root           856 Jan 18 20:38 ucitrack
           4 -rw-------    1 root     root          1801 Oct  1 06:01 uhttpd
           4 -rw-r--r--    1 root     root          1019 Oct  1 06:01 wifi_schedule
           8 -rw-------    1 root     root          6988 Dec  8 19:29 wireless
      
      /etc/config/LAN:
           1 -rw-r--r--    1 root     root          1281 Oct  1 06:01 ddns.LAN
          11 -rw-r--r--    1 root     root         10855 Oct  1 06:01 dhcp.LAN
           9 -rw-r--r--    1 root     root          9363 Oct  1 06:01 firewall.LAN
           5 -rw-r--r--    1 root     root          5323 Oct  1 06:01 network.LAN
           4 -rw-r--r--    1 root     root          3853 Oct  1 06:01 qos.LAN
           1 -rw-r--r--    1 root     root           939 Oct  1 06:01 sqm.LAN
      
      /etc/config/WAN:
           4 -rw-r--r--    1 root     root          1281 Oct  1 06:01 ddns.WAN
           8 -rw-r--r--    1 root     root          7920 Oct  1 06:01 dhcp.WAN
          16 -rw-r--r--    1 root     root         13757 Oct  1 06:01 firewall.WAN
           5 -rw-r--r--    1 root     root          5330 Oct  1 06:01 network.WAN
           4 -rw-r--r--    1 root     root          3853 Oct  1 06:01 qos.WAN
           1 -rw-r--r--    1 root     root           939 Oct  1 06:01 sqm.WAN
      
      

Thanks all. All I had to do was add this to the end of /etc/config/network:

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 8'

And wired devices that I connect to my 4 LAN ports seem to all be on the same LAN!

Next step: getting the WAN port included. :slight_smile: Wish me luck.

Weird... I clearly gave you the wrong information, and that's a weird numbering for the CPU port.

  • Normally, switch ports go in numerical order, starting from the left if you're looking at the back of the router, with the CPU port(s) on a 4 LAN router normally being sw.port 5, and if CPU has 2 ports, sw.port 6

.
I completely missed that in your original post, my bad =]

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