# How to change ip address of node after added to chef-server

**URL:** <https://discourse.chef.io/t/how-to-change-ip-address-of-node-after-added-to-chef-server/5507>\
**Category:** Chef Infra (archive)\
**Created:** [July 10, 2014, 2:31pm UTC](https://discourse.chef.io/t/how-to-change-ip-address-of-node-after-added-to-chef-server/5507 "2014-07-10T14:31:23Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![idzzy](https://avatars.discourse-cdn.com/v4/letter/i/d6d6ee/32.png) [@idzzy](https://discourse.chef.io/u/idzzy)\
**Post date:** [July 10, 2014, 2:31pm UTC](https://discourse.chef.io/t/how-to-change-ip-address-of-node-after-added-to-chef-server/5507/1 "2014-07-10T14:31:23Z")

</div>

Hello,

Let me ask about how to change ip address of node after added to chef-server.

target sever has some ip address like this.  
eth0 : 192.168.10.1  
eth1: 192.168.20.1  
eth2: 192.168.30.1

## I run bootstrap from chef workstation to the target server. workstation has 192.168.10.100.

## knife bootstrap 192.168.10.1 -N node-4 -E poc -x root -d centos6

and then completed to install chef-client, registered to chef-server.  
chef-serrver has 192.168.10.200

So all (workstation / chef-server / target-server) is in 192.168.10.x

But the ip address registered to chef-server is 192.168.20.1. Why?  
How can I change the ip address to 192.168.10.1?

* * *

# knife node show node-4

## Node Name: node-4 Environment: poc FQDN: node-4 IP: 192.168.20.1 Run List: Roles: Recipes: Platform: centos 6.5 Tags:

I already use edit command, but there is not ip address.  
and also “-a” option, but I’m not sure which part should I modify.

* * *

# knife node edit node-4

{  
“name”: “node-4”,  
“chef\_environment”: “poc”,  
“normal”: {  
“tags”: [

```
]

```

},  
“run\_list”: [

## ] }

Thank you.

—  
idzzy

---

<div class="post-metadata">

**Author:** ![Fitzwater\_Brian\_K\_CT](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/fitzwater_brian_k_ct/32/45_2.png) [@Fitzwater\_Brian\_K\_CT](https://discourse.chef.io/u/Fitzwater_Brian_K_CT)\
**Post date:** [July 10, 2014, 5:00pm UTC](https://discourse.chef.io/t/how-to-change-ip-address-of-node-after-added-to-chef-server/5507/2 "2014-07-10T17:00:05Z")

</div>

The ipaddress is an automatic attribute[http://docs.opscode.com/ohai.html#automatic-attributes](http://docs.opscode.com/ohai.html#automatic-attributes) detected by ohai. It defaults to the default route. All attributes collected by Ohai are unmodifiable by the chef-client.

So, the short answer is: you can’t (unless you change the default route…but that will probably break something)

From: idzzy [[mailto:idezebi@gmail.com](mailto:idezebi@gmail.com)]  
Sent: Thursday, July 10, 2014 10:31 AM  
To: [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
Subject: [chef] how to change ip address of node after added to chef-server.

Hello,

Let me ask about how to change ip address of node after added to chef-server.

target sever has some ip address like this.  
eth0 : 192.168.10.1  
eth1: 192.168.20.1  
eth2: 192.168.30.1

## I run bootstrap from chef workstation to the target server. workstation has 192.168.10.100.

## knife bootstrap 192.168.10.1 -N node-4 -E poc -x root -d centos6

and then completed to install chef-client, registered to chef-server.  
chef-serrver has 192.168.10.200

So all (workstation / chef-server / target-server) is in 192.168.10.x

But the ip address registered to chef-server is 192.168.20.1. Why?  
How can I change the ip address to 192.168.10.1?

* * *

# knife node show node-4

## Node Name: node-4 Environment: poc FQDN: node-4 IP: 192.168.20.1 Run List: Roles: Recipes: Platform: centos 6.5 Tags:

I already use edit command, but there is not ip address.  
and also “-a” option, but I’m not sure which part should I modify.

* * *

# knife node edit node-4

{  
“name”: “node-4”,  
“chef\_environment”: “poc”,  
“normal”: {  
“tags”: [

```
]

```

},  
“run\_list”: [

## ] }

Thank you.

—  
idzzy

---

<div class="post-metadata">

**Author:** ![Matt\_Ray\_GETCHEF](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/matt_ray_getchef/32/180_2.png) [@Matt\_Ray\_GETCHEF](https://discourse.chef.io/u/Matt_Ray_GETCHEF)\
**Post date:** [July 11, 2014, 3:33am UTC](https://discourse.chef.io/t/how-to-change-ip-address-of-node-after-added-to-chef-server/5507/3 "2014-07-11T03:33:58Z")

</div>

Not to say you "can't", you just need to determine why ohai is setting  
it the way it is and possibly replace the offending behavior. You  
could add a new ohai plugin to modify the behavior, or potentially  
submit a patch if it's a bug in ohai.

> **[About Ohai](https://docs.chef.io/ohai/)**
>
> Ohai is a tool for collecting system configuration data, which it then provides to Chef Infra Client to use in cookbooks.

Thanks,  
Matt Ray  
Director of Partner Integration :: Chef  
512.731.2218 :: [matt@getchef.com](mailto:matt@getchef.com)  
mattray :: GitHub :: IRC :: Twitter

On Thu, Jul 10, 2014 at 12:00 PM, Fitzwater, Brian K (CTR)  
[brian.k.fitzwater@uscis.dhs.gov](mailto:brian.k.fitzwater@uscis.dhs.gov) wrote:

> The ipaddress is an automatic attribute detected by ohai. It defaults to  
> the default route. All attributes collected by Ohai are unmodifiable by the  
> chef-client.
> 
> So, the short answer is: you can’t (unless you change the default route…but  
> that will probably break something)
> 
> From: idzzy [[mailto:idezebi@gmail.com](mailto:idezebi@gmail.com)]  
> Sent: Thursday, July 10, 2014 10:31 AM  
> To: [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> Subject: [chef] how to change ip address of node after added to chef-server.
> 
> Hello,
> 
> Let me ask about how to change ip address of node after added to  
> chef-server.
> 
> target sever has some ip address like this.
> 
> eth0 : 192.168.10.1
> 
> eth1: 192.168.20.1
> 
> eth2: 192.168.30.1
> 
> I run bootstrap from chef workstation to the target server. workstation has  
> 192.168.10.100.
> 
> * * *
> 
> knife bootstrap 192.168.10.1 -N node-4 -E poc -x root -d centos6
> 
> * * *
> 
> and then completed to install chef-client, registered to chef-server.
> 
> chef-serrver has 192.168.10.200
> 
> So all (workstation / chef-server / target-server) is in 192.168.10.x
> 
> But the ip address registered to chef-server is 192.168.20.1. Why?
> 
> How can I change the ip address to 192.168.10.1?
> 
> * * *
> 
> # knife node show node-4
> 
> Node Name: node-4
> 
> Environment: poc
> 
> FQDN: node-4
> 
> IP: 192.168.20.1
> 
> Run List:
> 
> Roles:
> 
> Recipes:
> 
> Platform: centos 6.5
> 
> Tags:
> 
> * * *
> 
> I already use edit command, but there is not ip address.
> 
> and also “-a” option, but I’m not sure which part should I modify.
> 
> * * *
> 
> # knife node edit node-4
> 
> {
> 
> "name": "node-4",
> 
> "chef\_environment": "poc",
> 
> "normal": {
> 
> ```
> "tags": [
> 
> ]
> 
> ```
> 
> },
> 
> "run\_list": [
> 
> ]
> 
> }
> 
> * * *
> 
> Thank you.
> 
> —
> 
> idzzy

---

<div class="post-metadata">

**Author:** ![DV1](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/dv1/32/186_2.png) [@DV1](https://discourse.chef.io/u/DV1)\
**Post date:** [July 11, 2014, 4:27am UTC](https://discourse.chef.io/t/how-to-change-ip-address-of-node-after-added-to-chef-server/5507/4 "2014-07-11T04:27:07Z")

</div>

Maybe instead of relying on node[:ipaddress] you can rely on  
node[:network][:interfaces][:eth0][:addresses] hash. It has all the network  
info you may need. To get the IPv4 address you need to check for value of  
"family":

node[:network][:interfaces][:eth0][:addresses].each do |addr|  
if addr[:family] == "inet"  
return addr # not sure if this var contains actual value..  
end  
end

Here's relevant section from ohai output:

"network": {  
"interfaces": {  
"eth0": {  
"type": "eth",  
"number": "0",  
"mtu": "1500",  
"flags": [  
"BROADCAST",  
"MULTICAST",  
"UP",  
"LOWER\_UP"  
],  
"encapsulation": "Ethernet",  
"addresses": {  
"06:84:8E:00:1D:A6": {  
"family": "lladdr"  
},  
"10.190.34.22": {  
"family": "inet",  
"prefixlen": "23",  
"netmask": "255.255.254.0",  
"broadcast": "10.190.35.255",  
"scope": "Global"  
},  
"fe80::484:8eff:fe00:1da6": {  
"family": "inet6",  
"prefixlen": "64",  
"scope": "Link"  
}

On Thu, Jul 10, 2014 at 8:33 PM, Matt Ray [matt@getchef.com](mailto:matt@getchef.com) wrote:

> Not to say you "can't", you just need to determine why ohai is setting  
> it the way it is and possibly replace the offending behavior. You  
> could add a new ohai plugin to modify the behavior, or potentially  
> submit a patch if it's a bug in ohai.
> 
> [About Ohai](http://docs.opscode.com/ohai.html#custom-plugins)
> 
> Thanks,  
> Matt Ray  
> Director of Partner Integration :: Chef  
> 512.731.2218 :: [matt@getchef.com](mailto:matt@getchef.com)  
> mattray :: GitHub :: IRC :: Twitter
> 
> On Thu, Jul 10, 2014 at 12:00 PM, Fitzwater, Brian K (CTR)  
> [brian.k.fitzwater@uscis.dhs.gov](mailto:brian.k.fitzwater@uscis.dhs.gov) wrote:
> 
> > The ipaddress is an automatic attribute detected by ohai. It defaults to  
> > the default route. All attributes collected by Ohai are unmodifiable by  
> > the  
> > chef-client.
> > 
> > So, the short answer is: you can’t (unless you change the default  
> > route…but  
> > that will probably break something)
> > 
> > From: idzzy [[mailto:idezebi@gmail.com](mailto:idezebi@gmail.com)]  
> > Sent: Thursday, July 10, 2014 10:31 AM  
> > To: [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> > Subject: [chef] how to change ip address of node after added to  
> > chef-server.
> > 
> > Hello,
> > 
> > Let me ask about how to change ip address of node after added to  
> > chef-server.
> > 
> > target sever has some ip address like this.
> > 
> > eth0 : 192.168.10.1
> > 
> > eth1: 192.168.20.1
> > 
> > eth2: 192.168.30.1
> > 
> > I run bootstrap from chef workstation to the target server. workstation  
> > has  
> > 192.168.10.100.
> > 
> > * * *
> > 
> > knife bootstrap 192.168.10.1 -N node-4 -E poc -x root -d centos6
> > 
> > * * *
> > 
> > and then completed to install chef-client, registered to chef-server.
> > 
> > chef-serrver has 192.168.10.200
> > 
> > So all (workstation / chef-server / target-server) is in 192.168.10.x
> > 
> > But the ip address registered to chef-server is 192.168.20.1. Why?
> > 
> > How can I change the ip address to 192.168.10.1?
> > 
> > * * *
> > 
> > # knife node show node-4
> > 
> > Node Name: node-4
> > 
> > Environment: poc
> > 
> > FQDN: node-4
> > 
> > IP: 192.168.20.1
> > 
> > Run List:
> > 
> > Roles:
> > 
> > Recipes:
> > 
> > Platform: centos 6.5
> > 
> > Tags:
> > 
> > * * *
> > 
> > I already use edit command, but there is not ip address.
> > 
> > and also “-a” option, but I’m not sure which part should I modify.
> > 
> > * * *
> > 
> > # knife node edit node-4
> > 
> > {
> > 
> > "name": "node-4",
> > 
> > "chef\_environment": "poc",
> > 
> > "normal": {
> > 
> > ```
> > "tags": [
> > 
> > ]
> > 
> > ```
> > 
> > },
> > 
> > "run\_list": [
> > 
> > ]
> > 
> > }
> > 
> > * * *
> > 
> > Thank you.
> > 
> > —
> > 
> > idzzy

--  
Best regards, Dmitriy V.

---

<div class="post-metadata">

**Author:** ![idzzy](https://avatars.discourse-cdn.com/v4/letter/i/d6d6ee/32.png) [@idzzy](https://discourse.chef.io/u/idzzy)\
**Post date:** [July 12, 2014, 12:16am UTC](https://discourse.chef.io/t/how-to-change-ip-address-of-node-after-added-to-chef-server/5507/5 "2014-07-12T00:16:48Z")

</div>

Hello

Understood. It’s very helpful hint.  
I will check the ohai output again and also custom plugin.

Thank you.

—  
idzzy

On July 11, 2014 at 1:28:09 PM, DV ([vindimy@gmail.com](mailto:vindimy@gmail.com)) wrote:

Maybe instead of relying on node[:ipaddress] you can rely on node[:network][:interfaces][:eth0][:addresses] hash. It has all the network info you may need. To get the IPv4 address you need to check for value of "family":

node[:network][:interfaces][:eth0][:addresses].each do |addr|  
if addr[:family] == "inet"  
return addr # not sure if this var contains actual value..  
end  
end

Here's relevant section from ohai output:

"network": {  
"interfaces": {  
"eth0": {  
"type": "eth",  
"number": "0",  
"mtu": "1500",  
"flags": [  
"BROADCAST",  
"MULTICAST",  
"UP",  
"LOWER\_UP"  
],  
"encapsulation": "Ethernet",  
"addresses": {  
"06:84:8E:00:1D:A6": {  
"family": "lladdr"  
},  
"10.190.34.22": {  
"family": "inet",  
"prefixlen": "23",  
"netmask": "255.255.254.0",  
"broadcast": "10.190.35.255",  
"scope": "Global"  
},  
"fe80::484:8eff:fe00:1da6": {  
"family": "inet6",  
"prefixlen": "64",  
"scope": "Link"  
}

On Thu, Jul 10, 2014 at 8:33 PM, Matt Ray [matt@getchef.com](mailto:matt@getchef.com) wrote:  
Not to say you "can't", you just need to determine why ohai is setting  
it the way it is and possibly replace the offending behavior. You  
could add a new ohai plugin to modify the behavior, or potentially  
submit a patch if it's a bug in ohai.

> **[About Ohai](https://docs.chef.io/ohai/)**
>
> Ohai is a tool for collecting system configuration data, which it then provides to Chef Infra Client to use in cookbooks.

Thanks,  
Matt Ray  
Director of Partner Integration :: Chef  
512.731.2218 :: [matt@getchef.com](mailto:matt@getchef.com)  
mattray :: GitHub :: IRC :: Twitter

On Thu, Jul 10, 2014 at 12:00 PM, Fitzwater, Brian K (CTR)  
[brian.k.fitzwater@uscis.dhs.gov](mailto:brian.k.fitzwater@uscis.dhs.gov) wrote:

> The ipaddress is an automatic attribute detected by ohai. It defaults to  
> the default route. All attributes collected by Ohai are unmodifiable by the  
> chef-client.
> 
> So, the short answer is: you can’t (unless you change the default route…but  
> that will probably break something)
> 
> From: idzzy [[mailto:idezebi@gmail.com](mailto:idezebi@gmail.com)]  
> Sent: Thursday, July 10, 2014 10:31 AM  
> To: [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> Subject: [chef] how to change ip address of node after added to chef-server.
> 
> Hello,
> 
> Let me ask about how to change ip address of node after added to  
> chef-server.
> 
> target sever has some ip address like this.
> 
> eth0 : 192.168.10.1
> 
> eth1: 192.168.20.1
> 
> eth2: 192.168.30.1
> 
> I run bootstrap from chef workstation to the target server. workstation has  
> 192.168.10.100.
> 
> * * *
> 
> knife bootstrap 192.168.10.1 -N node-4 -E poc -x root -d centos6
> 
> * * *
> 
> and then completed to install chef-client, registered to chef-server.
> 
> chef-serrver has 192.168.10.200
> 
> So all (workstation / chef-server / target-server) is in 192.168.10.x
> 
> But the ip address registered to chef-server is 192.168.20.1. Why?
> 
> How can I change the ip address to 192.168.10.1?
> 
> * * *
> 
> # knife node show node-4
> 
> Node Name: node-4
> 
> Environment: poc
> 
> FQDN: node-4
> 
> IP: 192.168.20.1
> 
> Run List:
> 
> Roles:
> 
> Recipes:
> 
> Platform: centos 6.5
> 
> Tags:
> 
> * * *
> 
> I already use edit command, but there is not ip address.
> 
> and also “-a” option, but I’m not sure which part should I modify.
> 
> * * *
> 
> # knife node edit node-4
> 
> {
> 
> "name": "node-4",
> 
> "chef\_environment": "poc",
> 
> "normal": {
> 
> ```
> "tags": [
> 
> ]
> 
> ```
> 
> },
> 
> "run\_list": [
> 
> ]
> 
> }
> 
> * * *
> 
> Thank you.
> 
> —
> 
> idzzy

--  
Best regards, Dmitriy V.

---

<div class="post-metadata">

**Author:** ![Christine\_Draper](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/christine_draper/32/68_2.png) [@Christine\_Draper](https://discourse.chef.io/u/Christine_Draper)\
**Post date:** [July 12, 2014, 7:06pm UTC](https://discourse.chef.io/t/how-to-change-ip-address-of-node-after-added-to-chef-server/5507/6 "2014-07-12T19:06:02Z")

</div>

This problem has been bothering me too.

I fixed it in my case by changing the default IP route to eth1 rather than  
eth0. In ubuntu, the command was:

sudo ip route change to default dev eth1 via [gateway ip]

I hoped I might do this in a recipe using the route resource, but:

route "default" do  
device "eth1"  
end

Didn't recognize "default" as a valid address. Having looked at the doc  
[http://docs.opscode.com/resource\_route.html](http://docs.opscode.com/resource_route.html) and code  
[https://github.com/opscode/chef/blob/master/lib/chef/provider/route.rb](https://github.com/opscode/chef/blob/master/lib/chef/provider/route.rb) it  
looks like the route resource only supports specific IP addresses.

On Fri, Jul 11, 2014 at 7:16 PM, idzzy [idezebi@gmail.com](mailto:idezebi@gmail.com) wrote:

> Hello
> 
> Understood. It’s very helpful hint.  
> I will check the ohai output again and also custom plugin.
> 
> Thank you.
> 
> —  
> idzzy
> 
> On July 11, 2014 at 1:28:09 PM, DV ([vindimy@gmail.com](mailto:vindimy@gmail.com)) wrote:
> 
> Maybe instead of relying on node[:ipaddress] you can rely on  
> node[:network][:interfaces][:eth0][:addresses] hash. It has all the network  
> info you may need. To get the IPv4 address you need to check for value of  
> "family":
> 
> node[:network][:interfaces][:eth0][:addresses].each do |addr|  
> if addr[:family] == "inet"  
> return addr # not sure if this var contains actual value..  
> end  
> end
> 
> Here's relevant section from ohai output:
> 
> "network": {  
> "interfaces": {  
> "eth0": {  
> "type": "eth",  
> "number": "0",  
> "mtu": "1500",  
> "flags": [  
> "BROADCAST",  
> "MULTICAST",  
> "UP",  
> "LOWER\_UP"  
> ],  
> "encapsulation": "Ethernet",  
> "addresses": {  
> "06:84:8E:00:1D:A6": {  
> "family": "lladdr"  
> },  
> "10.190.34.22": {  
> "family": "inet",  
> "prefixlen": "23",  
> "netmask": "255.255.254.0",  
> "broadcast": "10.190.35.255",  
> "scope": "Global"  
> },  
> "fe80::484:8eff:fe00:1da6": {  
> "family": "inet6",  
> "prefixlen": "64",  
> "scope": "Link"  
> }
> 
> On Thu, Jul 10, 2014 at 8:33 PM, Matt Ray [matt@getchef.com](mailto:matt@getchef.com) wrote:
> 
> > Not to say you "can't", you just need to determine why ohai is setting  
> > it the way it is and possibly replace the offending behavior. You  
> > could add a new ohai plugin to modify the behavior, or potentially  
> > submit a patch if it's a bug in ohai.
> > 
> > [About Ohai](http://docs.opscode.com/ohai.html#custom-plugins)
> > 
> > Thanks,  
> > Matt Ray  
> > Director of Partner Integration :: Chef  
> > 512.731.2218 :: [matt@getchef.com](mailto:matt@getchef.com)  
> > mattray :: GitHub :: IRC :: Twitter
> > 
> > On Thu, Jul 10, 2014 at 12:00 PM, Fitzwater, Brian K (CTR)  
> > [brian.k.fitzwater@uscis.dhs.gov](mailto:brian.k.fitzwater@uscis.dhs.gov) wrote:
> > 
> > > The ipaddress is an automatic attribute detected by ohai. It defaults  
> > > to  
> > > the default route. All attributes collected by Ohai are unmodifiable  
> > > by the  
> > > chef-client.
> > > 
> > > So, the short answer is: you can’t (unless you change the default  
> > > route…but  
> > > that will probably break something)
> > > 
> > > From: idzzy [[mailto:idezebi@gmail.com](mailto:idezebi@gmail.com)]  
> > > Sent: Thursday, July 10, 2014 10:31 AM  
> > > To: [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> > > Subject: [chef] how to change ip address of node after added to  
> > > chef-server.
> > > 
> > > Hello,
> > > 
> > > Let me ask about how to change ip address of node after added to  
> > > chef-server.
> > > 
> > > target sever has some ip address like this.
> > > 
> > > eth0 : 192.168.10.1
> > > 
> > > eth1: 192.168.20.1
> > > 
> > > eth2: 192.168.30.1
> > > 
> > > I run bootstrap from chef workstation to the target server. workstation  
> > > has  
> > > 192.168.10.100.
> > > 
> > > * * *
> > > 
> > > knife bootstrap 192.168.10.1 -N node-4 -E poc -x root -d centos6
> > > 
> > > * * *
> > > 
> > > and then completed to install chef-client, registered to chef-server.
> > > 
> > > chef-serrver has 192.168.10.200
> > > 
> > > So all (workstation / chef-server / target-server) is in 192.168.10.x
> > > 
> > > But the ip address registered to chef-server is 192.168.20.1. Why?
> > > 
> > > How can I change the ip address to 192.168.10.1?
> > > 
> > > * * *
> > > 
> > > # knife node show node-4
> > > 
> > > Node Name: node-4
> > > 
> > > Environment: poc
> > > 
> > > FQDN: node-4
> > > 
> > > IP: 192.168.20.1
> > > 
> > > Run List:
> > > 
> > > Roles:
> > > 
> > > Recipes:
> > > 
> > > Platform: centos 6.5
> > > 
> > > Tags:
> > > 
> > > * * *
> > > 
> > > I already use edit command, but there is not ip address.
> > > 
> > > and also “-a” option, but I’m not sure which part should I modify.
> > > 
> > > * * *
> > > 
> > > # knife node edit node-4
> > > 
> > > {
> > > 
> > > "name": "node-4",
> > > 
> > > "chef\_environment": "poc",
> > > 
> > > "normal": {
> > > 
> > > ```
> > > "tags": [
> > > 
> > > ]
> > > 
> > > ```
> > > 
> > > },
> > > 
> > > "run\_list": [
> > > 
> > > ]
> > > 
> > > }
> > > 
> > > * * *
> > > 
> > > Thank you.
> > > 
> > > —
> > > 
> > > idzzy
> 
> --  
> Best regards, Dmitriy V.

---

<div class="post-metadata">

**Author:** ![dennybaa](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/dennybaa/32/286_2.png) [@dennybaa](https://discourse.chef.io/u/dennybaa)\
**Post date:** [July 12, 2014, 9:44pm UTC](https://discourse.chef.io/t/how-to-change-ip-address-of-node-after-added-to-chef-server/5507/7 "2014-07-12T21:44:56Z")

</div>

Default route is the same with 0.0.0.0, you could try it instead.  
On Jul 12, 2014 11:06 PM, "Christine Draper" \<  
[christine\_draper@thirdwaveinsights.com](mailto:christine_draper@thirdwaveinsights.com)\> wrote:

> This problem has been bothering me too.
> 
> I fixed it in my case by changing the default IP route to eth1 rather than  
> eth0. In ubuntu, the command was:
> 
> sudo ip route change to default dev eth1 via [gateway ip]
> 
> I hoped I might do this in a recipe using the route resource, but:
> 
> route "default" do  
> device "eth1"  
> end
> 
> Didn't recognize "default" as a valid address. Having looked at the doc  
> [http://docs.opscode.com/resource\_route.html](http://docs.opscode.com/resource_route.html) and code  
> [https://github.com/opscode/chef/blob/master/lib/chef/provider/route.rb](https://github.com/opscode/chef/blob/master/lib/chef/provider/route.rb)  
> it looks like the route resource only supports specific IP addresses.
> 
> On Fri, Jul 11, 2014 at 7:16 PM, idzzy [idezebi@gmail.com](mailto:idezebi@gmail.com) wrote:
> 
> > Hello
> > 
> > Understood. It’s very helpful hint.  
> > I will check the ohai output again and also custom plugin.
> > 
> > Thank you.
> > 
> > —  
> > idzzy
> > 
> > On July 11, 2014 at 1:28:09 PM, DV ([vindimy@gmail.com](mailto:vindimy@gmail.com)) wrote:
> > 
> > Maybe instead of relying on node[:ipaddress] you can rely on  
> > node[:network][:interfaces][:eth0][:addresses] hash. It has all the network  
> > info you may need. To get the IPv4 address you need to check for value of  
> > "family":
> > 
> > node[:network][:interfaces][:eth0][:addresses].each do |addr|  
> > if addr[:family] == "inet"  
> > return addr # not sure if this var contains actual value..  
> > end  
> > end
> > 
> > Here's relevant section from ohai output:
> > 
> > "network": {  
> > "interfaces": {  
> > "eth0": {  
> > "type": "eth",  
> > "number": "0",  
> > "mtu": "1500",  
> > "flags": [  
> > "BROADCAST",  
> > "MULTICAST",  
> > "UP",  
> > "LOWER\_UP"  
> > ],  
> > "encapsulation": "Ethernet",  
> > "addresses": {  
> > "06:84:8E:00:1D:A6": {  
> > "family": "lladdr"  
> > },  
> > "10.190.34.22": {  
> > "family": "inet",  
> > "prefixlen": "23",  
> > "netmask": "255.255.254.0",  
> > "broadcast": "10.190.35.255",  
> > "scope": "Global"  
> > },  
> > "fe80::484:8eff:fe00:1da6": {  
> > "family": "inet6",  
> > "prefixlen": "64",  
> > "scope": "Link"  
> > }
> > 
> > On Thu, Jul 10, 2014 at 8:33 PM, Matt Ray [matt@getchef.com](mailto:matt@getchef.com) wrote:
> > 
> > > Not to say you "can't", you just need to determine why ohai is setting  
> > > it the way it is and possibly replace the offending behavior. You  
> > > could add a new ohai plugin to modify the behavior, or potentially  
> > > submit a patch if it's a bug in ohai.
> > > 
> > > [About Ohai](http://docs.opscode.com/ohai.html#custom-plugins)
> > > 
> > > Thanks,  
> > > Matt Ray  
> > > Director of Partner Integration :: Chef  
> > > 512.731.2218 :: [matt@getchef.com](mailto:matt@getchef.com)  
> > > mattray :: GitHub :: IRC :: Twitter
> > > 
> > > On Thu, Jul 10, 2014 at 12:00 PM, Fitzwater, Brian K (CTR)  
> > > [brian.k.fitzwater@uscis.dhs.gov](mailto:brian.k.fitzwater@uscis.dhs.gov) wrote:
> > > 
> > > > The ipaddress is an automatic attribute detected by ohai. It defaults  
> > > > to  
> > > > the default route. All attributes collected by Ohai are unmodifiable  
> > > > by the  
> > > > chef-client.
> > > > 
> > > > So, the short answer is: you can’t (unless you change the default  
> > > > route…but  
> > > > that will probably break something)
> > > > 
> > > > From: idzzy [[mailto:idezebi@gmail.com](mailto:idezebi@gmail.com)]  
> > > > Sent: Thursday, July 10, 2014 10:31 AM  
> > > > To: [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> > > > Subject: [chef] how to change ip address of node after added to  
> > > > chef-server.
> > > > 
> > > > Hello,
> > > > 
> > > > Let me ask about how to change ip address of node after added to  
> > > > chef-server.
> > > > 
> > > > target sever has some ip address like this.
> > > > 
> > > > eth0 : 192.168.10.1
> > > > 
> > > > eth1: 192.168.20.1
> > > > 
> > > > eth2: 192.168.30.1
> > > > 
> > > > I run bootstrap from chef workstation to the target server.  
> > > > workstation has  
> > > > 192.168.10.100.
> > > > 
> > > > * * *
> > > > 
> > > > knife bootstrap 192.168.10.1 -N node-4 -E poc -x root -d centos6
> > > > 
> > > > * * *
> > > > 
> > > > and then completed to install chef-client, registered to chef-server.
> > > > 
> > > > chef-serrver has 192.168.10.200
> > > > 
> > > > So all (workstation / chef-server / target-server) is in 192.168.10.x
> > > > 
> > > > But the ip address registered to chef-server is 192.168.20.1. Why?
> > > > 
> > > > How can I change the ip address to 192.168.10.1?
> > > > 
> > > > * * *
> > > > 
> > > > # knife node show node-4
> > > > 
> > > > Node Name: node-4
> > > > 
> > > > Environment: poc
> > > > 
> > > > FQDN: node-4
> > > > 
> > > > IP: 192.168.20.1
> > > > 
> > > > Run List:
> > > > 
> > > > Roles:
> > > > 
> > > > Recipes:
> > > > 
> > > > Platform: centos 6.5
> > > > 
> > > > Tags:
> > > > 
> > > > * * *
> > > > 
> > > > I already use edit command, but there is not ip address.
> > > > 
> > > > and also “-a” option, but I’m not sure which part should I modify.
> > > > 
> > > > * * *
> > > > 
> > > > # knife node edit node-4
> > > > 
> > > > {
> > > > 
> > > > "name": "node-4",
> > > > 
> > > > "chef\_environment": "poc",
> > > > 
> > > > "normal": {
> > > > 
> > > > ```
> > > > "tags": [
> > > > 
> > > > ]
> > > > 
> > > > ```
> > > > 
> > > > },
> > > > 
> > > > "run\_list": [
> > > > 
> > > > ]
> > > > 
> > > > }
> > > > 
> > > > * * *
> > > > 
> > > > Thank you.
> > > > 
> > > > —
> > > > 
> > > > idzzy
> > 
> > --  
> > Best regards, Dmitriy V.

---

<div class="post-metadata">

**Author:** ![Christine\_Draper](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/christine_draper/32/68_2.png) [@Christine\_Draper](https://discourse.chef.io/u/Christine_Draper)\
**Post date:** [July 13, 2014, 7:18am UTC](https://discourse.chef.io/t/how-to-change-ip-address-of-node-after-added-to-chef-server/5507/8 "2014-07-13T07:18:07Z")

</div>

I gave it a go and I can add a route for 0.0.0.0 but unfortunately it  
doesnt result in ohai picking up the eth1 address, because I've still got a  
default route for eth0. Seems like 0.0.0.0 isn't quite the same as default  
in this respect.

Christine

On Sat, Jul 12, 2014 at 4:44 PM, Денис Барышев [denis.barishev@gmail.com](mailto:denis.barishev@gmail.com)  
wrote:

> Default route is the same with 0.0.0.0, you could try it instead.  
> On Jul 12, 2014 11:06 PM, "Christine Draper" \<  
> [christine\_draper@thirdwaveinsights.com](mailto:christine_draper@thirdwaveinsights.com)\> wrote:
> 
> > This problem has been bothering me too.
> > 
> > I fixed it in my case by changing the default IP route to eth1 rather  
> > than eth0. In ubuntu, the command was:
> > 
> > sudo ip route change to default dev eth1 via [gateway ip]
> > 
> > I hoped I might do this in a recipe using the route resource, but:
> > 
> > route "default" do  
> > device "eth1"  
> > end
> > 
> > Didn't recognize "default" as a valid address. Having looked at the doc  
> > [http://docs.opscode.com/resource\_route.html](http://docs.opscode.com/resource_route.html) and code  
> > [https://github.com/opscode/chef/blob/master/lib/chef/provider/route.rb](https://github.com/opscode/chef/blob/master/lib/chef/provider/route.rb)  
> > it looks like the route resource only supports specific IP addresses.
> > 
> > On Fri, Jul 11, 2014 at 7:16 PM, idzzy [idezebi@gmail.com](mailto:idezebi@gmail.com) wrote:
> > 
> > > Hello
> > > 
> > > Understood. It’s very helpful hint.  
> > > I will check the ohai output again and also custom plugin.
> > > 
> > > Thank you.
> > > 
> > > —  
> > > idzzy
> > > 
> > > On July 11, 2014 at 1:28:09 PM, DV ([vindimy@gmail.com](mailto:vindimy@gmail.com)) wrote:
> > > 
> > > Maybe instead of relying on node[:ipaddress] you can rely on  
> > > node[:network][:interfaces][:eth0][:addresses] hash. It has all the network  
> > > info you may need. To get the IPv4 address you need to check for value of  
> > > "family":
> > > 
> > > node[:network][:interfaces][:eth0][:addresses].each do |addr|  
> > > if addr[:family] == "inet"  
> > > return addr # not sure if this var contains actual value..  
> > > end  
> > > end
> > > 
> > > Here's relevant section from ohai output:
> > > 
> > > "network": {  
> > > "interfaces": {  
> > > "eth0": {  
> > > "type": "eth",  
> > > "number": "0",  
> > > "mtu": "1500",  
> > > "flags": [  
> > > "BROADCAST",  
> > > "MULTICAST",  
> > > "UP",  
> > > "LOWER\_UP"  
> > > ],  
> > > "encapsulation": "Ethernet",  
> > > "addresses": {  
> > > "06:84:8E:00:1D:A6": {  
> > > "family": "lladdr"  
> > > },  
> > > "10.190.34.22": {  
> > > "family": "inet",  
> > > "prefixlen": "23",  
> > > "netmask": "255.255.254.0",  
> > > "broadcast": "10.190.35.255",  
> > > "scope": "Global"  
> > > },  
> > > "fe80::484:8eff:fe00:1da6": {  
> > > "family": "inet6",  
> > > "prefixlen": "64",  
> > > "scope": "Link"  
> > > }
> > > 
> > > On Thu, Jul 10, 2014 at 8:33 PM, Matt Ray [matt@getchef.com](mailto:matt@getchef.com) wrote:
> > > 
> > > > Not to say you "can't", you just need to determine why ohai is setting  
> > > > it the way it is and possibly replace the offending behavior. You  
> > > > could add a new ohai plugin to modify the behavior, or potentially  
> > > > submit a patch if it's a bug in ohai.
> > > > 
> > > > [About Ohai](http://docs.opscode.com/ohai.html#custom-plugins)
> > > > 
> > > > Thanks,  
> > > > Matt Ray  
> > > > Director of Partner Integration :: Chef  
> > > > 512.731.2218 :: [matt@getchef.com](mailto:matt@getchef.com)  
> > > > mattray :: GitHub :: IRC :: Twitter
> > > > 
> > > > On Thu, Jul 10, 2014 at 12:00 PM, Fitzwater, Brian K (CTR)  
> > > > [brian.k.fitzwater@uscis.dhs.gov](mailto:brian.k.fitzwater@uscis.dhs.gov) wrote:
> > > > 
> > > > > The ipaddress is an automatic attribute detected by ohai. It  
> > > > > defaults to  
> > > > > the default route. All attributes collected by Ohai are unmodifiable  
> > > > > by the  
> > > > > chef-client.
> > > > > 
> > > > > So, the short answer is: you can’t (unless you change the default  
> > > > > route…but  
> > > > > that will probably break something)
> > > > > 
> > > > > From: idzzy [[mailto:idezebi@gmail.com](mailto:idezebi@gmail.com)]  
> > > > > Sent: Thursday, July 10, 2014 10:31 AM  
> > > > > To: [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> > > > > Subject: [chef] how to change ip address of node after added to  
> > > > > chef-server.
> > > > > 
> > > > > Hello,
> > > > > 
> > > > > Let me ask about how to change ip address of node after added to  
> > > > > chef-server.
> > > > > 
> > > > > target sever has some ip address like this.
> > > > > 
> > > > > eth0 : 192.168.10.1
> > > > > 
> > > > > eth1: 192.168.20.1
> > > > > 
> > > > > eth2: 192.168.30.1
> > > > > 
> > > > > I run bootstrap from chef workstation to the target server.  
> > > > > workstation has  
> > > > > 192.168.10.100.
> > > > > 
> > > > > * * *
> > > > > 
> > > > > knife bootstrap 192.168.10.1 -N node-4 -E poc -x root -d centos6
> > > > > 
> > > > > * * *
> > > > > 
> > > > > and then completed to install chef-client, registered to chef-server.
> > > > > 
> > > > > chef-serrver has 192.168.10.200
> > > > > 
> > > > > So all (workstation / chef-server / target-server) is in 192.168.10.x
> > > > > 
> > > > > But the ip address registered to chef-server is 192.168.20.1. Why?
> > > > > 
> > > > > How can I change the ip address to 192.168.10.1?
> > > > > 
> > > > > * * *
> > > > > 
> > > > > # knife node show node-4
> > > > > 
> > > > > Node Name: node-4
> > > > > 
> > > > > Environment: poc
> > > > > 
> > > > > FQDN: node-4
> > > > > 
> > > > > IP: 192.168.20.1
> > > > > 
> > > > > Run List:
> > > > > 
> > > > > Roles:
> > > > > 
> > > > > Recipes:
> > > > > 
> > > > > Platform: centos 6.5
> > > > > 
> > > > > Tags:
> > > > > 
> > > > > * * *
> > > > > 
> > > > > I already use edit command, but there is not ip address.
> > > > > 
> > > > > and also “-a” option, but I’m not sure which part should I modify.
> > > > > 
> > > > > * * *
> > > > > 
> > > > > # knife node edit node-4
> > > > > 
> > > > > {
> > > > > 
> > > > > "name": "node-4",
> > > > > 
> > > > > "chef\_environment": "poc",
> > > > > 
> > > > > "normal": {
> > > > > 
> > > > > ```
> > > > > "tags": [
> > > > > 
> > > > > ]
> > > > > 
> > > > > ```
> > > > > 
> > > > > },
> > > > > 
> > > > > "run\_list": [
> > > > > 
> > > > > ]
> > > > > 
> > > > > }
> > > > > 
> > > > > * * *
> > > > > 
> > > > > Thank you.
> > > > > 
> > > > > —
> > > > > 
> > > > > idzzy
> > > 
> > > --  
> > > Best regards, Dmitriy V.

---

<div class="post-metadata">

**Author:** ![dennybaa](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/dennybaa/32/286_2.png) [@dennybaa](https://discourse.chef.io/u/dennybaa)\
**Post date:** [July 13, 2014, 7:28am UTC](https://discourse.chef.io/t/how-to-change-ip-address-of-node-after-added-to-chef-server/5507/9 "2014-07-13T07:28:37Z")

</div>

Hmm. I got that, I don't how Ohai plug-in works. But the route resource  
defaults mask to /24 and it is of course not the same, cuz the default  
route mask is /0.  
On Jul 13, 2014 11:18 AM, "Christine Draper" \<  
[christine\_draper@thirdwaveinsights.com](mailto:christine_draper@thirdwaveinsights.com)\> wrote:

> I gave it a go and I can add a route for 0.0.0.0 but unfortunately it  
> doesnt result in ohai picking up the eth1 address, because I've still got a  
> default route for eth0. Seems like 0.0.0.0 isn't quite the same as default  
> in this respect.
> 
> Christine
> 
> On Sat, Jul 12, 2014 at 4:44 PM, Денис Барышев [denis.barishev@gmail.com](mailto:denis.barishev@gmail.com)  
> wrote:
> 
> > Default route is the same with 0.0.0.0, you could try it instead.  
> > On Jul 12, 2014 11:06 PM, "Christine Draper" \<  
> > [christine\_draper@thirdwaveinsights.com](mailto:christine_draper@thirdwaveinsights.com)\> wrote:
> > 
> > > This problem has been bothering me too.
> > > 
> > > I fixed it in my case by changing the default IP route to eth1 rather  
> > > than eth0. In ubuntu, the command was:
> > > 
> > > sudo ip route change to default dev eth1 via [gateway ip]
> > > 
> > > I hoped I might do this in a recipe using the route resource, but:
> > > 
> > > route "default" do  
> > > device "eth1"  
> > > end
> > > 
> > > Didn't recognize "default" as a valid address. Having looked at the doc  
> > > [http://docs.opscode.com/resource\_route.html](http://docs.opscode.com/resource_route.html) and code  
> > > [https://github.com/opscode/chef/blob/master/lib/chef/provider/route.rb](https://github.com/opscode/chef/blob/master/lib/chef/provider/route.rb)  
> > > it looks like the route resource only supports specific IP addresses.
> > > 
> > > On Fri, Jul 11, 2014 at 7:16 PM, idzzy [idezebi@gmail.com](mailto:idezebi@gmail.com) wrote:
> > > 
> > > > Hello
> > > > 
> > > > Understood. It’s very helpful hint.  
> > > > I will check the ohai output again and also custom plugin.
> > > > 
> > > > Thank you.
> > > > 
> > > > —  
> > > > idzzy
> > > > 
> > > > On July 11, 2014 at 1:28:09 PM, DV ([vindimy@gmail.com](mailto:vindimy@gmail.com)) wrote:
> > > > 
> > > > Maybe instead of relying on node[:ipaddress] you can rely on  
> > > > node[:network][:interfaces][:eth0][:addresses] hash. It has all the network  
> > > > info you may need. To get the IPv4 address you need to check for value of  
> > > > "family":
> > > > 
> > > > node[:network][:interfaces][:eth0][:addresses].each do |addr|  
> > > > if addr[:family] == "inet"  
> > > > return addr # not sure if this var contains actual value..  
> > > > end  
> > > > end
> > > > 
> > > > Here's relevant section from ohai output:
> > > > 
> > > > "network": {  
> > > > "interfaces": {  
> > > > "eth0": {  
> > > > "type": "eth",  
> > > > "number": "0",  
> > > > "mtu": "1500",  
> > > > "flags": [  
> > > > "BROADCAST",  
> > > > "MULTICAST",  
> > > > "UP",  
> > > > "LOWER\_UP"  
> > > > ],  
> > > > "encapsulation": "Ethernet",  
> > > > "addresses": {  
> > > > "06:84:8E:00:1D:A6": {  
> > > > "family": "lladdr"  
> > > > },  
> > > > "10.190.34.22": {  
> > > > "family": "inet",  
> > > > "prefixlen": "23",  
> > > > "netmask": "255.255.254.0",  
> > > > "broadcast": "10.190.35.255",  
> > > > "scope": "Global"  
> > > > },  
> > > > "fe80::484:8eff:fe00:1da6": {  
> > > > "family": "inet6",  
> > > > "prefixlen": "64",  
> > > > "scope": "Link"  
> > > > }
> > > > 
> > > > On Thu, Jul 10, 2014 at 8:33 PM, Matt Ray [matt@getchef.com](mailto:matt@getchef.com) wrote:
> > > > 
> > > > > Not to say you "can't", you just need to determine why ohai is setting  
> > > > > it the way it is and possibly replace the offending behavior. You  
> > > > > could add a new ohai plugin to modify the behavior, or potentially  
> > > > > submit a patch if it's a bug in ohai.
> > > > > 
> > > > > [About Ohai](http://docs.opscode.com/ohai.html#custom-plugins)
> > > > > 
> > > > > Thanks,  
> > > > > Matt Ray  
> > > > > Director of Partner Integration :: Chef  
> > > > > 512.731.2218 :: [matt@getchef.com](mailto:matt@getchef.com)  
> > > > > mattray :: GitHub :: IRC :: Twitter
> > > > > 
> > > > > On Thu, Jul 10, 2014 at 12:00 PM, Fitzwater, Brian K (CTR)  
> > > > > [brian.k.fitzwater@uscis.dhs.gov](mailto:brian.k.fitzwater@uscis.dhs.gov) wrote:
> > > > > 
> > > > > > The ipaddress is an automatic attribute detected by ohai. It  
> > > > > > defaults to  
> > > > > > the default route. All attributes collected by Ohai are  
> > > > > > unmodifiable by the  
> > > > > > chef-client.
> > > > > > 
> > > > > > So, the short answer is: you can’t (unless you change the default  
> > > > > > route…but  
> > > > > > that will probably break something)
> > > > > > 
> > > > > > From: idzzy [[mailto:idezebi@gmail.com](mailto:idezebi@gmail.com)]  
> > > > > > Sent: Thursday, July 10, 2014 10:31 AM  
> > > > > > To: [chef@lists.opscode.com](mailto:chef@lists.opscode.com)  
> > > > > > Subject: [chef] how to change ip address of node after added to  
> > > > > > chef-server.
> > > > > > 
> > > > > > Hello,
> > > > > > 
> > > > > > Let me ask about how to change ip address of node after added to  
> > > > > > chef-server.
> > > > > > 
> > > > > > target sever has some ip address like this.
> > > > > > 
> > > > > > eth0 : 192.168.10.1
> > > > > > 
> > > > > > eth1: 192.168.20.1
> > > > > > 
> > > > > > eth2: 192.168.30.1
> > > > > > 
> > > > > > I run bootstrap from chef workstation to the target server.  
> > > > > > workstation has  
> > > > > > 192.168.10.100.
> > > > > > 
> > > > > > * * *
> > > > > > 
> > > > > > knife bootstrap 192.168.10.1 -N node-4 -E poc -x root -d centos6
> > > > > > 
> > > > > > * * *
> > > > > > 
> > > > > > and then completed to install chef-client, registered to chef-server.
> > > > > > 
> > > > > > chef-serrver has 192.168.10.200
> > > > > > 
> > > > > > So all (workstation / chef-server / target-server) is in 192.168.10.x
> > > > > > 
> > > > > > But the ip address registered to chef-server is 192.168.20.1. Why?
> > > > > > 
> > > > > > How can I change the ip address to 192.168.10.1?
> > > > > > 
> > > > > > * * *
> > > > > > 
> > > > > > # knife node show node-4
> > > > > > 
> > > > > > Node Name: node-4
> > > > > > 
> > > > > > Environment: poc
> > > > > > 
> > > > > > FQDN: node-4
> > > > > > 
> > > > > > IP: 192.168.20.1
> > > > > > 
> > > > > > Run List:
> > > > > > 
> > > > > > Roles:
> > > > > > 
> > > > > > Recipes:
> > > > > > 
> > > > > > Platform: centos 6.5
> > > > > > 
> > > > > > Tags:
> > > > > > 
> > > > > > * * *
> > > > > > 
> > > > > > I already use edit command, but there is not ip address.
> > > > > > 
> > > > > > and also “-a” option, but I’m not sure which part should I modify.
> > > > > > 
> > > > > > * * *
> > > > > > 
> > > > > > # knife node edit node-4
> > > > > > 
> > > > > > {
> > > > > > 
> > > > > > "name": "node-4",
> > > > > > 
> > > > > > "chef\_environment": "poc",
> > > > > > 
> > > > > > "normal": {
> > > > > > 
> > > > > > ```
> > > > > > "tags": [
> > > > > > 
> > > > > > ]
> > > > > > 
> > > > > > ```
> > > > > > 
> > > > > > },
> > > > > > 
> > > > > > "run\_list": [
> > > > > > 
> > > > > > ]
> > > > > > 
> > > > > > }
> > > > > > 
> > > > > > * * *
> > > > > > 
> > > > > > Thank you.
> > > > > > 
> > > > > > —
> > > > > > 
> > > > > > idzzy
> > > > 
> > > > --  
> > > > Best regards, Dmitriy V.
