How to create a Virtual IP?

Hello,

I am faced with a problem that my research has not been able to solve.

I would like to set up a high availability for my dns servers accessible only for my local network.

For this purpose, I would like to create a virtual IP that would correspond to my two DNS servers.

Unfortunately I can't find a simple solution to set this up, someone would have already done this operation with openwrt?

if this is useful, here is my network configuration file :

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

config globals 'globals'
        option ula_prefix 'fda5:c72c:3d20::/48'

config interface 'lan'
        option type 'bridge'
        option ifname 'eth0.1'
        option proto 'static'
        option ipaddr '192.168.1.1'
        option netmask '255.255.255.0'
        option ip6assign '64'
        list dns '192.168.1.118'
        list dns '192.168.1.163'

config device 'lan_eth0_1_dev'
        option name 'eth0.1'
        option macaddr '74:83:c2:09:c8:7c'

config interface 'wan'
        option ifname 'eth0.2'
        option proto 'static'
        option broadcast '192.168.1.255'
        option ipaddr '192.168.1.12'
        option gateway '192.168.1.254'
        option netmask '255.255.255.0'
        option macaddr '74:83:c2:09:c8:7d'
        list dns '192.168.1.118'
        list dns '192.168.1.163'

config interface 'wan6'
        option ifname 'eth0.2'
        option proto 'static'
        option ip6prefix '2a01:xxxx:xxxx:4dd1::/64'
        list ip6addr '2a01:xxxx:xxxx:4dd1::2/126'
        option ip6gw 'fe80::3627:92ff:fe60:8e20'
        list dns '192.168.1.118'
        list dns '192.168.1.163'

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '1'

config switch_vlan
        option device 'switch0'
        option vlan '1'
        option ports '1 2 3 4 6t'

config switch_vlan
        option device 'switch0'
        option vlan '2'
        option ports '0 6t'

Thank you in advance for your help! :slight_smile:

Why are your WAN and LAN interface on the same 192.168.1.0/24 subnet

3 Likes

My two cents:

  • You probably do not need to do anything special to have high availability on DNS, just configure the two servers on your clients, most (if not all) clients are prepared to accept more than one DNS.

  • Your configuration is seriously messed up, both LAN and WAN cannot be on the same 192.168.1.0/24 network, and the DNSs have to be configured on the interface that gives access to them.

4 Likes

Thank you for your answers.

I'm aware of this wobbly configuration, however I'm stuck with this one for several more weeks.

Concerning the availability of the DNS servers, via a vip, this is a first step to redundant several other services afterwards.

So my question is still how to create a virtual IP via OpenWrt?

I guess you could do it in shell:
ip addr add <ip> dev <interface>

If that works, just put the line in rc.local so it always get applied at boot.

1 Like

This is probably better, now when i think about it I think I have something similar in my setup.