The officially official Devuan Forum!

You are not logged in.

#1 2024-11-27 17:04:17

SpongeBOB
Member
From: Brussels
Registered: 2022-02-07
Posts: 127  

Disable a NIC at boot.

Hi,

I would like to disable a NIC a boot.

I've created an init script

#!/bin/sh
### BEGIN INIT INFO
# Provides:          disable_WiFi
# Required-Start:    $network $local_fs
# Required-Stop:     $network $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Disable WiFi and BlueTooth
### END INIT INFO

case "$1" in
  start)
    echo "Disabling WiFi & BlueTooth"
    ifconfig wlan0 down
    ;;
  stop)
    echo "WiBT will not be reactived"
    ;;
  *)
    echo "Usage: $0 {start|stop}"
    exit 1
esac

exit 0

But after reboot and login ifconfig still show the interface :'(

Any ideas ?

Thanks.


Linux noob, plz be kind big_smile

Offline

#2 2024-11-27 18:45:13

greenjeans
Member
Registered: 2017-04-07
Posts: 590  
Website

Re: Disable a NIC at boot.

On my laptop, there is a switch to turn wi-fi on and off (f12), once turned off it persists through re-boots, and ifconfig confirms that it indeed disabled.

If you right click on the Network Manager icon in the tray, there is an option to enable wi-fi if not running, and disable if running.

Left-clicking that icon confirms also that wi-fi is disabled.

This all persists through re-boots, easy-peasy. Hope this helps!


https://sourceforge.net/projects/vuu-do/ New 1.09 isos uploaded 11/27/2024
Vuu-do GNU/Linux, minimal Devuan-based openbox systems to build on, maximal versions if you prefer your linux fully-loaded.
New Devuan-mate-mini isos too!
Please donate to support Devuan and init freedom! https://devuan.org/os/donate

Offline

#3 2024-11-27 21:35:48

fanderal
Member
Registered: 2017-01-14
Posts: 86  

Re: Disable a NIC at boot.

Don't know if you've made any edits but interfaces marked "auto" or "allow-" in /etc/networking/interfaces are brought up at boot. And /etc/init.d/networking and /etc/default/networking have the line CONFIGURE_INTERFACES=yes as default.

If no laptop switch (fine suggestion greenjeans!), try setting your init script to load last. Another option is /etc/rc.local. Any cmds there are executed after all the normal system services are started and before login.

Offline

#4 2024-11-28 11:36:38

SpongeBOB
Member
From: Brussels
Registered: 2022-02-07
Posts: 127  

Re: Disable a NIC at boot.

@greenjeans
Thanks, but I don't have an hardware switch to shutdown disable the WiFi.
Another way it's to disable it in the BIOS/UEFI smile (I'll try on my in a couple of hours)

@fanderal
Thanks, I believe you meant: /etc/network/interfaces smile

in that file I got (I didn't modify it)

auto lo
iface lo inet loopback

indeed I see in /etc/init.d/networking

CONFIGURE_INTERFACES=yes
EXCLUDE_INTERFACES=

If I set CONFIGURE_INTERFACES to no I assum it will affect all the interface
Maybe I can use just EXCLUDE_INTERFACES ? EXCLUDE_INTERFACES=wlan0 ?


Linux noob, plz be kind big_smile

Offline

#5 2024-11-28 11:42:53

SpongeBOB
Member
From: Brussels
Registered: 2022-02-07
Posts: 127  

Re: Disable a NIC at boot.

update

I've just tried in /etc/init.d/networking

EXCLUDE_INTERFACES=wlan0

but it's not working... the NIC is still up...

same with /etc/rc.local

ifconfig wlan0 down

:'(

Last edited by SpongeBOB (2024-11-28 11:49:28)


Linux noob, plz be kind big_smile

Offline

#6 2024-11-28 16:08:25

stargate-sg1-cheyenne-mtn
Member
Registered: 2023-11-27
Posts: 208  

Re: Disable a NIC at boot.

you might take a closer look at /etc/default/networking(on our daedalus the CONFIGURE_INTERFACES=yes is commented out)

# Configuration for networking init script being run during
# the boot sequence

# Set to 'no' to skip interfaces configuration on boot
#CONFIGURE_INTERFACES=yes

# Don't configure these interfaces. Shell wildcards supported/
#EXCLUDE_INTERFACES=

# Set to 'yes' to enable additional verbosity
#VERBOSE=no

# Method to wait for the network to become online,
# for services that depend on a working network:
# - ifup: wait for ifup to have configured an interface.
# - route: wait for a route to a given address to appear.
# - ping/ping6: wait for a host to respond to ping packets.
# - none: don't wait.
#WAIT_ONLINE_METHOD=ifup

# Which interface to wait for.
# If none given, wait for all auto interfaces, or if there are none,
# wait for at least one hotplug interface.
#WAIT_ONLINE_IFACE=

# Which address to wait for for route, ping and ping6 methods.
# If none is given for route, it waits for a default gateway.
#WAIT_ONLINE_ADDRESS=

# Timeout in seconds for waiting for the network to come online.
#WAIT_ONLINE_TIMEOUT=300

Be Excellent to each other and Party On!
https://www.youtube.com/watch?v=rph_1DODXDU
https://en.wikipedia.org/wiki/Bill_%26_Ted%27s_Excellent_Adventure
Do unto others as you would have them do instantaneously back to you!

Offline

#7 2024-11-28 17:55:01

greenjeans
Member
Registered: 2017-04-07
Posts: 590  
Website

Re: Disable a NIC at boot.

Huh, well I learn new things all the time, but have never seen a laptop myself that didn't have a wi-fi key. On the oldest one I have it's literally a small switch on the laptop body.

As I said, on 2 of 3 laptops we have, it's the F12 key, below the little f12 designation there's a little symbol of an antenna, and the key has an embedded LED that lights up white when wi-fi is on, and orange when it is not. And whatever you chose in the last session persists to the next.


https://sourceforge.net/projects/vuu-do/ New 1.09 isos uploaded 11/27/2024
Vuu-do GNU/Linux, minimal Devuan-based openbox systems to build on, maximal versions if you prefer your linux fully-loaded.
New Devuan-mate-mini isos too!
Please donate to support Devuan and init freedom! https://devuan.org/os/donate

Offline

#8 2024-11-28 18:22:10

fanderal
Member
Registered: 2017-01-14
Posts: 86  

Re: Disable a NIC at boot.

I don't use this mobo's wifi so I tried my suggestion for eth1: I put ifdown eth1 and then /etc/init.d/networking stop in /etc/rc.local, rebooting after each edit. Although the boot process stalled for ~15 seconds (trying to bring up the network), there was no connection at the desktop. In each instance at the desktop, issuing the opposite cmd brought up the network.

Is there a reason your /etc/network/interfaces doesn't include wlan0 and/or dhcp?

My interfaces file:
auto eth1
iface eth1 inet dhcp

Last edited by fanderal (2024-11-29 22:14:01)

Offline

#9 2024-12-02 07:42:47

SpongeBOB
Member
From: Brussels
Registered: 2022-02-07
Posts: 127  

Re: Disable a NIC at boot.

stargate-sg1-cheyenne-mtn wrote:

/etc/default/networking ... CONFIGURE_INTERFACES=yes is commented out

Thank you Cheyenne, Should I  un comment it ? in order for ifconfig or ifdownto work at boot ?

-

Thanks fanderal

I've set ifdown wlan0 into /etc/rc.local but i got ~

boot terminal wrote:

ifdown: unknow interface wlan0
startpar: service(s) returned failure: rc.local ... failed!

it's weird because when i use ifconfig wlan0 down it's not generating an error, it's just not applied...

fanderal wrote:

Is there a reason your /etc/network/interfaces doesn't include wlan0 and/or dhcp?

no ideas, I didn't touch for sure. anyway I'll try now with a stock devuan4 install to see what it does.

edit: with a fresh install, it trow the same error.

Last edited by SpongeBOB (2024-12-02 07:55:19)


Linux noob, plz be kind big_smile

Offline

#10 2024-12-02 21:51:52

fanderal
Member
Registered: 2017-01-14
Posts: 86  

Re: Disable a NIC at boot.

SpongeBOB wrote:

I've set ifdown wlan0 into /etc/rc.local but...

My error. What follows 'iface' in the interfaces file declares the interfaces for the system. The interfaces file is what ifup/down uses when invoked. My suggestion didn't work because wlan0 isn't in the interfaces file. Assuming you tried ifconfig wlan0 down in rc.local, it may have failed for the same reason.

New suggestion:
Re-edit any changes you made and return them to system defaults.
Disable (for now) the init script you created.

What follows 'auto' in the interfaces file identifies the interface to be brought up at boot. 'lo' is like a virtual loopback device to access your local network.

Edit /etc/network/interfaces from this:

auto lo
iface lo inet loopback

to this:

auto wlan0
iface wlan0 inet loopback

This interfaces edit tells the system to enable wlan0 at boot. The 'switch' to disable wlan0 is rc.local. After the interfaces edit, test again with ifdown wlan0 or /etc/init.d/networking stop in rc.local.

I don't know if adding dhcp to the iface line will help or hinder a wireless interface. Maybe someone who knows can help?

Offline

#11 2024-12-02 22:31:19

ralph.ronnquist
Administrator
From: Battery Point, Tasmania, AUS
Registered: 2016-11-30
Posts: 1,259  

Re: Disable a NIC at boot.

no! Don't destroy the loopback interface configuration!

Use "man interfaces"

EDIT. Btw the kernel will install an adapter for the wireless card if it has the software to do so. You may use "rfkill" to software-block the adapter, and then no networking will be configured for it. However, you will need that "rfkill" to happen early on, so will probably need to add it into initrd's init scripts. And that is a second cloud of knowledge to gain, perhaps starting with "man initramfs-tools".

Offline

#12 Yesterday 01:26:00

fanderal
Member
Registered: 2017-01-14
Posts: 86  

Re: Disable a NIC at boot.

ralph.ronnquist wrote:

no! Don't destroy the loopback interface configuration!

Glad you posted. I assume you mean removing 'lo' from the auto line destroys the loopback interface, even with 'loopback' in the iface line.

@SpongeBOB: forget my previous post.

Offline

Board footer