Remap LAN port to WAN on WD MyNet N750 with OpenWRT

Posted on March 6, 2017

A couple years ago, I got a WD MyNet N750 on sale and put OpenWRT on it, for use as my home wireless router (with the excellent Motorola SURFboard SB6141 serving as modem). It ran flawlessly until last week, when the WAN port on the router stopped working, probably as a result of a power surge during a thunderstorm.

While discussing the problem the next day, a coworker suggested, “Can you work around it?” I realised that I could probably just remap one of the LAN ports on the back (I don’t use all of them) as a WAN port. Here’s how to do it, in case anyone else runs into the same problem.

  1. Go to the WD MYNet N750 page on OpenWRT.org and read it well.

  2. Understand the port mappings. In my case, the WAN port (i.e., port 5) was fried. Port 0 is some kind of mapping to the CPU, which I don’t fully understand.

  3. The /etc/config/network file on your OpenWRT box contains details about the interface mappings. This page is very helpful for understanding this file.

  4. Look at the stanzas for LAN and WAN configs. In my case, they looked like this:

    config interface 'lan'
      option ifname 'eth0.1'
      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.2'
      option proto 'dhcp'
      option macaddr 'xx:xx:xx: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 mirror_sourxce_port '0'
      option mirror_monitor_port '0'
    
    config switch_vlan
      option device 'switch0'
      option vlan '1'
      option vid '1'
      option ports '0t 1 2 3 4'
    
    config switch_vlan
      option device 'switch0'
      option vlan '2'
      option vid '2'
      option ports '0t 5'

    What does this mean? Matching it up with the ports on the OpenWRT page, it looks like ports 0 (the CPU one), alond with the LAN port 1, 2, 3, and 4 are on VLAN 1. And then the WAN port (i.e., port 5 according the page on OpenWRT.org) is on VLAN 2.

  5. So all we should need to do is to take out that pesky ‘5’ in the last section (since it is kaput), and replace it with the LAN port we intend to use instead. I chose port 4. We will also need to take port 4 out of the section for LAN ports since we won’t be able to use it as a LAN port any longer.

  6. So the only two changed sections look as follows:

    config switch_vlan
     option device 'switch0'
     option vlan '1'
     option vid '1'
     option ports '0t 1 2 3' <--- 4 removed
    
    config switch_vlan
       option device 'switch0'
       option vlan '2'
       option vid '2'
       option ports '0t 4' <--- 5 replaced by 4
  7. And we are done! You might need an /etc/init.d/network restart for these changes to take effect. In case you plugged something else into your modem earlier to substitute for the dead router, you also might need to reboot it. After that, your network should be back to normal (less one LAN port).

A couple of other things to keep in mind:

  1. Apparently the t at the end of a port indicates that packets sent on that interface will be tagged with the VLAN in question, whereas without a t just indicates that tagged traffic can be received on that interface.

  2. I flashed my router with the newer OpenWRT release (Chaos Calmer 15.05.1) as part of this troubleshooting, and promptly stumbled (not for the first time) upon the fact that OpenWRT uses Dropbear for SSH while setting up key access. Hat tip, your keys are appended to /etc/dropbear/authorized_keys and not $HOME/.ssh/authorized_keys as you might expect.


❧ Suggestions, comments, etc. can be emailed to comments@mandarg.com