OpenWrt Forum Archive

Topic: How to disable a LAN Port

The content of this topic has been archived on 1 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Dear all,

I need to perform a disconnection from the router (http://wiki.openwrt.org/toh/buffalo/wzr-hp-g300nh2) on a specific LAN port, say LAN-3 as printed on the router case.
The WIKI suggest that the LAN-3 is identified as Logical Port #4 and LuCI Label 5, I then go through the VLAN wiki, seems LAN-3 = VLAN 4
but I don't know how to amend the interface/network config to disable the port

What I want to do is like a cron job, disable the LAN port for a time, then re-enable it.

Great thanks for your help in advance!

Best Regards

seems DD-WRT offers a easier approach by
nvram set vlan1ports="xxxxx"

does Openwrt offers similar option?

Sure, edit /etc/config/network and change the "option ports" line.

You can use "swconfig" to set vlan ID if that's what you want to do.

jow wrote:

Sure, edit /etc/config/network and change the "option ports" line.

Thx for the hints, I have tried to mod the following lines:

config switch_vlan
    option device 'eth0'
    option vlan '1'
    option vid '1'
    option ports '0t 1 3 4 5'

config switch_vlan
    option device 'eth0'
    option vlan '2'
    option ports '0t 2'
    option vid '2' 

I changed the vlan1, i.e. the controlling VLAN for the LAN port, to:

    option ports '0t 1 4 5'

the the internet connection to LAN PORT #3 is still perfectly working, cannot disable it.
am I wrong in some step?

Did you reboot afterwards? Also note that internal port numbers often do not correspond to the case labels.

jow wrote:

Did you reboot afterwards? Also note that internal port numbers often do not correspond to the case labels.

hmm! you are totally right!
i reboot and no more internet connection

but still it can't perform what I need, my case is as below:

i use a homeplug PLC (power line connector?) to connect my computer to router, the heat generation from the PLC is huge and hence connection unstable. I found out the reason is that its sleep mode is not perfect:
on my computer side the PLC can sleep after shut down the computer,
but on the router side it won't sleep unless i manually unplug the lan wire

after the vlan isolation setting as mentioned, the PLC cannot obtain address nor connect to anywhere else, but it still keep trying to communicate with the router and not going to sleep.

so i m wondering any function that i can power-off the port

i checked here http://mlab.my.contact.bg/net/param.htm … _POWERDOWN mentions a powerdown function but i have no idea how to perform it.

sincerely appreciate for any help, thanks!

phuque99 wrote:

You can use "swconfig" to set vlan ID if that's what you want to do.

i notice if I type:

swconfig dev eth0 port 3 get link

it returns

port:3 link:up speed:100baseT full-duplex txflow rxflow

any possibility that i can turn the link from up to down by using swconfig?

like:

link: port5: link:down

thx a lot!

(Last edited by upsangel on 26 Jul 2013, 17:09)

Link up down is not a "switch"; but rather status if an ethernet cable is plugged in. Changing vlan id is the "hack" that you learned from ddwrt. So if you wanna mangle the vlan id, you can use swconfig to do so.

phuque99 wrote:

Link up down is not a "switch"; but rather status if an ethernet cable is plugged in. Changing vlan id is the "hack" that you learned from ddwrt. So if you wanna mangle the vlan id, you can use swconfig to do so.

Thx! i double checked the dd wiki on how to disable port :http://www.dd-wrt.com/wiki/index.php/Switched_Ports#Disable_LAN_ports

seems i have already achieve by mod the .network config
but the communication between the LAN and ROUTER still exists (the LED on the LAN port still blinking slowly)

so i m looking for two alternative:
either disable the LAN ports' power
or ban all packages from that LAN port by the firewall

I'm unsure what happens if a port is not covered by vlan config at all, it could be that it simply remains in some default state.
Right now you can't actually poweroff a switch port but you could create a dummy vlan which just contains the port you want to isolate without the cpu port, this way the port should be terminated on the switch hardware and never reach the system, something like that:

config switch_vlan
  option device eth0
  option vlan 2
  option vid 999
  option ports 2 

The discussion might have continued from here.