Page 1 of 1

Problem with router on VM

Posted: 13. Sep 2013, 18:43
by mailo
I want to create on one virtual machine (CateOS) a virtual router. Next, second virtual machine (CateOS too) should connect via this virtual router to the Internet.

This is my configuration:

1st (router):
- eth0 is bridget adapter with my physical wlan card (Broadcom 802.11n Network Adapter)
is configured by DHCP and it has already

ip: 192.168.1.108,
netmask: 255.255.255.0,
gateway: 192.168.1.1

- eth1 is VirtualBox Host-Only Ethernet Adapter (Promiscuous Mode:Allow All - but I think in my case it isn't important, is it?)
is configured manually and it has already:
ip: 192.168.0.1
netmask: 255.255.255.0
gateway: 192.168.0.1
dns servers: 8.8.8.8

I wrote in console as root:

Code: Select all

echo 1 > /proc/sys/net/ipv4/ip_forward 
iptables -A POSTROUTING -s 192.168.0.0/24 -j MASQUERADE -t nat
2nd VM:

- eth0 is VirtualBox Host-Only Ethernet Adapter (Promiscuous Mode: Allow all)
is configured manually and it has already:
ip: 192.168.0.2
netmask: 255.255.255.0
gateway: 192.168.0.1
dns servers: 8.8.8.8

From 2nd VM I can ping 192.168.0.1 but I can't ping any address from the Internet (Unknown host for google for example). It looks like router doesn't want to forward packages but I don't know why. I am beginner but the instruction for iptables looks good for me. Do you have any ideas? Of course I have the internet access on the virtual router. What maybe can be important that I use livecd version of CateOS (without installation) so I don't reboot it anytime.

Re: Problem with router on VM

Posted: 13. Sep 2013, 19:04
by Perryg
I would use the internal mode instead of host-only for the host and guest LAN (private side)
Router guest would would have one NAT or Bridged and one internal. 2nd guest would have internal.

Re: Problem with router on VM

Posted: 13. Sep 2013, 21:46
by mailo
Thank you for reply. Should I change something more? Because when I change only type to internal (with the same name "intnet") on both devices, the situation is the same (only ping 192.168.0.1 is working).

Re: Problem with router on VM

Posted: 13. Sep 2013, 22:05
by Perryg
If you setup the guest/s properly they will be able to ping each other. Then if you setup your router properly they will be able to ping the Internet.
VirtualBox provides the emulated hardware but specific configurations are up to the end user. Normal network knowledge is all you need.

Re: Problem with router on VM

Posted: 13. Sep 2013, 22:38
by noteirak
make sure iptables does not have a default DROP policy, and if it does, change accordingly.

Re: Problem with router on VM

Posted: 14. Sep 2013, 11:00
by mailo
Yea :) It works :) Thanks noteirak. You had right, something was wrong in the default configuration. iptables --flush solved the problem.