Force physical link down

I need to temporarily down the physical link of a wired ethernet interface, and as far as I can tell ifconfig isn't capable of this. Well, with some interfaces ifconfig <dev> down followed by ifconfig <dev> up does seem to briefly down the link. The briefness is fine for my purposes (it only needs to be down for an instant) but leveraging this seems shady. Is there some other way?
 
Last edited by a moderator:
Are you looking for something like # service netif stop <interface> followed by # service netif start <interface> or maybe # service netif restart <interface>?
 
There's a difference between administratively down (i.e. ifconfig em0 down) and physically down (i.e. no link, cable not connected). You can only set an interface administratively down.
 
Yeah, that's what I had come to understand at this point.

I happened to watch a video on YT where GNN briefly described the networking stack, specifically that the netif layer has no knowledge of the physical device. In that light, the fact that ifconfig can only "administratively down" an interface makes sense. But it still perplexes me that no means is provided to [physically] down an interface, and that unconfigured interfaces are brought [physically] up by default.
 
Some NICs do actually perform a link-down when the settings are changed because the firmware on the NIC is so limited. I belive some revisions of fxp(4) cards are such. You can't depend on the behaviour though because it can't be controlled in any way other than hope that the firmware of the NIC does the link-down when settings change.
 
As I said in the OP, I did see brief link-down but didn't consider it reliable (NIC is Intel I350, igb(4)). Still, I did a little more testing and found that using ifconfig down followed by ifconfig up (which made sense when I thought the former caused physical down) eventually causes the NIC to go loopy, thinking it's physically up when it's unplugged...
 
Back
Top