Force DHCP to assign the same ip always to the same client?

0

I'm behind a router with at least 1 client and at most 3 clients. My "main" client runs some services like Apache2 so I port forwarded in router configuration the incoming traffic to its IP address 10.0.0.2 assigned by the router's dhcp. Sometimes it happens that the routers assigns 10.0.0.3 to my main client so i have to change all the forwarding. Are there any possibilities to avoid this?

I thought about something like

ifconfig eth1 down
ifconfig eth1 10.0.0.2 up

but this doesn't help. I still have 10.0.0.3.

This doesn't work either.

dhclient -r
ifconfig eth1 down
ifconfig eth1 10.0.0.2 up

I have still 10.0.0.3 after reconnecting.

Maybe there are another solutions? By the way, this must not be a perfect solution because it's just a home network, but the target is to not change all the forwardings all the time.

Bevor

Posted 2012-02-19T19:22:20.530

Reputation: 307

Answers

4

This is called a "DHCP reservation", or sometimes "static DHCP".

How it's configured will depend on your router, but many consumer routers do have this capability.

Shane Madden

Posted 2012-02-19T19:22:20.530

Reputation: 686

Some routers actually keep the assigned IPs stored until the pool is needed for more new devices. This makes DHCP addresses de-facto constant out of the box. – Zdenek – 2018-05-30T18:26:22.440

You were right, my router supports such an option. Works now, thanks. – Bevor – 2012-02-19T19:38:06.147

0

Shane's suggestion should work.

Another method - say if your router is 10.0.0.1 and it starts giving out ip addresses from 10.0.0.2 onwards, you may be able to reconfigure it so the first available ip to give out is i.e. 10.0.0.10 Then you can manually specify the ip on devices 10.0.0.2 - 10.0.0.9 and it will work.

Robin Gill

Posted 2012-02-19T19:22:20.530

Reputation: 151

DHCP has built-in resiliency against IP collision, so it should work properly even without changing the start of the DHCP pool. That said, I'm always safe rather than sorry. – Zdenek – 2018-05-30T18:28:30.107