0

I have some Pi Wifi experience on Raspbian Jessie (just followed tutorials, though), but not an expert on networking. Anyway, I recently moved to Stretch. Thanks to new tutorials and Internet discussions, I can run Wifi repeater on Stretch again. But I am having one problem.

On Jessie, we could run a script when a network interface is up/down by adding pre-up / post-up / pre-down / post-down lines to each iface section in /etc/network/interfaces. But on Stretch, it seems we shouldn't modify it unless networking service is enabled and dhcpcd service is disabled.

So, What is a proper way to run a script by interface up/down now?

  • Clarification: Why am I using it as a repeater? A) To use it in multiple locations that need to follow little complex routing rules. B) Backup when I'm testing my router. Why do I want to use interface up/down? - It doesn't need to be actual networking service ifup/ifdown. I just need to run certain commands dynamically when certain interface goes up/down. Mostly for VPN connection but not limited. – Chihaya Dec 24 '18 at 14:40
1

There is no "proper way" BECAUSE Raspbian DOES NOT use Debian networking, although it is still possible to use this if desired.

Raspbian uses dhcpcd as its default network manager. See How to set up networking/WiFi for detail.

Why do you WANT to "interface up/down" - dhcpcd automatically manages network interfaces, and does an excellent job?

You can write hooks which are invoked by network events - see man 8 dhcpcd-run-hooks (There are a number of included hooks e.g. 10-wpa_supplicant see /lib/dhcpcd/dhcpcd-hooks

PS Using a Pi as a WiFi repeater seems a poor idea, due to the restricted network throughput - a dedicated repeater would be cheaper and perform better.

Incidentally you can still use /etc/network/interfaces if you configure dhcpcd to NOT manage an interface (discussed in linked answer).


Stretch networking is the same as Jessie.

The earlier Foundation implementation of dhcpcd (in Jessie and Wheezy) omitted the 10-wpa_supplicant hook, requiring a kludge in /etc/network/interfaces to support WiFi. (In fact I installed 10-wpa_supplicant in my Jessie, rendering /etc/network/interfaces unnecessary.)

Debian Stretch introduced predictable network interface names which are incompatible with the kludged /etc/network/interfaces so the 10-wpa_supplicant hook was included. (For some incomprehensible reason the Foundation later decided to disable predictable network interface names.)

If you want Stretch networking to work the same as Jessie all you have to do is delete 10-wpa_supplicant and restore the kludged /etc/network/interfaces. This will, of cause, suffer from the limitations of Jessie networking.

  • Thank you for the comment. That what I am figuring out but I wasn't sure since most of the documents I came across the Internet was updated version from Jessie, especially the like you mentioned is often cited but very confusing. It tried to explain both Jessie and Stretch, which uses completely different networking management policy at the same. I think the key difference is, Stretch isn't using networking service anymore by default, so anything under /etc/network would not be used. I got it then wondered what is the best place I can add hook commands. – Chihaya Dec 24 '18 at 15:15
  • @Chihaya I am sorry you find the tutorial confusing, BUT the Foundation will keep changing networking. Many people are still using Jessie (some even using Wheezy). For normal implementations you only need to read the first few paragraphs - the rest is for advanced use (and I try to explain WHY - rather than a trust me answer). Jessie and Stretch DO NOT different networking management policy - they are the same! See the addition to my answer. – Milliways Dec 24 '18 at 22:44
  • I appreciate your work first. It gave me the clue what was going on. But I still think they are NOT the same at all. it's different because the services managing network interfaces are not the same. One running networking AND dhcpcd, Stretch is only using dhcpcd by default. it's astronomically different. Isn't it why people keep asking Stretch network isn't working? It doesn't work because their familiar Debian networking service is not running since anything under /etc/network wouldn't do anything. It would have been much clear if the document stated it very beginning. – Chihaya Dec 25 '18 at 3:32
  • I really appreciate your work and contribution to the community. But I'd strongly suggest making a separate document for Stretch and older Raspibian versions because anything involved under /etc/network/ would not work on Stretch by default settings. Pretending both using the same policy is simply false. In fact, you even mentioned /etc/network/interfaces can be deleted. I'd say the entire directory of /etc/networking can be deleted.. .or actually should have been by the foundation. For some incomprehensible reason, the kept it. I wouldn't say it is the same policy at all. – Chihaya Dec 25 '18 at 4:04
  • @Chihaya Debian networking is active in Stretch. It is just active (exited). I think you will find that the same applies in Jessie. I have no interest in writing tutorials for obsolete unsupported operating systems, Unfortunately many people still attempt to run obsolete tutorials. There is nothing to stop anyone wanting to do so from running Debian networking (or indeed any of the other 3 or 4 supported network managers) under Stretch. – Milliways Dec 25 '18 at 4:14

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.