Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Static IP on wired LAN

+1
−0

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).

History
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

2 answers

+3
−0

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).

History
Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

`ip addr show` doesn't need `sudo` (1 comment)
+0
−1

I did this with NetworkManager.

  • nmtui to open the TUI interface and then select "Edit..." and the ethernet connection
    • You can also use the equivalent GUI or CLI commands, but I find them harder to use
  • Next to IPv4 Configuration, click Show to see connection details.
  • Go to Addresses, <Add...> and put in the IP that you want.
    • I've seen people say you need to put in the Gateway as well but I didn't and it works anyway
    • Everything else can be left as is

You may need to disconnect and reconnect.

But ultimately this set up will cause your computer to ask the router for a specific IP (the one you put in). It's then up to the router to decide whether to allow it. I've seen two common reasons why it would decide not to:

  • The old IP has not expired yet, so you either have to wait (usually a few minutes or hours) or you have to flush it through the router's interface (for OpenWrt, see https://linux.codidact.com/posts/289617). Restarting the router might work as well.
  • The router's range of allowed DHCP addresses doesn't cover your desired address. I'm not really sure if this is always necessary, in the past I've seen some routers grant the IP even though it's outside the DHCP. But if it doesn't work, it's worth trying to expand the DHCP range to include you desired IP.

In theory, there could also be an issue where some other device has already taken the IP you want. There are ways to solve that (which I'll leave to a separate question) but in practice this seems to be very rare.

History
Why does this post require moderator attention?
You might want to add some details to your flag.

0 comment threads

Sign up to answer this question »