2

When I change network from dhcp to static, it will periodically change IP to the dhcp configuration and ignore the configuration of /etc/network/interface.

So I want to remove the dhcp-client, however when I remove it in Ubuntu, I encounter this problem. Can you give me some help ?

$ sudo apt-get remove dhcp-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
**Virtual packages like 'dhcp-client' can't be removed**
0 upgraded, 0 newly installed, 0 to remove and 77 not upgraded.

this is my interface file content:

auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 10.0.0.7
netmask 255.255.255.0
gateway 10.0.0.1
# This is an autoconfigured IPv6 interface
iface eth0 inet6 auto
4
  • Can you post your /etc/network/interfaces file?
    – Chida
    Aug 14, 2012 at 5:03
  • i have post my interface file
    – rgc
    Aug 14, 2012 at 7:07
  • See my answer below to update the interfaces file
    – Chida
    Aug 14, 2012 at 7:14
  • I've seen this on a bunch of systems I was in the process of setting up recently after manually editing /etc/network/interfaces and restarting networking, I kept seeing hosts disappear. As I hadn't commissioned the systems, I was able to reboot them, which solved the problem.
    – Bryan
    Nov 19, 2012 at 9:04

5 Answers 5

2

I never had Ubuntu behave like this, so this is just a wild guess: It could have something to do with 'network-manager'.

As to the removal of dhcp-client:

You are trying to remove a virtual package. Virtual packages don't really exist they are just provided by some packages to declare they provide a similar service/function (see also Debian Policy Manual). IIRC the default dhcp-client package installed by ubuntu is 'isc-dhcp-client', but no mater which one is installed on your system you probably will have a rather hard time removing it cleanly as quite some other packages depend on it being installed.

1
  • actually, what you have said is right, i can remove isc-dhcp-client from my ubuntu, and i learn about what is virtual package, thank you! I will see whether if dhcp-client cause this problem.
    – rgc
    Aug 14, 2012 at 7:16
2

You probably didn't take the interface down before reconfiguring it, and so there is still a DHCP client running in the background trying to maintain the DHCP IP. Check for this with ps -eF | grep dhclient and kill the process.

If you really want to uninstall the DHCP client (which you shouldn't need to), you need to remove the dhcp3-client package.

1
  • when i type this in terminal : ps -eF | grep dhclient. it shows nothing, and i also sudo apt-get remove dhcp3-client, it shows that i did not install it any more.
    – rgc
    Aug 14, 2012 at 7:11
1

You need to remove the isc-dhcp-client completely. If DNS-server addresses are configured both in the isc-dhcp-client and in /etc/network/interfaces file the addresses in the client configuration always take precedence and will be the ones that are written to /etc/resolv.conf. If you want the dns-servers setting in /etc/network/interfaces to be written to /etc/resolv.conf you will have to remove the isc-dhcp-client completely.

The apt-get --purge remove isc-dhcp-client isc-dhcp-common command will do just that. If that does not do the trick find and remove these two files:

/run/resolvconf/interface/eth0.dhclient and /run/resolvconf/interface/original.resolvconf

0

This is the problem line,

iface eth0 inet dhcp

Remove it and restart your networking.

$ sudo service networking restart
2
  • i am sorry, i have lost #, it was commented in interface file. when copy from file, i lost it.
    – rgc
    Aug 14, 2012 at 7:20
  • 1
    This is ineffective in 12.04 or 12.10. As mgorven pointed out, dhclient is still running in the background.
    – blee
    Nov 19, 2012 at 8:07
0

I've got the same problem. My not so scientific test found this solution. Put network and broadcast in interace config too. Like this:

auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
address 10.0.0.7
network 10.0.0.0
broadcast 10.0.0.255
netmask 255.255.255.0
gateway 10.0.0.1
# This is an autoconfigured IPv6 interface
iface eth0 inet6 auto

You must log in to answer this question.

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