フォーラムに解決方法があったので,WN-G300DGR の OpenWrt を再設定した。
https://forum.openwrt.org/viewtopic.php?pid=192105#p192105

起動して luci で確認すると,WAN/LAN ポートが正しくアサインされており,問題はほぼ解決した。 (WAN/LAN,APのある無線LANルータの基本形になった)

WN-G300DGR は,rt305x 組み込みのスイッチと,RTL8366RB スイッチの 2 つのスイッチを持っている。

rt305xスイッチ の#6がCPUとリンクしている内部ポートで,rt305xスイッチの#5がRTL8366RB の#5とリンクしている。 RTL8366RBのポートが実際の接続用ポートだ。
vlan1 がLAN,vlan2 がWANで,#5,#6はトランクポートになっている。
実際のポートは #0,#1,#2 がLAN,#3がWANになる。(WN-G300DGR は0123の4ポート)
(RTL8366RB の カーネルモジュールを組み込んでおく。)

以上を設定に反映するため,/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 interface 'lan'
option ifname 'eth0.1'
option type 'bridge'
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
option macaddr '00:a0:b0:b4:ca:74'

config interface 'wan'
option ifname 'eth0.2'
option proto 'dhcp'
option macaddr '00:a0:b0:b4:ca:75'

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

config switch_vlan
option device 'switch1'
option vlan '1'
option ports '0 1 2 5t'

config switch_vlan
option device 'switch1'
option vlan '2'
option ports '3 5t'

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

config switch_vlan
option device 'switch0'
option vlan '1'
option ports '5t 6t'

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




これで動いたので,ソースも書き換えた。 

~/trunk/target/linux/ramips/base-files/etc/uci-defaults/02_network


wl-351)
ucidef_set_interfaces_lan_wan "eth0.1" "eth0.2"
ucidef_add_switch "switch1" "1" "1"
ucidef_add_switch_vlan "switch1" "1" "0 1 2 5t"
ucidef_add_switch_vlan "switch1" "2" "3 5t"
ucidef_add_switch "switch0" "1" "1"
ucidef_add_switch_vlan "switch0" "1" "5t 6t"
ucidef_add_switch_vlan "switch0" "2" "5t 6t"
;;

 





5t,6t などtが付く数字は tagged ポートの番号だ。 


sitecom WL-351 用のOpenWrtファームウェアを使っているので,ボード名に WL-351 が表示される。 
ボード名が WN-G300DGR になるよう OpenWrt のソースを変更追加している。