Prompt Title: create a script that auto run every detect new network

Created 1 year ago
Votes 0
Views 195 times
0

Prompt Detail:

To create a script that auto runs every time a new network is detected in Linux, you can use a combination of udev rules and a shell script.

  1. Create a new udev rule:
    javascript
    sudo nano /etc/udev/rules.d/99-new-network.rules
  2. Add the following line to the rule:
    makefile
    ACTION=="add", SUBSYSTEM=="net", RUN+="/path/to/your/script.sh"
    This will trigger the script /path/to/your/script.sh every time a new network device is added to the system.
  3. Save and close the file.
  4. Create a new shell script:
    bash
    sudo nano /path/to/your/script.sh
  5. Add your script commands to the file. For example, you might want to configure the new network device, or start a network service.
  6. Save and close the file.
  7. Make the script executable:
    bash
    sudo chmod +x /path/to/your/script.sh
  8. Reload the udev rules:
    css
    sudo udevadm control --reload-rules

Now, every time a new network device is detected on the system, the udev rule will trigger the execution of your shell script, allowing you to perform any necessary configuration or setup.

avatar
Hanh
Shared 1 prompt
Created 1 year ago

Leave a Comment

Related Tag Prompts

0
0
0
0
Segmentação de rede corporativa.
11 months ago 2023-05-03 01:14:20 Rodrigo
0
0
KNB
11 months ago 2023-05-03 10:54:33 gail
0
0
Collega uit eten vragen
9 months ago 2023-07-17 09:46:07 Rick