Skip to content

Commit

Permalink
v6.23
Browse files Browse the repository at this point in the history
+ DietPi-Config | Allow network drop-in configs via /etc/network/interfaces.d, which e.g. allows to add VLANs, multiple network adapters and such without DietPi-Config destroying it. Future idea is to use this ourself to allow easier adding/removal/adjusting of single interface settings instead of scraping and rewriting the whole interfaces file.
  • Loading branch information
MichaIng committed May 4, 2019
1 parent 3a65f6d commit aa4a36f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions dietpi/dietpi-config
Original file line number Diff line number Diff line change
Expand Up @@ -2282,8 +2282,12 @@ More info here: https://www.raspberrypi.org/forums/viewtopic.php?p=105008#p10500
fi

cat << _EOF_ > /etc/network/interfaces
# /etc/network/interfaces
# Please use DietPi-Config to modify network settings.
# Location: /etc/network/interfaces
# Please modify network settings via: dietpi-config
# Or create your own drop-ins in: /etc/network/interfaces.d/
# Drop-in configs
source interfaces.d/*
# Local
auto lo
Expand Down

9 comments on commit aa4a36f

@1985kasper
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very nice! but not really following how it works. You just create a file with lets say
iface eth0.300 inet dhcp
in /etc/network/interfaces.d?
can you explain how to setup a "drop-in"?

@MichaIng
Copy link
Owner Author

@MichaIng MichaIng commented on aa4a36f May 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@1985kasper
Jep exactly this should be possible. The drop-in config syntax follows exactly the one for the main config. Image the drop-in content to be copied just as-is into the main config when being parsed.

I am currently only not 100% sure about conflicts with iface eth0 inet dhcp that is generated by DietPi-Config. In case you need to comment that part.

And also I am not sure if the order is relevant, e.g. iface eth0 inet dhcp needs to be defined in front of the VLANs or such? With a future patch I want to move DietPi-Config settings into the drop-in dir as well. And when a certain interface (Ethernet or WiFi) is disabled, this config will be removed completely. So when you need a customised network setup, you can simply disable all interfaces in dietpi-config and add your own instead. Using DietPi-Config should then feel more like an "offer" than like what is required or expected.

@1985kasper
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

figured it out :-) never used this before but it's pretty nice
add to /etc/network/interfaces:
source interfaces.d/interfacename.cfg

create interfacename.cfg in /etc/network/interfaces.d. Example:
iface eth0.300 inet dhcp
ifup eth0.300

Very nice!

@MichaIng
Copy link
Owner Author

@MichaIng MichaIng commented on aa4a36f May 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@1985kasper
source interfaces.d/* loads all files automatically, using the asterisk as wildcard. If this did not work already, then perhaps indeed the order is relevant for VLANs, e.g. source being after the main interface declaration.

@1985kasper
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MichaIng Only thing i notice now is the interfaces in /etc/network/interfaces.d are not persistent across boots. Is this on purpose?

@MichaIng
Copy link
Owner Author

@MichaIng MichaIng commented on aa4a36f May 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@1985kasper
You mean the directory is cleared or the interfaces are simply not loaded on boot, but can be e.g. via ifup eth0.300?

Basically it should not make any difference it you add directives via drop-in files or directly to /etc/network/interfaces. Both should behave exactly the same.

@1985kasper
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have to run ifup after a reboot

@MichaIng
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@1985kasper
Does your drop-in contain allow-hotplug eth0.300 or auto eth0.300? Not sure if this required for VLANs?

Otherwise could you try moving source interfaces.d/* to the end of the file? Possibly eth0 needs to be placed in front of eth0.300.

@1985kasper
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point regarding the auto/hotplug I will try both tomorow. :-) thanks!

Please sign in to comment.