Comments on Static IP on wired LAN
Parent
Static IP on wired LAN
I have an Arch Linux machine connected to a LAN by ethernet. The router runs OpenWRT.
DHCP assigns IPs to this machine like 192.168.1.*
- quite typical. I want the IP to always be 192.168.1.10
.
Ideally, I would like to do this through configuration on the machine only, without configuring anything on the router. The machine should know to request 192.168.1.10
from DHCP, rather than relying on DHCP to choose the correct IP address. It doesn't have to be through DHCP either (I don't know that much about how LAN IPs are assigned).
Post
There are a couple of ways of handling this (on PC's in general. I do use Linux, but not Arch, and this will work).
The first way is to statically assign an IP address. While you SHOULD be able to assign a static IP address in the DHCP range, it is better to assign it outside the range (the range is configured in the DHCP server - in this case your OpenWRT router). To statically assign an IP address, you need to specify the IP address, the Netmask, the Gateway, and the nameservers.
Here is a link on how to do this in Arch: https://ostechnix.com/configure-static-dynamic-ip-address-arch-linux/
I would argue the better way is to dynamically assign a static IP address. This is not strictly speaking what you asked, but is very relevant. The idea here is to map the MAC address of the Arch Linux LAN Interface to an IP, and have the DHCP server assign it dynamically. The nice thing here is you don't need to make any changes to your Arch box, and if you shift to another network, nothing needs to change to get connectivity.
https://openwrt.org/docs/guide-user/base-system/dhcp_configuration outlines how to do this on OpenWRT.
You can find your Arch box's IP address with a command like
ip addr show
The MAC address is the bit after the words link/ether for the appropriate device. You will need this information to tell OpenWRT's DHCP server how to identify this box (or, strictly speaking, this particular network interface).
0 comment threads