# [SOLVED] IP Changed

## Holysword

Hi there

I'm used to have my IP Address as 10.0.0.4, but now, I don't know why, dhcpcd configs it to 10.0.0.13.

I didn't changed the router at all, soh I believe that's something with dhcpcd.

There are a way to make it becomes 10.0.0.4 again? I don't wanna reconfig my router neither my tons of softwares that points to 10.0.0.4  :Razz: 

Thx in advice!

----------

## nixnut

if you don't want a dynamic ip, but a static ip then don't use dhcp (look up what that acronym means   :Wink:  )

set config_eth0=( "10.0.0.4/24" ) in /etc/conf.d/net

----------

## Holysword

Thx for your reply.

I did as you said, but it don't recognized this option ( maybe without "set" ?!?! )

Anyway, why dhcp did choosd this IP instead of 10.0.0.4?!! There must be a configuration file where you name the prefered IP, right?

----------

## NeddySeagoon

Holysword,

dhcp has an option to allow you to suggest an IP you would like. It does not ensure you get it, since it may already be in use.

Far better to allocate a static IP, either by using the static setup process or telling your router to allways allocate the same IP to your MAC address.

----------

## Holysword

Good... so how can I setup dhcp to choose this prefered IP?! I really don't wanna make it static... :/

PS: I'm sure that 10.0.0.4 is not in using by any other machine.

----------

## NeddySeagoon

Holysword,

My network is all static, I'm afraid I will have to refer you to the man page for your dhcp client and/or the /etc/conf.net.example file. The option you need should be in one or both places.

----------

## Holysword

Ok, I'll waste some time reading. When I got the solution I post here.

Thx you both!

----------

## Holysword

Well, after a lot of time only reading, I got nothing...

No one knows?!?!

----------

## elgato319

just add to dhcpd.conf:

```

host mypc { 

   hardware ethernet 01:23:45:67:89:ab; 

   fixed-address 10.0.0.4;

}

```

restart dhcpd and try to renew the dhcp lease

----------

## Dagger

 *Quote:*   

> 
> 
> Ok, I'll waste some time reading.
> 
> 

 

lol I don't believe time spent on reading important documentation is ever wasted!  :Smile: 

what are you using to assign IP address (you mentioned router). Is it linux based server or is it hardware router?

----------

## ShinyThings

What I would do is set your router so that it only gives out dhcp addresses above a certain value. For example, the first address given out by dhcp will be 192.168.1.50. Then, in your /etc/conf.d/net, put 

```
config_eth0=("x.x.x.x")
```

the x.x.x.x should be the IP that you want (below the dhcp range).

You may also have to add a routes_eth0 line that will look like routes_eth0("default via {router's ip address}"). I think you will also have to manually put the ips of your nameserver into /etc/resolv.conf.

----------

## tylerwylie

 *ShinyThings wrote:*   

> What I would do is set your router so that it only gives out dhcp addresses above a certain value. For example, the first address given out by dhcp will be 192.168.1.50. Then, in your /etc/conf.d/net, put 
> 
> ```
> config_eth0=("x.x.x.x")
> ```
> ...

 Exactly.  If you are unable to tell your router to specify that your machine with your hostname/mac address does not get 10.0.0.4 then you will have to go static which will need static DNS entries as well.

----------

## Holysword

 *elgato319 wrote:*   

> just add to dhcpd.conf:
> 
> ```
> 
> host mypc { 
> ...

 

I didn't found this file at my machine. O.o

 *Dagger wrote:*   

> what are you using to assign IP address (you mentioned router). Is it linux based server or is it hardware router?

 

Hardware router  :Very Happy: 

 *ShinyThings wrote:*   

> What I would do is set your router so that it only gives out dhcp addresses above a certain value. For example, the first address given out by dhcp will be 192.168.1.50. Then, in your /etc/conf.d/net, put 
> 
> ```
> config_eth0=("x.x.x.x")
> ```
> ...

 

This is a static ip configuration, right? Man, I'm almost configuring this static... dhcp is driven me crazy :S

----------

## Holysword

Its alive!!!

I emerged udhcp, and seted at /etc/conf.d/net:

```
config_eth0=("udhcpc")

udhcpc_eth0="-r 10.0.0.4"
```

And it got the proper IP.

But before close this topic, I would like to know a stuff... I tried the exactly same thing with dhcpcd, but it didn't worked

```
mensirval ~ # /etc/init.d/net.eth0 start

 * Starting eth0

 *   Bringing up eth0

 *     dhcp

 *       Running dhcpcd ...

Info, eth0: dhcpcd 3.1.5 starting

Info, eth0: hardware address = 00:50:8d:e1:a3:04

Info, eth0: DUID = 00:01:00:01:0e:e5:40:29:00:50:8d:e1:a3:04

Info, eth0: broadcasting for a lease of 10.0.0.4

Debug, eth0: sending DHCP_REQUEST with xid 0xeea42ec

Debug, eth0: waiting on select for 20 seconds

Debug, eth0: sending DHCP_REQUEST with xid 0xeea42ec

Debug, eth0: sending DHCP_REQUEST with xid 0xeea42ec

Debug, eth0: sending DHCP_REQUEST with xid 0xeea42ec

Debug, eth0: sending DHCP_REQUEST with xid 0xeea42ec

Debug, eth0: sending DHCP_REQUEST with xid 0xeea42ec

Debug, eth0: sending DHCP_REQUEST with xid 0xeea42ec

Error, eth0: timed out

Info, eth0: exiting                                                                                                                                            [ ok ]

 *       eth0 received address
```

When I change from dhcpcd to udhcpc it works perfectly!! If I try other IPs like 10.0.0.9, or 10.0.0.10 it works!! And sometimes it can get IPs like 10.0.0.3, 10.0.0.5. Some RARE times it gets 10.0.0.4, but only when I tell it to choose randomly. Is this a bug or there is a reason? Maybe a problem from my switch/router?

----------

## xbmodder

Why don't you let it be static? What is your obsession with dhcp?

----------

## pblinux2

I beat my head against this one for a while too.  The relevant information lies here:

# man dhcpcd

```
-I clientID

              Specifies  the  client  identifier  string. If not specified then dhcpcd will attempt to create a client

              identifier according to RFC 4361 and store  the  DUID  part  in  /var/lib/dhcpcd/dhcpcd.duid,  otherwise

              dhcpcd  uses  the MAC address of the network interface. If -I is not given an option then we use the MAC

              address of the network interface.

```

Your dhcpcd client is no longer sending just the MAC in the request.  It is also attaching the DUID, which your router does not recognize.  Since your router thinks you have a new machine, you are not getting the IP address reserved for what it thinks is the old machine.

The fix:  set the vram use flag for dhcpcd and rebuild

```
echo "net-misc/dhcpcd vram" >> /etc/portage/package.use

emerge -N dhcpcd

dhcpcd -x eth0

dhcpcd eth0
```

----------

## Holysword

 *Quote:*   

> The fix: set the vram use flag for dhcpcd and rebuild Κώδικας:
> 
> ```
> echo "net-misc/dhcpcd vram" >> /etc/portage/package.use 
> 
> ...

 

In fact man, this worked! Very thx!!!

 *xbmodder wrote:*   

> Why don't you let it be static? What is your obsession with dhcp?

 

Huahuahauhauhauhauahua, because "I wanted it simple". Funny, don't you think? XD

----------

