PDA

View Full Version : Newbie setup question (Mac)


jowie
07-04-2008, 01:06 AM
Hi there, newbie here :)

I'm wondering if anyone can help me. Our company has a Jabber server set up to work in and outside their firewall. Everyone seems to be able to connect okay except me... I'm on a Mac.

I've been given all the details (hostname, username, password, port 5222 etc). I've tried connecting using iChat, Adium and JabberFoX. None of them seem to be able to manage it!

I was wondering if I can do some telnet tests to find out what's going on... And so I did so through Terminal. Strange thing is, when I did:
telnet jabber.atticmedia.com 5222
it says:Trying 192.168.0.92...
A local IP adddress? Huh?

Am I missing something? Could I be having a firewall issue? Why do PCs work but Macs don't?

Thanks in advance!

Jehan
07-04-2008, 02:24 AM
I don't think this is because you are on a mac. Maybe at worse it is badly configured, but that's all.

About the IP first, you seem to think it is wrong. Is it? You said it is your server's company, so if you are running this in the local network, the name resolution probably gets it right and gives you the local IP (there is no need to leave on the internet to come back in the local network when you are already inside!). Yet if you are outside the local network, there is obviously an issue. If you are in such case, you should check a local address mapping which may take over the domain name service. If this is like GNU, check if you have the file /etc/hosts.
You may try also the command (if it exists also on mac):

nslookup jabber.atticmedia.com

Anyway even before all this, I wonder: what happened when you made the telnet? It says "trying", but did it fail? Or did it hold? And if it holds, could you make the simple test of typing some random characters, then Enter. If you are indeed on your Jabber server, then this one should answer with a XML element indicating an error, then close the connection.

If the connection does not hold or it holds but answers something else than XML, then it is not a Jabber server.

Kev
07-04-2008, 08:33 AM
You could also try Psi to connect, which might give more helpful error messages to help debug.

jowie
07-04-2008, 01:19 PM
I don't think this is because you are on a mac. Maybe at worse it is badly configured, but that's all.
That's good to know.

About the IP first, you seem to think it is wrong. Is it? You said it is your server's company, so if you are running this in the local network, the name resolution probably gets it right and gives you the local IP (there is no need to leave on the internet to come back in the local network when you are already inside!).
No, I am running outside the network (working from home).

Yet if you are outside the local network, there is obviously an issue. If you are in such case, you should check a local address mapping which may take over the domain name service. If this is like GNU, check if you have the file /etc/hosts.
You may try also the command (if it exists also on mac):

nslookup jabber.atticmedia.com
I wasn't sure what the GNU bit was about, but I could to the nslookup and I got this message:
Server: 192.168.0.1
Address: 192.168.0.1#53

Non-authoritative answer:
jabber.atticmedia.com canonical name = redbus-jabber.atticmedia.com.
Name: redbus-jabber.atticmedia.com
Address: 212.187.178.206


Anyway even before all this, I wonder: what happened when you made the telnet? It says "trying", but did it fail? Or did it hold? And if it holds, could you make the simple test of typing some random characters, then Enter. If you are indeed on your Jabber server, then this one should answer with a XML element indicating an error, then close the connection.
When I do my telnet command:
telnet jabber.atticmedia.com 5222
I get this back:
Trying 192.168.0.92...
telnet: connect to address 192.168.0.92: Host is down
telnet: Unable to connect to remote host

I'm wondering if it's some port forwarding/triggering stuff going on? I checked my router and I *did* have port triggering TCP/UDP for ports 5060-5678, but I just turned that off and it made no difference.

Thanks for your help!

jowie
07-04-2008, 01:22 PM
You could also try Psi to connect, which might give more helpful error messages to help debug.
Thanks - I just tried Psi but I can't seem to get it to do anything. I can't find a connect button and the XML console sits there showing nothing. :confused:

Jehan
07-04-2008, 02:35 PM
Hello you have obviously an issue because your telnet does not give the same answer as the nslookup. Moreover if you are on the web, the local IP is indeed obviously wrong, as you were thinking. I guess you are working from a laptop and that this one has been given from your company, hence configured by your administrator, aren't you? Most probably, he must have set some local lookup for the domain jabber.atticmedia.com.

What I was saying about the "hosts" file is that it is usually the place were you set custom name resolution (maybe can it be also set somehow else, but I am not a network expert). And this is often looked up in priority before querying the dns service.
So maybe in your case has it been set manually to 192.168.0.92 because your admin thought you would connect from the local network. A small search on the internet gave me that apprently this file is located here on a mac: /private/etc/hosts
So edit this file and if you have a line with this domain name, comment it (add a '#' in front of the line, probably same as on Linux) or remove it.

Anyway if you don't find this line, you can also simply replace the server address by its external IP in your Jabber client and this should work: 212.187.178.206

Make a test with:

telnet 212.187.178.206 5222


This method has only one drawback (which you may never know in most case): if ever the server does change its external IP address (this will probably never happen), then you will have to change this again in your jabber client.

P.S.: for the GNU thing, this is just a name you can replace by Linux, not to bother you (even though this is not exactly the same thing). Whatever I was dealing with the path of the "hosts" file and though it is a Linux file, its path is rather dependant of the filesystem hierarchy, which is again another standard (http://proton.pathname.com/fhs/)/entity on most GNU/Linux systems, but I don't know the hierarchy used by mac (but don't worry about this all... just complicated parts, many standards for one single OS at the end).

jowie
07-04-2008, 03:09 PM
Hi again,

Well I managed to telnet okay:
telnet 212.187.178.206 5222
Trying 212.187.178.206...
Connected to 212.187.178.206.
Escape character is '^]'.
lo
<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='none' from='jabber.atticmedia.com' version='1.0'><stream:error><xml-not-well-formed xmlns='urn:ietf:params:xml:ns:xmpp-streams'/></stream:error></stream:stream>Connection closed by foreign host.

So we know it works. I don't know if I've set up a strange domain lookup on this machine, but it is a personal machine and not setup by work. I have added some routes to connect to the VPN at work but I don't think I did the .92 one (I don't recall anyway!).

I found the "hosts" file in the bash shell, I just don't know how to open it and edit it ;-) any clues?

thanks again! :)

Jehan
07-04-2008, 03:22 PM
With a simple text editor, no? If this is the same way as Linux, it will be a simple text file (though I know some Unix system takes the bad habit of having configurations/exchange/save files in binary form! Why? I don't know, but this is not so smart. I hope mac doesn't do so, because then you will have to find the right tools to edit the file).

For my own I use vim for everything and there is a mac version: http://www.vim.org/download.php
It is a very powerful tool but if you are not a developper or administrator, probably this will be a scary editor. Anyway you probably have a default mac text editor, no? According to wikipedia, this is the one bundled in standard with MacOSX: http://en.wikipedia.org/wiki/TextEdit
Or can't you access through a file navigator and double click the file? Mac can select a text editor for you this way, no?

jowie
07-04-2008, 03:23 PM
Well I've found the "hosts" file, and for some reason it has been added to that! How did that happen!

192.168.0.92 jabber.atticmedia.com
However, I cannot edit and save the file in the Finder because I am not logged in as root. So how may I edit it in the bash shell? I am logged in as root there.

Do I need to reboot after making the change or is it instant?

Thanks!

jowie
07-04-2008, 03:47 PM
With a simple text editor, no? (snip)
No sorry, I just meant in the BASH shell - I thought there was a way of editing a file there. The problem is that if I edit the file through TextEdit in the Finder I am not logged in as root. I can login as root really easily through the shell. Otherwise I have to reboot in a weird way to get to the root in the Finder.

Any ideas? I just tried using Vim and it confused the hell out of me!:eek:everything I did made my computer beep and I nearly ended up deleting half the file. Maybe I should read the help...

jowie
07-04-2008, 04:03 PM
Okay so I finally managed to get it sorted - thanks for everybody's help! :)

I edited the file in Vim (once I worked out how) and, hey presto, it started working. I have no idea what I must have done in the past, or whether it's possible that one of my chat software packages added that to my hosts file, but suffice it to say it has now been removed and I am cooking on Jabber Gas.

Thanks again! :D

Jehan
07-04-2008, 04:06 PM
Yes don't use vim. It was a bad idea telling you about it. It is not complicated, but complex it is obviously. So when you don't know what you do, you may make mistakes.
Anyway you can probably run textedit from the shell, hence with the root user. Try maybe the command:

textedit host


But what is sure is that we have found the problem. Once this line removed, all shall be great. :-)

Edit: ok I looked on the web:
http://www.westwind.com/reference/OS-X/commandline/text-files.html
Apparently you probably has "vim", "emacs", "pico" already by default (vim and emacs being the most powerful, but I guess pico will be sufficient for just removing a line ; -).
And apparently there exists also a command called "open" which is the one opening textedit:
http://www.westwind.com/reference/OS-X/commandline/text-files.html
So when logged as root in the shell, if you run "open", this will open textedit with root rights. (why having not chosen "textedit" as name of the command line... I don't know! Too obvious probably. But maybe both exist and are equivalent)

jowie
07-04-2008, 04:10 PM
I tried the textedit host thing but it didn't work. I tried a few variations such as TextEdit and TextEdit.app but none worked. I even tried going to the Applications folder and doing it from there. I'm guessing because the app is not recognized by Unix then it cannot launch it.

But luckily with a bit of fiddling, I managed to edit the file in Vim. I have no idea how though! ;)

Jehan
07-04-2008, 04:15 PM
I tried the textedit host thing but it didn't work. I tried a few variations such as TextEdit and TextEdit.app but none worked. I even tried going to the Applications folder and doing it from there. I'm guessing because the app is not recognized by Unix then it cannot launch it.

But luckily with a bit of fiddling, I managed to edit the file in Vim. I have no idea how though! ;)

Ok perfect. For information (so that you will know for the future how to use textedit as root), look at my "edit" in the previous post. I found this on the web. Foolishly Apple chose the name "open" to use textedit (probably for the case where they change their default editor, they wanted a generic name).

jowie
07-04-2008, 04:25 PM
Thanks for the info, that's great to know!

Unfortunately however, the "open" command isn't clever enough to open it in the scope of root... Therefore it opens lovely, however I cannot save it because I do not have access privileges.

Jehan
07-04-2008, 04:40 PM
Ok. In that case, I would say it is the opposite: if -- being logged as root -- you run "open" and it opens textedit as non-root, then it means the open command is too "clever" because it has been configured not to open as root (basically a command run with a login does not change this login!). Probably some "safety" guard set by Apple to prevent errors from uncareful users.
But ok. You know the other editors now. :-)

jowie
07-04-2008, 04:47 PM
yes thanks, however emacs and pico don't work under root :(
Error opening terminal: network.

Nicholas Jordan
07-04-2008, 05:21 PM
(...snip...) I nearly ended up deleting half the file. Maybe I should read the help...

Occasionally do a file rename on the folder where everthing is and put the folder back and copy all the contents back or copy everything verbatim over to a backup folder having a naming convention:

folder[0]
folder[1]
folder[2]
folder[3]
...
...
...

With terabyte drives now available and left over drives in the gigabyte range, there is just absolutely no reason to totally lose a project. No need to compress or anything with the disk room that sits unused making this approach like putting a cup of coffee in a lake.

zeller
07-04-2008, 05:29 PM
use `sudo nano -w /etc/hosts`
enter your user's password
then after you delete the line press ctrl-o, and then ctrl-x to save and exit the editor

zeller
07-04-2008, 05:35 PM
So when logged as root in the shell, if you run "open", this will open textedit with root rights.
the 'open' command in the terminal is the same as if you double clicked on the items icon in the finder. Thus `open /Applications/TextEdit.app` is how you would open TextEdit from the terminal. Unfortunately after Mac OS X 10.1, Apple removed the ability to run gui applications in root mode unless you're specifically logged in as root. So even if you use the open command with sudo, it opens the application with your users privileges.

jowie
07-05-2008, 12:46 PM
Ah well.... I can fast user switch to root, then open it up in the GUI there if necessary.

The main thing is that I've managed to comment out that bizarre line in my hosts file, so thanks to you all for your help! :)

msandersen
08-14-2008, 08:55 AM
I just tried sudo open /Applications/TextEdit.appunder Leopard and it worked. Didn't try to save anything in a restricted location though, and don't wanna mess with the hosts file.
If you change into the directory first, you can do:cd /Applications
sudo open TextEdit.app
Anyway, as mentioned, you can also use sudo pico -w /private/etc/hostswhere -w is "no line wrap". Pico is a variant of Nano, both are available in OSX.