Or, “How To Fix Your Ubuntu Linux Server When You Can’t For The Life of You Figure Out Why The Flip It Won’t Ping or Talk to the Internet….”
Imagine the scenario: you’ve just completed a shiny new installation of Ubuntu Server on your HP DL380 G5 machine, ready to take on the world with whatever new and inventive web application you’re about to launch. You’re just about to drive to Lapland to plonk your server next door to Facebook’s new datacentre, when you stumble across a problem. It doesn’t work.
What could be causing this? The IP settings are all correct, DNS server is live, gateway correct…. but sudo apt-get update just fails, and an attempt to ping a working web site gets nowhere, not even a resolution of its IP address. Perhaps you were mid-coffee-sip when the installation detected your network ports and has assigned eth0 to that extra network card you’ve put in to use for a DMZ or other connection? So you’ve been into the etc/network/interfaces file and updated it, and restarted networking, but still to no avail?
Well, this very scenaraio happened to a guy I know just this week. He shall remain nameless, but he did a lot of Googling around and finally found a solution which worked. Ubuntu Server has some useful security defaults which protect you from accidentally giving all your data to the bad guys – which is clearly a good thing. They may also have shares in coffee manufacturers due to the amount that gets drunk whilst fixing problems (“learning”), but that’s a different issue. So when you change to use a different network card, it sees that this has a different MAC address from the first one, and it deliberately doesn’t make any assumptions about its configuration which would end up placing your data on the wrong side of your firewall.
So, to clear out its previous configuration and let it reconfigure for your new card, delete the configuration file by running this command:
sudo rm /etc/udev/rules.d/70-persistent-net.rules
Then, reboot your server and – hey presto! – it should all work. At least, this is what I did and it worked for me (errr… I mean the guy I know. The one who remained nameless) and credit goes to the fellas in the forum linked above.
We’re all still learning every day (most of all me) so if you’re reading this and thinking “what on earth is this guy on about?” then please correct me and share the knowledge in the comments section below!
Thank you. After moving my Ubuntu server hard drive from my old dead Shuttle to shiny new Shuttle my network connection (understandably for the reasons described) stopped working. After hunting around for a solution, simply deleting 70-persistent-net.rules and rebooting automatically reconfigured everything.