2

So each time I restart my ubuntu server (virtual 10.04, via Xencenter), I have to call dhclient before I can access the internet:

http://img813.imageshack.us/i/dhclient.png/

What do I need to change to get internet access automatically? Apologies for posting images, I'm using Xencenter, so I can't copy/paste the console output

EDIT::

daniel@workwork:~$ cat /etc/network/interfaces 
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
    address 192.168.69.136
    netmask 255.255.255.0
    network 192.168.69.0
    broadcast 192.168.69.255
    gateway 192.168.69.1
    # dns-* options are implemented by the resolvconf package, if installed
    dns-nameservers 192.168.69.120
    dns-search workwork.com.au
daniel@workwork:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr ae:11:14:22:0a:03  
          inet6 addr: fe80::ac11:14ff:fe22:a03/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:32 errors:0 dropped:0 overruns:0 frame:0
          TX packets:85 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:10496 (10.4 KB)  TX bytes:13086 (13.0 KB)
          Interrupt:32 Base address:0x6000 

eth1      Link encap:Ethernet  HWaddr b2:2c:40:f2:a0:fa  
          inet addr:192.168.69.167  Bcast:192.168.69.255  Mask:255.255.255.0
          inet6 addr: fe80::b02c:40ff:fef2:a0fa/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:13448 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3100 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:7679428 (7.6 MB)  TX bytes:282286 (282.2 KB)
          Interrupt:36 Base address:0xa100 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:179 errors:0 dropped:0 overruns:0 frame:0
          TX packets:179 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:36905 (36.9 KB)  TX bytes:36905 (36.9 KB)

daniel@workwork:/var/lib/dhcp3$ cat dhclient.leases 
lease {
  interface "eth1";
  fixed-address 192.168.69.167;
  filename "boot\\x86\\wdsnbp.com";
  option subnet-mask 255.255.255.0;
  option routers 192.168.69.1;
  option dhcp-lease-time 28800;
  option dhcp-message-type 5;
  option domain-name-servers 192.168.69.120,192.168.69.121;
  option dhcp-server-identifier 192.168.69.120;
  option dhcp-renewal-time 14400;
  option dhcp-rebinding-time 25200;
  option domain-name "workwork.com.au";
  renew 5 2011/03/18 07:36:53;
  rebind 5 2011/03/18 11:35:39;
  expire 5 2011/03/18 12:35:39;
}
lease {
  interface "eth1";
  fixed-address 192.168.69.167;
  filename "boot\\x86\\wdsnbp.com";
  option subnet-mask 255.255.255.0;
  option routers 192.168.69.1;
  option dhcp-lease-time 28800;
  option dhcp-message-type 5;
  option domain-name-servers 192.168.69.120,192.168.69.121;
  option dhcp-server-identifier 192.168.69.120;
  option dhcp-renewal-time 14400;
  option dhcp-rebinding-time 25200;
  option domain-name "workwork.com.au";
  renew 5 2011/03/18 08:51:58;
  rebind 5 2011/03/18 12:24:16;
  expire 5 2011/03/18 13:24:16;
}
daniel@workwork:/var/lib/dhcp3$ cat dhclient.eth0.leases 
daniel@workwork:/var/lib/dhcp3$  

ifconfig eth1 before and after dhclient http://img692.imageshack.us/i/prepost.png/

Zeophlite
  • 125
  • 1
  • 5

2 Answers2

1

What's your /etc/network/interfaces file look like?

For DHCP, your interface should be configured like this:

auto eth0
iface eth0 inet dhcp

If that doesn't work, something's probably starting in the wrong order; you may be able to work around it by adding a dhclient command to /etc/rc.local.

Shane Madden
  • 112,982
  • 12
  • 174
  • 248
0

You might want to look at the lease (on my Ubuntu they're stored in /var/lib/dhcp3; look for *.lease file(s)); my guess is that one of your configuration settings — likely the DNS server — is wrong, and dhclient is correcting it from the DHCP lease. You can look at the saved lease and use it to update /etc/network/interfaces if needed.


Here's a sample dhclient lease record:

lease {
  interface "eth1";
  fixed-address 10.211.55.15;
  option subnet-mask 255.255.255.0;
  option routers 10.211.55.1;
  option dhcp-lease-time 1800;
  option dhcp-message-type 5;
  option domain-name-servers 10.211.55.1;
  option dhcp-server-identifier 10.211.55.1;
  option domain-name "localdomain";
  renew 3 2011/03/16 23:17:44;
  rebind 3 2011/03/16 23:32:10;
  expire 3 2011/03/16 23:35:55;
}
geekosaur
  • 7,025
  • 1
  • 19
  • 19
  • I've posted it above, what's next? – Zeophlite Mar 18 '11 at 06:54
  • Mm, only significant difference there is an additional DNS server — but the DNS server you listed is also the DHCP server, so that shouldn't matter. I think next is to compare `ifconfig eth1` output and (just in case) the contents of `/etc/resolv.conf` before and after running `dhclient`. – geekosaur Mar 18 '11 at 07:00
  • It does occur to me also that you might want to temporarily change the IP address in `/etc/network/interfaces`, reboot the VM, and ping the old one (by address, not name) before running `dhclient`, just in case Xencenter for some reason gave that address to another VM. – geekosaur Mar 18 '11 at 07:04
  • /etc/network/interfaces has auto eth0, but dhclient.leases has leases for eth1 - would this be related to the problem? – Zeophlite Mar 18 '11 at 07:26
  • ahhh, missed that — and yes, *very* likely. – geekosaur Mar 18 '11 at 07:28
  • I've added the output you wanted to the first point. It seems though that the auto thing is the main problem, how would I fix that? – Zeophlite Mar 18 '11 at 07:38
  • Change it to `auto eth1`, so the system isn't trying to send packets on `eth0` when nobody's listening. Or get the VM definition changed to not have a separate `eth1` which is the actual connection to XenServer but instead put it on `eth0`. (After finding out *why* it was set up that way.) – geekosaur Mar 18 '11 at 07:42