How to turn off/on networking

Forum Forums General Software How to turn off/on networking

  • This topic has 7 replies, 4 voices, and was last updated Dec 12-7:32 pm by andyprough.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #95334
    Member
    berndE

      I want to turn off or on any networking immediately.
      I know I can use “ifconfig device off” for all devices in a loop. But I wonder if there is a single command for this.
      I tried “/etc/init.d/networking stop” and “ifdown -a”, but neither had any noticeable effect.

      #95341
      Member
      techore
        Helpful
        Up
        0
        ::

        What is your goal? Details on what you are seeking to accomplish will help us provide guidance.

        Assuming you want a panic button to disconnect from all networks, I would create a bash script using ifdown for all the interfaces I want to disconnect.

        #!/usr/bin/env bash
        ifdown eth0
        ifdown wlan0

        It is very curious ‘ifdown -a’ didn’t work. Can you explain further?

        • This reply was modified 5 months ago by techore.
        • This reply was modified 5 months ago by techore.
        • This reply was modified 5 months ago by techore.
        #95399
        Member
        berndE
          Helpful
          Up
          0
          ::

          I want to turn off the network when I edit password files, for example. Just as a precaution.
          On another system running MX I can simply say nmcli n off. But, no problem, I use ifconfig eth0 down here.

          ifdown -a worked exactly once for me. After a ifup -a it didn’t work again. No idea why.

          Bernd

          #95406
          Member
          techore
            Helpful
            Up
            0
            ::

            Thank you for providing your goal and what you have tried.

            Please post the results of:

            inxi -zv7

            #95435
            Member
            berndE
              Helpful
              Up
              0
              ::

              Here it is:

              System:
              Kernel: 5.10.142-antix.2-amd64-smp arch: x86_64 bits: 64 compiler: gcc
              v: 10.2.1 Desktop: IceWM v: 3.2.3 dm: slimski v: 1.5.0
              Distro: antiX-22_x64-full Grup Yorum 18 October 2022
              base: Debian GNU/Linux 11 (bullseye)
              Machine:
              Type: Desktop System: ASUS product: N/A v: N/A serial: <superuser required>
              Mobo: ASUSTeK model: PRIME B450M-A II v: Rev X.0x
              serial: <superuser required> UEFI: American Megatrends v: 3002
              date: 03/10/2021
              Battery:
              Message: No system battery data found. Is one present?
              Memory:
              RAM: total: 31.33 GiB used: 1.3 GiB (4.2%)
              RAM Report:
              permissions: Unable to run dmidecode. Root privileges required.
              CPU:
              Info: 8-core model: AMD Ryzen 7 3700X bits: 64 type: MT MCP smt: enabled
              arch: Zen 2 rev: 0 cache: L1: 512 KiB L2: 4 MiB L3: 32 MiB
              Speed (MHz): avg: 3659 high: 4239
              min/max: 2200/5091:5224:4957:4426:4823:4560:4690 boost: enabled cores:
              1: 4239 2: 3542 3: 3597 4: 3597 5: 3588 6: 3590 7: 4029 8: 3586 9: 3588
              10: 3619 11: 3547 12: 3586 13: 3592 14: 3592 15: 3673 16: 3586
              bogomips: 114978
              Flags: 3dnowprefetch abm adx aes aperfmperf apic arat avic avx avx2 bmi1
              bmi2 bpext cat_l3 cdp_l3 clflush clflushopt clwb clzero cmov cmp_legacy
              constant_tsc cpb cpuid cqm cqm_llc cqm_mbm_local cqm_mbm_total
              cqm_occup_llc cr8_legacy cx16 cx8 de decodeassists extapic extd_apicid
              f16c flushbyasid fma fpu fsgsbase fxsr fxsr_opt ht hw_pstate ibpb ibs
              irperf lahf_lm lbrv lm mba mca mce misalignsse mmx mmxext monitor movbe
              msr mtrr mwaitx nonstop_tsc nopl npt nrip_save nx osvw overflow_recov pae
              pat pausefilter pclmulqdq pdpe1gb perfctr_core perfctr_llc perfctr_nb
              pfthreshold pge pni popcnt pse pse36 rdpid rdpru rdrand rdseed rdt_a
              rdtscp rep_good sep sev sev_es sha_ni skinit smap smca sme smep ssbd sse
              sse2 sse4_1 sse4_2 sse4a ssse3 stibp succor svm svm_lock syscall tce
              topoext tsc tsc_scale umip v_vmsave_vmload vgif vmcb_clean vme vmmcall
              wbnoinvd wdt xgetbv1 xsave xsavec xsaveerptr xsaveopt xsaves
              Graphics:
              Device-1: NVIDIA GP108 [GeForce GT 1030] vendor: ASUSTeK driver: nvidia
              v: 470.141.03 arch: Pascal pcie: speed: 8 GT/s lanes: 4 bus-ID: 09:00.0
              chip-ID: 10de:1d01 class-ID: 0300
              Display: server: X.Org v: 1.20.11 driver: X: loaded: nvidia
              unloaded: fbdev,modesetting,nouveau,vesa alternate: nv gpu: nvidia
              display-ID: :0.0 screens: 1
              Screen-1: 0 s-res: 1920×1080 s-dpi: 92 s-size: 530x301mm (20.87×11.85″)
              s-diag: 610mm (24″)
              Monitor-1: DVI-D-0 res: 1920×1080 hz: 60 dpi: 92
              size: 528x297mm (20.79×11.69″) diag: 606mm (23.85″) modes: N/A
              OpenGL: renderer: NVIDIA GeForce GT 1030/PCIe/SSE2
              v: 4.6.0 NVIDIA 470.141.03 direct render: Yes
              Audio:
              Device-1: Creative Labs EMU20k2 [Sound Blaster X-Fi Titanium Series]
              driver: snd_ctxfi v: kernel pcie: speed: 2.5 GT/s lanes: 1 bus-ID: 07:00.0
              chip-ID: 1102:000b class-ID: 0403
              Device-2: NVIDIA GP108 High Definition Audio vendor: ASUSTeK
              driver: snd_hda_intel v: kernel pcie: speed: 8 GT/s lanes: 4
              bus-ID: 09:00.1 chip-ID: 10de:0fb8 class-ID: 0403
              Device-3: AMD Starship/Matisse HD Audio vendor: ASUSTeK
              driver: snd_hda_intel v: kernel pcie: speed: 16 GT/s lanes: 16
              bus-ID: 0b:00.4 chip-ID: 1022:1487 class-ID: 0403
              Sound Server-1: ALSA v: k5.10.142-antix.2-amd64-smp running: yes
              Network:
              Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet
              vendor: ASUSTeK PRIME B450M-A driver: r8169 v: kernel pcie: speed: 2.5 GT/s
              lanes: 1 port: f000 bus-ID: 08:00.0 chip-ID: 10ec:8168 class-ID: 0200
              IF: eth0 state: up speed: 1000 Mbps duplex: full mac: <filter>
              IP v4: <filter> type: dynamic scope: global broadcast: <filter>
              IP v4: <filter> virtual: secondary scope: global broadcast: <filter>
              IP v6: <filter> type: dynamic mngtmpaddr scope: global
              IP v6: <filter> scope: link
              WAN IP: <filter>
              Bluetooth:
              Message: No bluetooth data found.
              Logical:
              Message: No logical block device data found.
              RAID:
              Message: No RAID data found.
              Drives:
              Local Storage: total: 1.82 TiB used: 72.48 GiB (3.9%)
              ID-1: /dev/nvme0n1 vendor: A-Data model: SWORDFISH size: 931.51 GiB
              speed: 31.6 Gb/s lanes: 4 type: SSD serial: <filter> rev: V9002s73
              temp: 34.9 C scheme: MBR
              ID-2: /dev/sda vendor: Samsung model: SSD 840 PRO Series size: 238.47 GiB
              speed: 6.0 Gb/s type: SSD serial: <filter> rev: 5B0Q scheme: GPT
              ID-3: /dev/sdb vendor: Samsung model: SSD 840 EVO 500GB size: 465.76 GiB
              speed: 6.0 Gb/s type: SSD serial: <filter> rev: BB0Q scheme: MBR
              ID-4: /dev/sdc vendor: Samsung model: SSD 840 EVO 250GB size: 232.89 GiB
              speed: 6.0 Gb/s type: SSD serial: <filter> rev: BB6Q scheme: MBR
              Optical-1: /dev/sr0 vendor: HL-DT-ST model: DVDRAM GH24NSD5 rev: LV00
              dev-links: cdrom,cdrw,dvd,dvdrw
              Features: speed: 12 multisession: yes audio: yes dvd: yes
              rw: cd-r,cd-rw,dvd-r,dvd-ram state: running
              Partition:
              ID-1: / size: 225.54 GiB used: 7.89 GiB (3.5%) fs: ext4 dev: /dev/sda2
              label: rootantiX22 uuid: 6e19919c-0b3b-45ff-aa52-15c033e7f5c8
              ID-2: /boot/efi size: 252 MiB used: 274 KiB (0.1%) fs: vfat
              dev: /dev/sda1 label: EFI System uuid: D250-D596
              ID-3: /rootMX size: 443.89 GiB used: 64.59 GiB (14.6%) fs: ext4
              dev: /dev/nvme0n1p3 label: rootMX21
              uuid: dbcaf6fc-f065-47c1-bc3b-5342f6562865
              Swap:
              ID-1: swap-1 type: partition size: 8 GiB used: 0 KiB (0.0%) priority: -2
              dev: /dev/sda3 label: swapantiX uuid: 3a388388-b809-4171-a6d7-801bc5e0ce8d
              ID-2: swap-2 type: partition size: 40 GiB used: 0 KiB (0.0%) priority: -3
              dev: /dev/nvme0n1p2 label: swapMX
              uuid: 113b33bd-0213-4ded-a282-04ab2765ba5f
              Unmounted:
              ID-1: /dev/nvme0n1p1 size: 439.45 GiB fs: ntfs label: N/A
              uuid: C49AC8D99AC8C8DE
              ID-2: /dev/sdc1 size: 232.88 GiB fs: ext4 label: Musik
              uuid: cfeac7f0-c11c-4254-97c8-9b7300f3190e
              USB:
              Hub-1: 1-0:1 info: Hi-speed hub with single TT ports: 10 rev: 2.0
              speed: 480 Mb/s chip-ID: 1d6b:0002 class-ID: 0900
              Hub-2: 2-0:1 info: Super-speed hub ports: 4 rev: 3.1 speed: 10 Gb/s
              chip-ID: 1d6b:0003 class-ID: 0900
              Hub-3: 3-0:1 info: Hi-speed hub with single TT ports: 4 rev: 2.0
              speed: 480 Mb/s chip-ID: 1d6b:0002 class-ID: 0900
              Device-1: 3-1:2 info: Logitech M-BT96a Pilot Optical Mouse type: Mouse
              driver: hid-generic,usbhid interfaces: 1 rev: 2.0 speed: 1.5 Mb/s
              power: 98mA chip-ID: 046d:c03d class-ID: 0301
              Device-2: 3-2:3 info: Fujitsu Siemens s Keyboard FSC KBPC PX
              type: Keyboard,HID driver: hid-generic,usbhid interfaces: 2 rev: 1.1
              speed: 1.5 Mb/s power: 100mA chip-ID: 0bf8:100c class-ID: 0300
              Device-3: 3-3:4 info: Canon CanoScan LiDE 300 type: <vendor specific>
              driver: N/A interfaces: 3 rev: 2.0 speed: 480 Mb/s power: 500mA
              chip-ID: 04a9:1913 class-ID: 0000 serial: <filter>
              Hub-4: 4-0:1 info: Super-speed hub ports: 4 rev: 3.1 speed: 10 Gb/s
              chip-ID: 1d6b:0003 class-ID: 0900
              Sensors:
              System Temperatures: cpu: 28.1 C mobo: N/A gpu: nvidia temp: 28 C
              Fan Speeds (RPM): N/A gpu: nvidia fan: 0%
              Info:
              Processes: 289 Uptime: 3m wakeups: 1 Init: SysVinit v: 2.96 runlevel: 5
              default: 5 Compilers: gcc: 10.2.1 alt: 10 Packages: apt: 1843 Shell: Bash
              v: 5.1.4 running-in: roxterm inxi: 3.3.19

              Thanks,
              Bernd

              #95454
              Member
              techore
                Helpful
                Up
                0
                ::

                Excellent and thank you.

                You are using antiX Full. I would use cmst to disable and re-enable networking.

                To launch cmst, either click the network icon in the tray on the status bar or click the “antiX” menu on the statusbar then Applications –> Preferences –> Connman UI Setup. Alternatively, execute cmst from shell.

                On the first tab, Status, toggle the “All Devices Off” to disconnect and reconnect to network.

                This should work with the default network settings or clean install. Be mindful that if use “Change wifi Program” to use ceni, then cmst may not be able to manage the wireless device. I suspect that is the case, but unverified.

                Attachments:
                #95463
                Moderator
                Brian Masinick
                  Helpful
                  Up
                  1
                  ::

                  I’ve been able to switch back and forth between cmst and ceni successfully with the “Change WiFi program” with no issues.

                  In the case of one old system, oscillating between the two programs and waiting seems for some reason on the one system to help.

                  My other systems work fine with either program. The one with issues is probably in need of a good cleaning and possibly one or two replacement parts.

                  --
                  Brian Masinick

                  #95466
                  Member
                  andyprough
                    Helpful
                    Up
                    0
                    ::

                    Here’s what I use –
                    Down (for wifi or ethernet):
                    sudo ip link set dev wlan1 down
                    sudo ip link set dev eth0 down

                    Up:
                    sudo ip link set dev wlan1 up
                    sudo ip link set dev eth0 up

                  Viewing 8 posts - 1 through 8 (of 8 total)
                  • You must be logged in to reply to this topic.