0

I have installed CentOS7 in virtualbox through vagrant. Both guest and host operating system is CentOS7. Guest operating system is minimum installation of centos7 with no graphics. On both system I have installed Firefox through sudo yum install firefox. On guest operating system some django project is running. I want forward Firefox window from guest to host operating system.

For this I ran ssh -X vagrant@127.0.0.1 -p 2222 on Host operating system and on Guest operating system ran 'firefox'. Guest operating system gives result Error: cannot open display: :0.

In host operating system

[neelabh@localhost ~]$ echo $DISPLAY
localhost:0.0

In guest operating system

[vagrant@localhost ~]$ echo $DISPLAY
localhost:0.0

ifconfig of guest operating system

[vagrant@localhost ~]$ ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.2.15  netmask 255.255.255.0  broadcast 10.0.2.255
        inet6 fe80::a00:27ff:feea:9bb5  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:ea:9b:b5  txqueuelen 1000  (Ethernet)
        RX packets 1193  bytes 122490 (119.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 787  bytes 108164 (105.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.50.4  netmask 255.255.255.0  broadcast 192.168.50.255
        inet6 fe80::a00:27ff:fe55:8a8c  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:55:8a:8c  txqueuelen 1000  (Ethernet)
        RX packets 135  bytes 46673 (45.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 44  bytes 7250 (7.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 79  bytes 4634 (4.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 79  bytes 4634 (4.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:18:df:5a  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Network setting of VM

enter image description here

  • @Anthon Thanks for reply, from where I will get variable Display.. – geeks Sep 2 '15 at 6:01
  • @Anthon In host operating system echo $DISPLAY gives localhost:0.0 and in guest operating system echo $DISPLAY also gives localhost:0.0 – geeks Sep 2 '15 at 6:06
0

If you do:

ssh -X vagrant@127.0.0.1 -p 2222

You are connecting to the host on port 2222, not to the guest. You should login to the guest os using

ssh -X vagrant@10.0.2.15

and then run firefox after being logged in. You might have to set your network to bridged interface, I never use NAT on my guests' setup and I think that might block routing from the host.

I can also recommend to not name a machine localhost and have your computer name in your prompt.

|improve this answer|||||
0

I just install x-server on guest os by running following line. Now if we open firefox on guest os then it will redirect to the host operating system. There is only one problem that one terminal tab will always engage with firefox.

sudo yum groupinstall "X Window System" "Desktop" "Desktop Platform" 
yum install gdm
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.