Sunday, July 31, 2016

instant dhcp server with dnsmasq

if you want to assign ip address using dhcp to other device and you don't want to edit any configuration you can use dnsmasq and run it on terminal with the ip address range you and to assign.

- for example you want give out address 192.168.15.100-192.168.15.200 with gateway 192.168.15.1 and dns server 8.8.8.8, so you run the following command

$ sudo dnsmasq --dhcp-range=192.168.15.100,192.168.15.200 \
    --dhcp-option=3,192.168.15.1 --dhcp-option=6,8.8.8.8


- or if want to run on an interface and you want create a script to run it. for example on vmnet3 that address ip address 192.168.15.1 as the gateway for our clients, so the script will look like below

#/bin/bash
ifconfig vmnet3 192.168.15.1/24 up
dnsmasq -i vmnet3 --dhcp-range=192.168.15.100,192.168.15.200 \
    --dhcp-option=3,192.168.15.1 --dhcp-option=6,8.8.8.8



you can save it as dhcp.sh and run it as
$ sudo sh dhcp.sh

No comments:

Post a Comment