1

I have this in etc/network/interfaces :

auto eth0
iface eth0 inet static
address 192.168.1.119
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4

I don't use network manager.

ifdown eth0 && ifup eth0 does not update my ip.

But the update is done if I reboot.

What am I missing ?

6
  • You haven't said much about your environment. It could be that in your down/up is fast enough to request the same IP, while a restart takes long enough that another client gets the IP. May 2, 2017 at 18:40
  • It's kali linux. I'm alone in my environment. No one gets the ip I'm requesting. But if I'm doing ifconfig -a, I still see the interface with the ip. Normal ?
    – trogne
    May 2, 2017 at 18:43
  • Oh, is the issue that ifconfig is not matching your file? May 2, 2017 at 18:51
  • yes, ifconfig doesn't not show the IP address I'm requesting
    – trogne
    May 2, 2017 at 18:55
  • Perhaps ifup is failing to parse your config for some reason. Can you simplify the config slightly by removing the network and broadcast stanzas and split the DNS config into two statements dns-nameservers 8.8.8.8 and dns-nameservers 8.8.4.4. It may also be useful using the --verbose flag when using ifdown and ifup to see if you get any additional information. May 2, 2017 at 19:24

2 Answers 2

3

I had first to turn down the interface, ifdown eth0.

Then edit the file /etc/network/interfaces, changing the ip.

And only then, turn up the interface, ifup eth0.

This way, it always works.

I guess that when using ifdown eth0 && ifup eth0 after editing the /etc/network/interfaces file, it seems that the ifdown eth0 doesn't have the right data to turn the interface down correctly.

1
  • 2
    If it was DHCP before you made your edits, then the ifdown tool doesn't know it needs to stop the dhcp daemon. It is kinda stupid like that. You could have also manually killed the dhcp client process. Stopping the interface, then making changes is a good option though.
    – Zoredache
    May 2, 2017 at 23:30
1

Maybe you can try

service networking restart

That will restart network interfaces reloading parameters in /etc/network/interfaces.

You can also use sysctl, but service still works.

7
  • It does not work, like ifdown/ifup.
    – trogne
    May 2, 2017 at 19:09
  • Just a silly question.. but are you have the proper administrative rights? Perform the command as root or using sudo.
    – patan90
    May 2, 2017 at 19:16
  • sudo service networking restart or service networking restart as root.
    – patan90
    May 2, 2017 at 19:16
  • I'm already root.
    – trogne
    May 2, 2017 at 19:16
  • Can you post the entire file? Does you get any error when restarting the service? Just to try. remove network 192.168.1.0 and broadcast 192.168.1.255 parameters, the are not generally needed.
    – patan90
    May 2, 2017 at 19:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .