I have a small router I am developing on Ubuntu 18.04 desktop and when I boot it without ethernet attached Netplan doesn't seem to assign the fixed IP (on the LAN side). WAN side is connected with DHCP. The LAN eth0 interface is what isc-dhcp-server runs on.
Problem : isc-dhcp-server crashes when it starts because no IP address exists on the eth0 interface.
If I do thinks manually with a device connected on eth0 then all works well. So the static IP is working when something is attached to eth0.
How do I get 192.168.10.1 assigned to eth0 (enp2s0 on this system) even if it's not plugged in?
I have a single .YAML file as follows:
# Let NetworkManager manage all devices on this system network: ethernets: enp2s0: dhcp4: no addresses: - 192.168.10.1/24 nameservers: addresses: - 188.8.131.52 - 184.108.40.206 search:  enp3s0: dhcp4: yes version: 2 renderer: NetworkManager
Alternately - is there an easy way to just launch (or restart) isc-dhcp-server based on a trigger of the interface getting connected?
This was a very similar question below but it wasn't closed or validated from the OP ... and I haven't successfully found a way to accomplish this. Any help is appreciated.
Update 8/3/19: As noted above w.r.t. restarting the server, I found that the cable state can be found reliably at /sys/class/net/enp2s0/carrier -- the value in that file being 0 when disconnected and 1 when being connected.
So it seems then quite logical to have a script that would test this value - if the value is zero do nothing , if the value changes from 0 to 1 then execute a command , and finally if the value stays as 1 or changes from 1 to 0 do nothing. How would I write a bash script to accomplish this?
Update 8/14/19: Found a resolution following the answer below - but make sure you have ifupdown installed - my system did not. I did not pursue the script idea as the solution to get the static IP seems reliable.