Thursday, January 12, 2017

configure dnsmasq as a dhcp relay agent

*** setup information
- diagram
client --> (vboxnet2:192.168.58.1)dhcp relay ---> dhcp server (mikrotik)

dhcp server ip: 192.168.202.3

1- configure dhcp server (dhcp server part)
/ip pool add name=pool2 ranges=192.168.58.50-192.168.58.100
/ ip dhcp-server network add address=192.168.58.0/24 gateway=192.
168.58.1 

/ip dhcp-server  add name=dhcp1 interface=ether2 relay=192.168.
58.1 address-pool=pool2 lease-time=3d

/ ip route add dst-address=192.168.58.0/24 gateway=192.168.202.2


2- configure dhcp relay agent, by edit file /etc/dnsmasq.conf as below
interface=vboxnet2
dhcp-relay=192.168.58.1,192.168.202.3



- to run it just execture sudo dnsmasq

if you want to see the verbose message, use the following command
$ sudo  dnsmasq -d -C /etc/dnsmasq.conf 


capturing the traffic during the dhcp request and offer between client and server
23:48:31.835886 IP (tos 0x0, ttl 16, id 0, offset 0, flags [none], proto UDP (17), length 328)
    192.168.202.3.bootps > 192.168.58.1.bootps: [udp sum ok] BOOTP/DHCP, Reply, length 300, xid 0x47f70d2c, Flags [none] (0x0000)
          Your-IP 192.168.58.50
          Server-IP 192.168.202.3
          Gateway-IP 192.168.58.1
          Client-Ethernet-Address 08:00:27:f8:da:51 (oui Unknown)
          Vendor-rfc1048 Extensions
            Magic Cookie 0x63825363
            DHCP-Message Option 53, length 1: ACK
            Server-ID Option 54, length 4: 192.168.202.3
            Lease-Time Option 51, length 4: 259200
            Subnet-Mask Option 1, length 4: 255.255.255.0
            Default-Gateway Option 3, length 4: 192.168.58.1
            Domain-Name-Server Option 6, length 8: google-public-dns-a.google.com,google-public-dns-a.google.com
            END Option 255, length 0
            PAD Option 0, length 0, occurs 22
23:48:34.075824 ARP, Ethernet (len 6), IPv4 (l




No comments:

Post a Comment