2

I have a static IP set on my web-server. When I change static to dhcp the server needs to be reboot for the changes to take effect. Is there any way to make it so I can use ifdown and ifup to change it?

I know that it should work because I have had a server that was able to be changed from static to dhcp without rebooting. I am just not sure if I am missing something.

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 10.8.105.8
netmask 255.255.0.0
gateway 10.8.1.1

auto eth1
iface eth1 inet static
address 169.254.1.1
netmask 255.255.0.0

To set it to to dhcp I change the iface eth0 inet static to iface eth0 inet dhcp

I am also running into an issue of slow boot times when I declare eth1 as another interface as it is.

Added info

default via 10.8.1.1 dev eth0 metric 100
10.8.0.0/16 dev eth0 proto kernel scope link 10.8.105.8
169.254.0.0/16 dev eth1 proto kernel scope link src 169.254.1.1
169.254.0.0/16 dev eth0 scope link metric 100
Keith
  • 227
  • 4
  • 12
  • try this [I need to reset my computer's ip address to dhcp from static](http://askubuntu.com/questions/178970/i-need-to-reset-my-computers-ip-address-to-dhcp-from-static) – Lety Oct 06 '14 at 18:27
  • @Letizia the `sudo /etc/init.d/networking restart` ran but did not switch my network to a `dhcp` address when it is declared as `dhcp` – Keith Oct 07 '14 at 15:20
  • Could you describe what you did to change static to dhcp and post /etc/network/interfaces file content? – Lety Oct 07 '14 at 15:54
  • Did you use `ifdown eth0` and `ifup eth0`? – Lety Oct 07 '14 at 22:53
  • @Letizia Yes, that is what I normally use but sometimes I get this error `RTNETLINK answers: File Exists` I have another post trying to solve that but they could very well deal with each other. – Keith Oct 08 '14 at 11:51
  • `/etc/network/interfaces` posted is complete or there are other directive related to eth1? In particular is there a gateway definition for eth1? – Lety Oct 08 '14 at 18:08
  • @Letizia that is the complete file. I do not need to have a gateway on the eth1 since it is a local network communicating to a few devices. I have heard a gateway conflict can cause slow boot issues. – Keith Oct 08 '14 at 18:10
  • Did you modify `/etc/dhcp/dhclient.conf`? – Lety Oct 08 '14 at 18:52
  • @Letizia I have not. Mine in empty – Keith Oct 08 '14 at 18:58
  • Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/17724/discussion-between-letizia-and-keith). – Lety Oct 08 '14 at 20:42

1 Answers1

2

What about using

sudo ip addr flush dev eth0

would that force the interface to pick up a new address?

ChrisL
  • 21
  • 3
  • It seemed to work. I had to follow that command by a `ifdown eth0` and an `ifup eth0`. It did however work so let me do some more situational testing on it. – Keith Oct 13 '14 at 11:56
  • Good! If it works, could you post `ip route` output after flush? I'm curious to know how it changes. – Lety Oct 13 '14 at 22:03