Configuring NAT and X11 for VMWare Fusion running Debian Etch
By Chee Ming on Jul 6, 2008 | In Technical, Exoweb, Mac OSX | Send feedback »
It would be so much easier to use "bridged" networking but sometimes it doesn't work properly with some wireless setups and we have to use NAT instead. But one problem I had was to configure the setup so that the host machine can access the guest machine easily.
I don't do this very often and I remember that I have to spend quite a bit of time searching the web to find the answers I am looking for. So I am going to write a bit about this so that it might help someone (or even myself) in the future.
At Exoweb, we do a lot of our development on the Debian distro so I have a VMWare Fusion virtual machine running Debian Etch. I want ssh access to the machine but how am I going to connect to it? You need to configure the natd that is running on your host machine, (in my case its the Macbook Pro) so that you can connect (ssh) to the guest machine that is connected to a virtual network created by VMWare Fusion.
Run the following command in Terminal, and you should get some similar output:
silviana:~ cheeming$ ps aux | grep vmnet-natd
cheeming 43558 0.2 0.0 75492 392 s001 R+ 12:54PM 0:00.00 grep vmnet-natd
root 38501 0.0 0.0 75924 312 ?? Ss Fri05PM 0:04.05 /Library/Application Support/VMware Fusion/vmnet-natd -c /Library/Application Support/VMware Fusion/vmnet8/nat.conf -m /Library/Application Support/VMware Fusion/vmnet8/nat.mac -d /var/run/vmnet-natd-vmnet8.pid vmnet8
You need to edit the configuration file that is used by vmnet-natd and in my machine its /Library/Application Support/VMware Fusion/vmnet8/nat.conf. Open the file in your favourite editor and check the [incomingtcp] section. There should be some comments about SSH, you can add a line that looks like the following:
... [incomingtcp] ... # lots of comments ... 8889 = 192.168.102.128:22 ...
What is config means is that for port 8889 on host machine point it to IP address 192.168.102.128 (insert your guest machine IP address here) at port 22. Save the file and then restart the VMWare networking stuff with the following command:
silviana:~ cheeming$ sudo "/Library/Application Support/VMWare Fusion/boot.sh" --restart
Once that is done, try the following:
silviana:~ cheeming$ ssh -p 8889 -X localhost
And you should be able to access to your guest machine from your host machine's terminal.
You'd notice that I included a "-X" option because I wanted to run some GUI apps as well. I also had some issues with it and initially thought it was due to the firewall but it wasn't.
After I posted this article, Martin, a fellow Exomate, wrote an e-mail to me explaining a proper way to do this and after that I did a few more experiments and realised that I didn't need to configure anything at all. I don't know what I did earlier to fix it but I am pretty sure I had problems the first time around. Instead of using ssh's -X command line. Its better to use -Y as such ssh -p 8889 -Y localhost. Here are some tips that Martin gave me: Before connecting to the remote host, try and run xlogo. It should work.
If it doesn't check the DISPLAY environment variable. On my machine it looks something like this: /tmp/launch-7t2bMS/:0. So then ssh into the remote machine as indicated before and then try and run xlogo again. And again it should work. If it doesn't then something is up, try checking the DISPLAY environment variable. It will look something like this: localhost:10.0.
Also, the method that I outlined below is not encrypted and should be avoided unless you know what you're doing. Many thanks Martin for clearing this up. But I am still not sure what happened to my setup earlier. Why didn't it work before?
The following section till the end has been deprecated:
I've been playing around with git and wanted to run gitk in VMWare Fusion but I got the following error:
cheeming@ccmdebianetch:~/trunk-git$ gitk
Application initialization failed: no display name and no $DISPLAY environment variable
Error in startup script: invalid command name "image"
while executing
"image create bitmap tri-rt -background black -foreground blue -data {
#define tri-rt_width 13
#define tri-rt_height 13
static unsigned cha..."
(file "/usr/bin/gitk" line 1185)
I am not too familiar with X11 configs but I remember from attending an ExoForum that Russell had to run some commands to make things work properly and that memory actually helped me configured things quite easily with out needing to RTFM.
First, I had to set the DISPLAY environment variable to my host machines' IP (this it the IP address as seen by the guest machine in the virtual network created by VMWare, check ifconfig and look for vmnet8 device) like this:
cheeming@ccmdebianetch:~/trunk-git$ export DISPLAY=192.168.102.1:0
cheeming@ccmdebianetch:~/trunk-git$ gitk
Xlib: connection to "192.168.102.1:0.0" refused by server
Xlib: No protocol specified
Application initialization failed: couldn't connect to display "192.168.102.1:0"
Error in startup script: invalid command name "image"
while executing
"image create bitmap tri-rt -background black -foreground blue -data {
#define tri-rt_width 13
#define tri-rt_height 13
static unsigned cha..."
(file "/usr/bin/gitk" line 1185)
Hmm, something is still up. And I did the following (on the host machine), again based on what I remembered from ExoForum, but this time had to use the man a bit.
silviana:~ cheeming$ xhost 192.168.102.128 192.168.102.128 being added to access control list
I tried running gitk again and it worked. Hope this has been helpful.
Trackback address for this post
Trackback URL (right click and copy shortcut/link location)
No feedback yet
Comments are not allowed from anonymous visitors.
| « EuroPython 2008 in Vilnius | Meeting Monica » |
