OpenWrt Forum Archive

Topic: Add VPN hostanames

The content of this topic has been archived on 13 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello,

I configure a VPN link between 2 networks with OpenWRT and OpenVPN. Each OpenWRT router assign IP, GW and DNS in the network.

On each OpenWRT router I have configure some hostnames that works in each network.

Is possible to use the hostnames of other router in the both networks?

Maybe configuring the other side DNS server (OpenWRT) in each router?

I don't know how to configure this.

I will appreciate your help.

Best regards.

Yes, there is no reason why you cannot use the DNS in one router to resolve hostnames in the other network, you just have to add them to the list: just go to "Network" > "Hostnames" and add them there.

You could also configure each DNS to ask the other DNS for hosts in his network; you need to use different domains for each network, and add a "server" directive to the dnsmasq configuration file of each router, pointing the domain on the other network to its router.

eduperez wrote:

Yes, there is no reason why you cannot use the DNS in one router to resolve hostnames in the other network, you just have to add them to the list: just go to "Network" > "Hostnames" and add them there.

You could also configure each DNS to ask the other DNS for hosts in his network; you need to use different domains for each network, and add a "server" directive to the dnsmasq configuration file of each router, pointing the domain on the other network to its router.

Thanks eduperez,

I want to do it with dnsmasq.

This is my siteA (192.168.1.1) 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 authoritative '1'
    option readethers '1'
    option leasefile '/tmp/dhcp.leases'
    option resolvfile '/tmp/resolv.conf.auto'

config dhcp 'lan'
    option interface 'lan'
    option start '100'
    option limit '150'
    option leasetime '12h'
    option dhcpv6 'server'
    option ra 'server'
    option ra_management '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'

And this is for siteB (192.168.2.1):

# 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 authoritative '1'
    option readethers '1'
    option leasefile '/tmp/dhcp.leases'
    option resolvfile '/tmp/resolv.conf.auto'

config dhcp 'lan'
    option interface 'lan'
    option start '100'
    option limit '150'
    option leasetime '12h'
    option dhcpv6 'server'
    option ra 'server'
    option ra_management '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'

How could  I configure this?

Thanks for the help.

Regards.

In site A, add one section like this for each server on site B that you need to resolve:

config domain
    option name 'somehost'
    option ip '192.168.2.xxx
eduperez wrote:

In site A, add one section like this for each server on site B that you need to resolve:

config domain
    option name 'somehost'
    option ip '192.168.2.xxx

Thanks again,

But I have more than 20 host in each site and they have one entry in each site.

I want to add the other side DNS (router) to resolv other side hosts. Not add all host in other site.

Thanks again.

Regards.

Sorry, I though you wanted to use the easy option.

First of all, you need to use different local names for your networks; instead of

    option local '/lan/'
    option domain 'lan'

on both sites, you need to use a different name on each site.

Now, you have to tell each router to ask the other router for hosts in the remote network; at "/etc/dnsmasq.conf", add one line such as

server=/lanB/192.168.2.1

Hope this helps!

eduperez wrote:

Sorry, I though you wanted to use the easy option.

First of all, you need to use different local names for your networks; instead of

    option local '/lan/'
    option domain 'lan'

on both sites, you need to use a different name on each site.

Now, you have to tell each router to ask the other router for hosts in the remote network; at "/etc/dnsmasq.conf", add one line such as

server=/lanB/192.168.2.1

Hope this helps!

Thanks again,

I configure this way:

I change this lines in "/etc/config/dhcp":

siteA:

        option local '/siteA/'
        option domain 'siteA'

siteB:

        option local '/siteB/'
        option domain 'siteB'

Then  I add this line in "/etc/dnsmasq.conf"

siteA:

server=/siteB/192.168.2.1

siteB:

server=/siteA/192.168.1.1

But if do a ping in siteA a host that is in siteB, it has no response.

Am I doing something wrong?

Thanks for your great help.

Best regards.

Well, a PING could fail, for a number of reasons... Could you please try a trace ("traceroute hostname" in a Linux computer, or "tracert hostname" on a Windows computer) and post the results here?

The discussion might have continued from here.