I never use the stock networking config system on linux; over the years I've developed my own scripts to do everything I want. I don't even know how to do anything properly, in fact, because it has been so long since I did so (which is why I rarely answer networking questions here). This isn't something I'm recommending to others, but just to point out that you do not have to use any existing system services in order to arrange a network connection.
First the obvious:
sudo systemctl disable dhcpcd
There may be other stuff you need to disable, but note the base networking
service is not one of them. What I also do is remove all references to any interface except lo
(local loopback) from /etc/network/interfaces
. I notice now Debian/Raspbian simply source stuff from a interfaces.d
but looking at an image it appears empty. Anyway, if it isn't, empty it.
You can also remove everything from the if-up/down
directories if you want -- it probably isn't necessary, but it won't negatively impact anything if you want to make your own arrangements instead.
The only part I'm uncertain about is the static address since I only use those on hotspot networks and not with a normative ISP provided router. However, if you have that configured to use a static IP with the Pi's MAC I don't think any kind of lease negotiation is required, so it is just a matter of:
sudo ip link set eth0 up
sudo ip addr add 10.0.0.2/24 dev eth0
sudo ip route add default via 10.0.0.1
Obviously using whatever static address in place of 10.0.0.2
and your router's address in place of 10.0.0.1
. Note it is important to use an explicit CIDR (/24
) because the default is /32
, which indicates a network of one.
You also probably need to add your ISP's nameservers to /etc/resolv.conf
(and beware DHCP tools like to overwrite that), or else use Google's (8.8.8.8
and 8.8.4.4
).
If it turns out you need to do DCHP negotiation with the router even though you will be assigned a static address, the situation is even simpler:
sudo ip link set eth0 up
sudo dhclient -v eth0
The latter will remain in the foreground until it gets a lease then fork to the background. There can only be one instance running at a time. To stop it, sudo dhclient -r
.
You do not need to configure any routing or nameservers when using dhclient
, meaning it might be preferable anyway if your router properly assigns the static address.