Why I cannot set the pvid of a switch port?

I have try three methods:

1st. with swconfig command

root@OpenWrt:~# swconfig dev switch0 port 4 set pvid 2
root@OpenWrt:~# swconfig dev switch0 port 4 get pvid
1

2nd. edit /etc/config/network file and load

config switch_port
        option port '4'
        option pvid '2'

root@OpenWrt:/# swconfig dev switch0 load network
root@OpenWrt:/# swconfig dev switch0 port 4 show | grep pvid
        pvid: 1

3rd. use uci command and restart network

uci show network
network.@switch_port[0]=switch_port
network.@switch_port[0].port='4'
network.@switch_port[0].pvid='2'

root@OpenWrt:/# /etc/init.d/network restart
root@OpenWrt:/# swconfig dev switch0 port 4 show | grep pvid
        pvid: 1

It's been bothering me all day, and does anyone know why?

Thanks,
kun

I think your config switch_port section lacks an option device switch0 to link it to the switch. Without that option, swconfig likely ignores this per-port section entirely.

of course have device switch0 config, but I omit it

config switch 
          option device 'switch0'
          option reset '1'
          option enable_vlan '1'
...

This is not what I meant. I mean that every config switch_vlan and config switch_port section requires an option 'device' 'switch0' to relate this section to the switch it belongs to.

You need

config switch_port
    option device 'switch0'    # this is mandatory
    option port '4'
    option pvid '2'
2 Likes

It works, thanks!

1 Like

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