How to access Linux Host from XP Guest when Host use DHCP ?

Discussions related to using VirtualBox on Linux hosts.
Post Reply
cpravia
Posts: 2
Joined: 22. Nov 2007, 04:28

How to access Linux Host from XP Guest when Host use DHCP ?

Post by cpravia »

Hi to everyone, I have a VBox running a XP Guest in a Ubuntu Gutsy Host.

I want to install a LAMP in the Ubuntu Host and access it from the XP Guest (for web development purposes I need to see the websites in different browsers and maybe use dreamweaver to edit the pages in Apache using ftp from the guest to the host).

I know this is possible using the NAT VBox default configuration, the XP can see the Linux using its IP, but the host is a laptop using DHCP to connect two different WiFi networks during the day by day use (one from the office and other from home).

Is it possible to access the Host from the Guest using the Host name instead of the IP even if the Host dont have a DHCP server to get the IP or a DNS server?

What I try to do is to set in the dreamweaver all the websites in the host Apache without have to change the ip every time I change of DHCP or even if I dont have an Internet connection.

How can accomplish this?

Thanks a lot at advance,

Carlos
SchlaWiener
Posts: 18
Joined: 3. Sep 2007, 17:47

Post by SchlaWiener »

the easiest (not the most elegant) solution is to edit the host file.

Open the file c:\windows\system32\drivers\etc\hosts with an editor

then you could create a line at the bottom like this:
192.168.2.123 myhost

after this "myhost" is resolved with 192.168.2.123.
If your host ip changes, you can update the value.



the second solution could be to setup a samba server on your linux box. Then the linux box should be resolvable through wins.
SchlaWiener
Posts: 18
Joined: 3. Sep 2007, 17:47

Post by SchlaWiener »

Another idea.

Configure your interface on the linux box to work with two adresses, one per dhcp and the other static.

syntax should be something like this:

auto eth0 eth0:1
iface eth0 inet dhcp
iface eth0:1 inet static
address 192.168.123.11
network 192.168.123.0
netmask 255.255.255.0

(to do so just edit the /etc/network/interfaces file on your linux box. backup first)

Notice that eth0:1 has no gateway.
After that you give your windows guest an additional ip 192.168.123.12 and both, host and guest should be able to access each other.
Ingo
Volunteer
Posts: 731
Joined: 22. Aug 2007, 10:13
Location: Germany

Post by Ingo »

SchlaWiener wrote:Configure your interface on the linux box to work with two adresses, one per dhcp and the other static.
Very interesting.
If you use this please tell me if it works.

I would prefer a virtual device tap0. You have a distinct separation from your physical device and there is no need for a bridge or so if you only want to connect to your host.
cpravia
Posts: 2
Joined: 22. Nov 2007, 04:28

It Works !! Thanks !!

Post by cpravia »

Excellent, I follow your suggestion and work just fine:

1- I edited the /etc/network/interfaces with eth0:1 usign an static IP 192.168.2.123.
2- I edited c:/windows/system32/drivers/etc/hosts with that direction as myhost
3- Reboot both host and guest
4- Test Linux internet and intranet connection, good, Test guest internet connection, good. and guest connection to myhost and work fine !

Thanks a lot SchlaWiener !!

Ingo, your suggestion is use a virtual device, does it means use a internal network in the vbox settings? I havent test it because I though NAT will be fine but I dont know if there is additional advantages using a virtual device instead of the solution above.
Ingo
Volunteer
Posts: 731
Joined: 22. Aug 2007, 10:13
Location: Germany

Post by Ingo »

That way using a second logical interface (eth0:1) to the physical device (eth0:0) is simple and very good and works with NAT. No need setting up a tap device because it only works with Host Interface Networking and is a little bit more complicated.
lando
Posts: 73
Joined: 3. Jan 2008, 23:52

Post by lando »

SchlaWiener wrote:Another idea.

Configure your interface on the linux box to work with two adresses, one per dhcp and the other static.

syntax should be something like this:

auto eth0 eth0:1
iface eth0 inet dhcp
iface eth0:1 inet static
address 192.168.123.11
network 192.168.123.0
netmask 255.255.255.0

(to do so just edit the /etc/network/interfaces file on your linux box. backup first)

Notice that eth0:1 has no gateway.
After that you give your windows guest an additional ip 192.168.123.12 and both, host and guest should be able to access each other.
I 've tried this solution but doesn't work...Could have I mistaken something...
Ubuntu network works fine as before , but doesn't see WinXP guest ,so WinXP doesn't see ubuntu .
After that you give your windows guest an additional ip 192.168.123.12 and both, host and guest should be able to access each other.
How have I to do ?
Thanks a lot


PS- My Ifconfig ....
lando@Lando-917e83357:~$ sudo ifconfig
eth0 Link encap:Ethernet HWaddr 00:1B:FC:B5:54:F4
inet addr:192.168.1.9 Bcast:255.255.255.255 Mask:255.255.255.224
inet6 addr: fe80::21b:fcff:feb5:54f4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6474 errors:0 dropped:0 overruns:0 frame:0
TX packets:6545 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:1828321 (1.7 MB) TX bytes:664653 (649.0 KB)
Base address:0xc000 Memory:f9ec0000-f9ee0000

eth0:1 Link encap:Ethernet HWaddr 00:1B:FC:B5:54:F4
inet addr:192.168.123.11 Bcast:192.168.123.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Base address:0xc000 Memory:f9ec0000-f9ee0000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:179 errors:0 dropped:0 overruns:0 frame:0
TX packets:179 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:14292 (13.9 KB) TX bytes:14292 (13.9 KB)

ppp0 Link encap:Point-to-Point Protocol
inet addr:87.11.47.45 P-t-P:192.168.100.1 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1492 Metric:1
RX packets:6362 errors:0 dropped:0 overruns:0 frame:0
TX packets:6275 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:3
RX bytes:1654618 (1.5 MB) TX bytes:469253 (458.2 KB)
Post Reply