3

I'm trying to use dnsmasq to pushing routes to my clients on a small local network.

However my clients (Server #1, #2 and #3) can not use these routes. The dnsmasq service is running and I do not know what may be going wrong.

This is the content of my "/etc/dnsmasq.conf" file:

domain-needed
bogus-priv
no-resolv
no-poll
server=/localnet/192.168.56.254
server=8.8.3.3
server=8.8.8.8
server=208.67.220.220
local=/brlightinternet.local/
interface=vboxnet0
listen-address=192.168.56.254
no-hosts
expand-hosts
domain=brlightinternet.local
dhcp-range=192.168.56.3,192.168.56.253,12h
dhcp-option=option:router,192.168.56.254

# pushing routes
dhcp-option=121,10.0.4.0/24,10.0.6.4,10.8.0.0/24,10.0.6.4,10.0.6.0/24,10.8.0.1
dhcp-option=249,10.0.4.0/24,10.0.6.4,10.8.0.0/24,10.0.6.4,10.0.6.0/24,10.8.0.1

dhcp-option=vendor:MSFT,2,1i
cache-size=150

IMPORTANT: "192.168.56.254" is not the ip of the server running dnsmasq. Its ip is "192.168.56.1". From what I understand we can assign a different ip to dnsmasq.

This is the network configuration ("/etc/sysconfig/network-scripts/ifcfg-enp0s17") on each client (Server #1, #2 and #3)...

BOOTPROTO=static
DEVICE=enp0s17
DNS1=192.168.56.254
GATEWAY=192.168.56.254
IPADDR=192.168.56.120
IPV6INIT=NO
NETMASK=255.255.255.0
NM_CONTROLLED=yes
ONBOOT=yes
TYPE=Ethernet
USERCTL=NO
ZONE=public

... only the ips change...

Server #1 -> IPADDR=192.168.56.122
Server #2 -> IPADDR=192.168.56.120
Server #3 -> IPADDR=192.168.56.121

Information about the LANs of each server...

Server #1

[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default 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: enp0s17: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:12:26:e2:6c brd ff:ff:ff:ff:ff:ff
    inet 192.168.56.122/24 brd 192.168.56.255 scope global noprefixroute enp0s17
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:12ff:fe26:e26c/64 scope link 
       valid_lft forever preferred_lft forever

Server #2

[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default 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: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:2c:d1:58 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.10/24 brd 10.0.2.255 scope global noprefixroute dynamic enp0s8
       valid_lft 888sec preferred_lft 888sec
    inet6 fe80::2c5c:27aa:2636:8dc9/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: enp0s17: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:1c:a6:b9:59 brd ff:ff:ff:ff:ff:ff
    inet 192.168.56.120/24 brd 192.168.56.255 scope global noprefixroute enp0s17
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:1cff:fea6:b959/64 scope link 
       valid_lft forever preferred_lft forever
5: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 100
    link/none 
    inet 10.8.0.1/24 brd 10.8.0.255 scope global tun0
       valid_lft forever preferred_lft forever
    inet6 fe80::6a67:7379:b64:967c/64 scope link flags 800 
       valid_lft forever preferred_lft forever

Server #3

[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default 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: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:71:77:07 brd ff:ff:ff:ff:ff:ff
    inet 10.0.4.4/24 brd 10.0.4.255 scope global noprefixroute dynamic enp0s8
       valid_lft 1115sec preferred_lft 1115sec
    inet6 fe80::899f:8ca4:a7c6:25a7/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: enp0s17: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:ea:4e:40:ae brd ff:ff:ff:ff:ff:ff
    inet 192.168.56.121/24 brd 192.168.56.255 scope global noprefixroute enp0s17
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:eaff:fe4e:40ae/64 scope link 
       valid_lft forever preferred_lft forever
4: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 100
    link/none 
    inet 10.8.0.6/24 brd 10.8.0.255 scope global tun0
       valid_lft forever preferred_lft forever
    inet6 fe80::48c2:b3cd:5845:5d35/64 scope link flags 800 
       valid_lft forever preferred_lft forever

NOTE I: "ip_forward" is enabled on Server #2...

echo -n "net.ipv4.ip_forward=1

" >> /etc/sysctl.d/ip_forward.conf
sysctl -w net.ipv4.ip_forward=1


NOTE II: This thread is entirely related to the problem...

Use the LANs of one server to access the LAN of another

With this solution I can make routes without problems...

https://unix.stackexchange.com/a/457347/61742

... but without the benefit of having the thing centralized as when I use dnsmasq.


Thanks! =D

  • @galaxy Thread related to configuring dnsmasq as a router: serverfault.com/a/575936/276753 – Eduardo Lucio Jul 20 '18 at 23:46
  • @dirkt I think this may interest you! – Eduardo Lucio Jul 20 '18 at 23:48
  • @RuiFRibeiro I think this may interest you! – Eduardo Lucio Jul 20 '18 at 23:49
  • 1
    I would advise a multi-homed DHCP server ISC-DHCP or Kea. dnsmasq is just suited for home networks/vm dual DNS setups/local DNS cache. We do not get notifications without posting in a thread btw. – Rui F Ribeiro Jul 21 '18 at 4:31
  • 1
    @RuiFRibeiro In view of your last comment and the explanations of Isaac I will try isc.org/kea (kea), because dnsmasq seems to be very limited even for a very small thing and I am having a bit of trouble finding information about how to use it. Thank you both! =D – Eduardo Lucio Jul 23 '18 at 18:21
5

AFAICT

Unfortunately providing several dhcp-options to dnsmasq results in the last being applied (not all).

So, you need to supply only two IP addresses (network and gateway):

dhcp-option=121,10.0.4.0/24,10.8.0.1

And, you also need to tell each server[123] to ask for the route.

And, if your ISC DHCP client doesn’t have support for this option (one in current Debian does), you need a line like below in /etc/dhclient.conf or /etc/dhcp3/dhclient.conf:

option classless-static-routes code 121 = array of { ip-address, ip-address };

to make dhclient aware of the 121 option and then use some script in /etc/dhcp3/dhclient-exit-hooks.d/configure_static_routes to make the network configuration automatic.

This is quite a good description.

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.