4

I'm using Ubuntu 12.04 LTS, but I need to run the following command:

sudo dhclient

after startup to acquire a stable ethernet connection. I am running dhclient during startup already, through the /etc/rc.local file.

Someone please help me run this command after-startup automatically (by removing it's requirement for root, or some other means), or suggest a different way of troubleshooting my ethernet connection.

8
  • 1
    Can you give us the output of the command ifconfig after you have rebooted (but before you've run sudo dhclient), and again after you have run sudo dhclient? It sounds like you may have an IP address incorrectly configured/not configured for DHCP on your network interface. May 18, 2012 at 5:52
  • Make sure you types the password correctly for your wireless ;)
    – Rinzwind
    May 18, 2012 at 6:08
  • rc.local is executing with root permission, so you dont need to use a sudo. Is everything alright in your Network Manager? You can try to remove Network Manager and configure a /etc/network/interfaces
    – us3r
    May 18, 2012 at 6:43
  • a) it's wired, see "ethernet" b) rc.local isn't working, I think it's because it's running dhclient before the system is fully booted. That's why I'm trying to run it immediately after boot, or login c) I think something is definitely wrong with my Network Manager, but I don't know how to follow your instructions, could you be more precise?
    – rofls
    May 18, 2012 at 6:55
  • Will do, ~5 minutes.
    – rofls
    May 18, 2012 at 6:56

2 Answers 2

5

One workaround would be to use rc.local with a sleep command. Put the following into /etc/rc.local:

(sleep 60; dhclient) &

This will make the command wait for 60 seconds before being executed, which should allow enough time for your machine to finish booting.

0

You can create a Custom script to start or stop services and make it executable at startup, i don't have experience in writing codes so please refer this official Guide look up Installing custom init-scripts

2
  • Yeah, but I think those run during boot, by default, though I could be wrong. Thanks though!
    – rofls
    May 18, 2012 at 7:05
  • 1
    Welcome to Ask Ubuntu! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – Mahesh
    May 18, 2012 at 17:48

You must log in to answer this question.

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