I.T. Security and Linux Administration

Mar 2 2012   11:49AM GMT

OpenVZ and Ubuntu: No loopback adapter

Eric Hansen Eric Hansen Profile: Eric Hansen

For the past few months I’ve been working hard at getting my own business started and going.  Its definitely been a ride, and have learned a lot about business and I.T. that I didn’t think I’d ever touch on.  One of those I.T. aspects involves OpenVZ and their Ubuntu template (I use 11.04 x86), and the disappearance of lo, or the loopback adapter.

The background to this is I bought two VPS servers @ $7/month each.  Now, I’ve never really touched a VPS before, as my servers have always been right next to my desktop.  I did it this way, however, because I needed to install a different OS on my home server.  I found a great host, and got everything set up.

What I was failed to be informed of, however, is that the Ubuntu template for OpenVZ can cause the loopback adapater to not be visible in the VZ.  What this is means is that anything requires connecting to 127.0.0.1 will completely fail.  On the other hand, there is 127.0.0.2, and most programs have no issues using that instead.  However, I ran into two VERY big issues with the lack of a loopback: Postfix would not work, and you could not telnet to anything.

Postfix

Postfix is a very interesting MTA.  Basically I had it set up via virtual hosting, so all the account information was stored in a database instead of a flat file.  Earlier in the day I had it working flawlessly.  I could connect via IMAPS and send mail via Postfix without any issues.  Then, I restarted the VPS, and that’s when the troubles started.

I originally thought the issue was because, after I discovered no more loopback, that the host was set to 127.0.0.1 and not localhost when it came to connecting to MySQL.  When Postfix was trying to connect, there would be errors such as “Unable to connect to MySQL via socket” and messages about some of Postfix’s components not working properly.

Telnet

With the invention of SSH, who would use telnet, eh?  Well, I use it a lot to test systems (i.e.: web and e-mail), to make sure they work as they should.  I’m still not sure personally how telnet stopped working due to no loopback, unless telnet creates a connection on the host on the loopback adapter, but that would kind of foil the point of connecting to an external source, wouldn’t it?

I figured it would make sense that I could not connect to 127.0.0.1 since there’s no loopback, but when I had MySQL listening on 127.0.0.2 instead, I still could not connect to MySQL (which is possible, just get a lot of weird garbage).  Even connecting to the public IP for web resulted in nothing.  Just a hanging at “Connecting to [ip]…”

Resolution

After spending numerous (literally) hours trying to find a solution and almost deciding to give up and restore from a backup earlier in the day, I came across a post on the OpenVZ forums.  This is where I learned that its because of a poorly done template that conflicts with Ubuntu’s network management scripts and such.

In short, the resolution is simple, all you have to do is run the following command: ifdown lo && ifup lo

This turns off (or disables) the adapter and then re-enables it.  Once I did this, localhost was back home, Postfix worked flawlessly again and telnet was connecting like a champ.  I then decided to create an alias for this in my root’s .bashrc file: alias lo_reset=’ifdown lo && ifup lo’

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: