2

I'm experimenting with OpenWrt on VirtualBox. So here is what I have:

  • openwrt VM
    • Adapter 1 is bridged. Gets 192.168.1.x address from my actual router.
    • Adapter 2 is local network "openwrt-lan". Configured as static bridge.
  • Debian VM
    • Adapter 1 is local network "openwrt-lan". Configured with DHCP.

My /etc/config/network files is like this:

config interface 'loopback'
    option ifname 'lo'
    option proto 'static'
    option ipaddr '127.0.0.1'
    option netmask '255.0.0.0'

config interface 'wan'
    option proto 'dhcp'
    option ifname 'eth1'

config interface 'lan'
    option ifname 'eth0'
    option proto 'static'
    option ipaddr '192.168.2.1'
    option netmask '255.255.255.0'

Now Debian VM gets 192.168.2.136 address successfully and can see as far as openwrt. Routing table are like this:

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         OpenWrt.lan     0.0.0.0         UG    0      0        0 eth0
link-local      *               255.255.0.0     U     1000   0        0 eth0
192.168.2.0     *               255.255.255.0   U     1      0        0 eth0

/etc/resolv.conf:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.0.1
search lan

However, it can't see beyond openwrt. tracert 8.8.8.8 shows that the traffic stops at the openwrt router.

A strange thing also is that on the openwrt VM eth0 doesn't have an IP despite the above configuration. Not sure if it's related.

Any input appreciated.

  • Can the openwrt VM get to the internet? – heavyd Feb 19 '14 at 15:08
  • @heavyd Yes. ping and nslookup works fine with internet host. – lang2 Feb 19 '14 at 15:10
0

The reason why this is not working is that this is a hybrid setup, because it uses a DHCP which is inside VirtualBox, and is unrelated to OpenWrt.

In the wild (lol), your Debian VM would receive an IP from the OpenWrt router, and, together with it, it would also receive information necessary to setup a proper routing table. But in your simulation, the Debian VM has so far no direct interaction with the OpenWrt router: it does not receive an IP address from it, nor a default gateway.

You can remedy the situation by treating the Debian VM as if it had a static IP: so, after bringing the NICs up and assigning them an IP address, you also have to manually setup the routing table and the DNSs servers: on the Debian machine, issue

   sudo ip ro add default via 192.168.2.1 dev eth0

if your OpenWrt router has IP address 192.168.2.1 and the Debian NIC is called eth0, otherwise change accordingly. Then add the following two lines to the bottom of the file /etc/resolv.conf:

   nameserver 8.8.4.4
   nameserver 8.8.8.8

and it should now work.

  • The debian vm does get an address from openwrt – lang2 Feb 19 '14 at 23:13
  • @lang2 How about routing table and DNS servers? Are they set correctly? – MariusMatutiae Feb 20 '14 at 4:06
  • question updated with routing and dns info. – lang2 Feb 20 '14 at 13:11

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.