networking - Mac OSX server command equivalent for dhclient?

  • John Hall

    Is there an MacOS command that makes a dhcp request, and renews the old lease, drops it for a new one, or usefully reports errors or lack of response from a dhcp server?

    This would both help fix networking on the machine after problems on the network without rebooting and would also be useful to diagnose wider networking problems from a mac.

    I can not find any command equivalent of dhclient though obviously some component must be serving this purpose. The question is, is that component exposed to a command line interface?

    I am biased to the command line for these features and may have overlooked settings panels or tools that might solve it using a gui interface.

    I believe this question is at the heart of this other question: Is there an equivalent command for 'init.d/networking restart' in OS X

  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    VMWare Workstation w/Ubuntu 10.04 Server: DHCP Issues
  • darvids0n

    Hey all. Bit of a possibly simple DHCP issue with my Ubuntu 10.04 Server (VMWare Guest). When I sudo dhclient eth0 it sends out plenty of DHCPDISCOVERs but doesn't get any DHCPOFFERs back from the router. Ping commands at this stage show connect: Network is unreachable.

    Breakdown of the situation and troubleshooting I have already tried is below:

    Previously: Ubuntu 8.04 Server was working perfectly with no modifications to package maintainer configs except aliasing in /etc/modprobe.d/aliases to disable IPv6.

    Network topology: VMWare Guest using a network bridge to share the host's adapter. Host computer (XP Pro SP3) has a DHCP-assigned address (bound to a MAC address in the router config, as is the virtual machine as well). Another PC on the network is Xubuntu 10.04 Desktop. Others are XP Pro SP3/Vista Premium SP2. No issues with DHCP on any of these, they are all set up for full autoconfig. All computers connected via the same switch to a Draytek Vigor2820n.

    Note: There is a DHCP issue with the Xubuntu 10.04 Desktop, which was temporarily solved by rm /etc/dhcp3/dhclient.conf, even though the .conf was the package maintainer's version. It's still broken, actually, nslookup works but firefox doesn't.

    What I can do: Ping IPs on the network if I set VMWare's Network Adapter setting to NAT (our network is 192.168.1.* and the NAT is 192.168.0.*; I could ping on both networks). The hostname doesn't appear in the router config though, and if you attempt to access the IP in e.g Firefox it seems to find something but times out (running Apache on the server so I was trying to access that). I can access the VM by hostname from its host computer in this state.

    Troubleshooting steps so far:

    • Installed winbind and added wins entry to /etc/nsswitch.conf on the hosts line
    • Blacklisted ipv6 in /etc/modprobe.d/blacklist.conf, aliased net-pf-10 to off, ipv6 to off in /etc/modprobe.d/aliases, set net.ipv6.conf.all.disable_ipv6=1 in /etc/sysctl.conf and rebooted. (interestingly, just now the VM didn't boot at all. smbd was terminating at startup because I had auto eth0 inet6 dhcp in /etc/network/interfaces)
    • Configured eth0 in /etc/network/interfaces with a static address/netmask/broadcast/gateway (similar to NAT, this allows me to ping by IP but it still doesn't register its hostname on the network. Interestingly enough, I can again access the VM by hostname from its host computer)
    • Changed /etc/dhcp3/dhclient.conf to send host-name "ubuntu" (that's the computer name) and request everything possible from the DHCP server (default config has it in there but it's commented out). I have since deleted dhclient.conf.
    • Set nameserver (the router) in /etc/resolv.conf (Not registering properly with the router means I can't ask it to resolve DNS queries. I think this is purely a side effect, though it may be indicative of a different issue).

    I can provide output of any any all commands/files on either the server or my desktop (Xubuntu 10.04). Current settings for dhclient (no file), network/interfaces (auto eth0, iface eth0 inet dhcp), resolv.conf (nameserver and nsswitch (hosts: files mdns4_minimal wins [NOTFOUND=return] dns mdns4) are sensible, unless we can find a way to resolve hostnames without WINS once DHCP is working.

    Output: ifconfig

    eth0      Link encap:Ethernet  HWaddr <MACADDR>
              inet addr:  Bcast:  Mask:
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:65027 errors:0 dropped:0 overruns:0 frame:0
              TX packets:19745 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:5230093 (5.2 MB)  TX bytes:2854793 (2.8 MB)
              Interrupt:18 Base address:0x1400 
    lo        Link encap:Local Loopback  
              inet addr:  Mask:
              UP LOOPBACK RUNNING  MTU:16436  Metric:1
              RX packets:136 errors:0 dropped:0 overruns:0 frame:0
              TX packets:136 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0 
              RX bytes:12688 (12.6 KB)  TX bytes:12688 (12.6 KB)

    To explain the acquired IP, right now I'm running it in "Host-only" mode just so that I can mount shares from the host computer to run processes which need to run in our business. If I set it to Bridged the output is the same minus the inet addr/bcast/netmask.

    Output: dhclient (v3.1.3)

    Listening on LPF/eth0/<MACADDR>
    Sending on LPF/eth0/<MACADDR>
    Sending on Socket/fallback
    DHCPDISCOVER on eth0 to interval 5
    DHCPDISCOVER on eth0 to interval 6
    DHCPDISCOVER on eth0 to interval 12
    DHCPDISCOVER on eth0 to interval 18
    DHCPDISCOVER on eth0 to interval 10
    DHCPDISCOVER on eth0 to interval 9
    DHCPDISCOVER on eth0 to interval 1
    No DHCPOFFERS received.
    No working leases in persistent database - sleeping.

    (I have also tried sending to with the same result)

    Thx in advance. Spent 3 days on this already so a different perspective is definitely welcome.

    Also recently installed a fresh Ubuntu 10.04 Server on the latest VMWare Player. Same issue out of the box. I'm in the process of setting up a VirtualBox VM, it's taking a while since I have to compile the Open Source Edition and so I need VC++ Express. I'll let people know how that goes.

    I'm stupid. The DHCP issue was resolved by disabling the firewall on the host. There's still a problem resolving DNS queries though.

  • Related Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.