Disclaimer: I the noobest noob when it comes to networking. I hardly have an idea what means what in a network setup. For me, there is no "trivial" information in this regard.
I have an Ubuntu 20.04 machine and a Raspberry Pi, on my home wired LAN network. In the current setup, the only thing in between these devices is a network switch:
[ Ubuntu ] ——— [ network switch ] ——— [ RPi ]
I don't have a WAN internet connection on this network (and in the current setup I don't need one), as it is provided by another, a wifi interface. I use the wired LAN only to connect these devices.
Since there is no router on this LAN network to provide a DHCP config, in my network settings GUI, on the IPv4
tab, I set "Link-Local Only".
My Ubuntu can see the RPi, and the RPi can see my Ubuntu, but only on the condition that first I look up each device's own IP address with hostname -I
, and then I use that IP address when connecting (mounting).
I have noticed that these IP addresses can change after reboots. They don't always do, and sometimes they return to previously used values, yet, in effect these changes roll an obstacle in the way of easy connecting. I'd like to set a static IP for both devices; I guess on this site I can ask about how to achieve it for my Ubuntu 20.04 machine.
I think that there may be a number of ways to achieve my goal, either through some config file, or the Settings GUI, or even by running some terminal commands (that I could put in a script).
Please, when suggesting a solution, take into account my lack of networking knowledge: I'm not after the industry best-practice — I prefer a method that's easier to carry out for a beginner.
Addendum:
- I seem to be aware that on Ubuntu 20.04
netplan
is often used in configuring networks; I have also seen renderer: NetworkManager
in such configs.
- Does this mean that I may have an option to avoid using netplan, and use something easier? (Netplan appears difficult as it seems to assume as a prerequisite a good level of networking knowledge.)
- Would there be a way to override a netplan config with a terminal command "on the fly", comparable to how
xrandr
commands can "amend" X-server configs?
- In the Network Settings GUI, on the
IPv4
tab (where I choose "Link-Local Only"), there seems to be a Routes section, with Address, Netmask, Gateway, and Metric "fields", but these remain greyed out, even if I toggle the corresponding Automatic toggle to "off".
- At the same time, the checkbox labelled Use this connection only for resources on its network also remains grayed out.
Update: solution summary
- For this to work, one needs to set corresponding static IPs on all involved devices.
- corresponding means:
foo.bar.baz.x
and foo.bar.baz.y
- For the wired interface, one should choose an IP range different from that of the wifi interface's; e.g.:
- wifi:
foo.bar.x.x
- wired:
baz.quux.x.x
- On Ubuntu, on the Network Settings GUI's
IPv4
tab, one should choose "Manual", and proceed as per @raj's answer.
- On a Raspberry Pi with Raspberry Pi OS based on Debian Buster, the
/etc/dhcpcd.conf
file needs to be modified: it already contains a helpful-enough "static IP example" snippet. More info on RPi.SE.