OpenWRT on VirtualBOX

Hello everyone.

I have recently started my adventure with OpenWRT, so my questions may seem trivial, but I want to understand them in order to proceed. I wanted to start a network consisting of several servers (DNS, WWW, MAIL). I have configured the eth0 (WAN), eth1 (NAT), eth2 (Host-Only) interfaces. I have also configured a DHCP server for class C IP addresses for the eth1 interface. When restarting dnsmaq, such messages appear.

Network configuration:

root@OpenWrt:~# cat /etc/config/network

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

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

config interface 'nat'
        option ifname 'eth1'
        option proto 'static'
        option ipaddr '192.168.20.1'
        option netmask '255.255.255.0'
        option gateway '192.168.20.1'
        option dns '192.168.0.1'

config interface 'hostonly'
        option ifname 'eth2'
        option proto 'static'
        option ipaddr '192.168.10.2'
        option netmask '255.255.255.0'
# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP qlen 1000
    link/ether 08:00:27:72:dc:31 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.104/24 brd 192.168.0.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe72:dc31/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP qlen 1000
    link/ether 08:00:27:0a:d5:e7 brd ff:ff:ff:ff:ff:ff
    inet 192.168.20.1/24 brd 192.168.20.255 scope global eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe0a:d5e7/64 scope link
       valid_lft forever preferred_lft forever
4: eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP qlen 1000
    link/ether 08:00:27:20:a3:86 brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.2/24 brd 192.168.10.255 scope global eth2
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe20:a386/64 scope link
       valid_lft forever preferred_lft forever

DHCP configuration

# cat /etc/config/dhcp

config dnsmasq
        option domainneeded '1'
        option boguspriv '1'
        option filterwin2k '0'
        option localise_queries '1'
        option rebind_protection '1'
        option rebind_localhost '1'
        option local '/lan/'
        option domain 'lan'
        option expandhosts '1'
        option nonegcache '0'
        option cachesize '1000'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
        option nonwildcard '1'
        option localservice '1'
        option ednspacket_max '1232'
        option filter_aaaa '0'
        option filter_a '0'

config dhcp 'lan'
        option interface 'nat'
        option start '100'
        option limit '150'
        option leasetime '12h'
        option dhcpv4 'server'
        option dhcpv6 'server'
        option ra 'server'
        option ra_slaac '1'
        list ra_flags 'managed-config'
        list ra_flags 'other-config'
        option dns '192.168.0.1'

config dhcp 'wan'
        option interface 'wan'
        option ignore '1'

#config odhcpd 'odhcpd'
#option maindhcp '0'
#option leasefile '/tmp/hosts/odhcpd'
#option leasetrigger '/usr/sbin/odhcpd-update'
#option loglevel '4'

I have been looking for the cause for another day, but I cannot deduce anything from where the references to class A addresses come from.

# service dnsmasq restart
udhcpc: started, v1.36.1
udhcpc: broadcasting discover
udhcpc: broadcasting select for 10.0.3.15, server 10.0.3.2
udhcpc: lease of 10.0.3.15 obtained from 10.0.3.2, lease time 86400

Can you tell me where he gets it from?

In VirtualBOX, I don't have a DHCP server that would work in this address class.

C:\Program Files\Oracle\VirtualBox> .\VBoxManage list dhcpservers
NetworkName:    HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter
Dhcpd IP:       192.168.56.100
LowerIPAddress: 192.168.56.101
UpperIPAddress: 192.168.56.254
NetworkMask:    255.255.255.0
Enabled:        No
Global Configuration:
    minLeaseTime:     default
    defaultLeaseTime: default
    maxLeaseTime:     default
    Forced options:   None
    Suppressed opts.: None
        1/legacy: 255.255.255.0
Groups:               None
Individual Configs:   None

And the router from which it takes the WAN interface address also has a DHCP server from class C. Could the reason be that the WAN interface is set as dhcp-client and the DHCP server is running on eth1?

Regards
MA

Start anew.
You should not destroy br-lan with eth0.

hi,

you are mixing Virtualbox networking with owrt networking schema. with virtualization there are two purpose/use case a network interface has:

  1. you can set in virtualbox how a particular interface would work in respect to host-guest relation, i.e. whether an interface can access for example your host network, host-only network or should be NATed facing to host network
  2. the same interface from the guest vm should do what. i.e. in owrt by default eth0 and eth1 interfaces are defined respectively used for lan and wan.

so if you want your owrt wan interface to be NATed from host point of view, or you want other VMs to connect as clients to owrt via owrt's lan interface therefore internal mode is set in VB, you can do that.

but as @brada4 suggested keep the default eth interfaces in owrt as is and align the VB config to meet their purpose. then you can add additional virtual intefaces and configure both host and guest end as you wish.

1 Like

In worst case you need to swap virtual cables outside virtual machine...

1 Like

If you need assistance, you'll also need to describe if the host is expected to perform other tasks.

  • Assuming the Windows machine is the host, it's also a normal Windows client, correct?
  • Where is the physical WAN connection?
  • Where is the physical LAN connection?
  • Are these interfaces bridged to real PHYs on the host?
  • Are you assuming that your Windows device will get an IP via DHCP from a router it's virtually hosting (that won't work)?

If the last question is true, this thread may help:

(Hint: for the host, you'll need to static assign the IP on an Internal/host only Interface - ignore the VirtualBox network config it creates.)

It's optional to keep unless user wants to bridge more PHYs for LAN or a passed-thru WiFi card.

Thanks for the answers. That's the problem, I mixed up the patterns. I have habits from Centos. Here it's a bit different though.

Thanks again Have a nice day

Just curious, you mean configuration in the Linux VM Manager verses configuring in VirtualBox on Windows, correct?

Anyways, I'm glad you got it working!

No no... maybe I wrote it loftily but it's hard to be surprised. I've just started playing with openwrt. In centos the dhcp server is not ready to use, you have to configure it on a short interface to work. Here, when I browse /etc/config/network and /etc/config/dhcp it is assigned to lan by default, i.e. to eth0 and there is no need to add another network adapter so that clients in the network use DHCP. But I noticed this only after the fact, when I wrote the post here.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.