Skip to content

Commit

Permalink
Merge pull request #1 from aspiers/dnsmasq
Browse files Browse the repository at this point in the history
Dnsmasq support
  • Loading branch information
dirkmueller committed May 19, 2015
2 parents 5e424c8 + a118bb5 commit b40e4a4
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 1 deletion.
26 changes: 25 additions & 1 deletion controller/config.sh
Expand Up @@ -36,11 +36,35 @@ baseUpdateSysConfig /etc/sysconfig/network/dhcp WRITE_HOSTNAME_TO_HOSTS no
#--------------------------------------
echo "Configure image: [$kiwi_iname]..."

domain=ruler.site
subnet=172.22.222
controller=2
pool_start=150
pool_end=160

cat > /etc/resolv.conf <<EOF
search $domain
nameserver 127.0.0.1
nameserver 192.168.100.4
EOF

for i in `seq $pool_start $pool_end`; do
echo $subnet.$i dhcp-$i
done >> /etc/hosts

sed -i "s/@@SUBNET@@/$subnet/g;
s/@@DOMAIN@@/$domain/g;
s/@@POOL_START@@/$pool_start/g;
s/@@POOL_END@@/$pool_end/g;" \
/etc/dnsmasq.conf

chkconfig dnsmasq on

cat > /etc/sysconfig/network/ifcfg-eth0 <<EOF
BOOTPROTO='static'
BROADCAST=''
ETHTOOL_OPTIONS=''
IPADDR='172.22.222.2/24'
IPADDR='$subnet.$controller/24'
MTU=''
NAME='Ethernet Card 0'
NETMASK=''
Expand Down
73 changes: 73 additions & 0 deletions controller/config/etc/dnsmasq.conf
@@ -0,0 +1,73 @@
# Never forward plain names (without a dot or domain part)
domain-needed
# Never forward addresses in the non-routed address spaces.
bogus-priv

# By default, dnsmasq will send queries to any of the upstream
# servers it knows about and tries to favour servers to are known
# to be up. Uncommenting this forces dnsmasq to try each query
# with each server strictly in the order they appear in
# /etc/resolv.conf
#strict-order

# If you don't want dnsmasq to read /etc/resolv.conf or any other
# file, getting its servers from this file instead (see below), then
# uncomment this.
#no-resolv

# If you don't want dnsmasq to poll /etc/resolv.conf or other resolv
# files for changes and re-read them then uncomment this.
#no-poll

# Add other name servers here, with domain specs if they are for
# non-public domains.
#server=/localnet/192.168.0.1

# Example of routing PTR queries to nameservers: this will send all
# address->name queries for 192.168.3/24 to nameserver 10.1.2.3
#server=/3.168.192.in-addr.arpa/10.1.2.3

# You can control how dnsmasq talks to a server: this forces
# queries to 10.1.2.3 to be routed via eth1
# server=10.1.2.3@eth1

# and this sets the source (ie local) address used to talk to
# 10.1.2.3 to 192.168.1.1 port 55 (there must be a interface with that
# IP on the machine, obviously).
# server=10.1.2.3@192.168.1.1#55

interface=eth0

# Set this (and domain: see below) if you want to have a domain
# automatically added to simple names in a hosts-file.
expand-hosts

# Set the domain for dnsmasq. this is optional, but if it is set, it
# does the following things.
# 1) Allows DHCP hosts to have fully qualified domain names, as long
# as the domain part matches this setting.
# 2) Sets the "domain" DHCP option thereby potentially setting the
# domain of all systems configured by DHCP
# 3) Provides the domain part for "expand-hosts"
domain=@@DOMAIN@@,@@SUBNET@@.0/24,local

dhcp-range=@@SUBNET@@.@@POOL_START@@,@@SUBNET@@.@@POOL_END@@,255.255.255.0,12h
# Supply parameters for specified hosts using DHCP. There are lots
# of valid alternatives, so we will give examples of each. Note that
# IP addresses DO NOT have to be in the range given above, they just
# need to be on the same network. The order of the parameters in these
# do not matter, it's permissible to give name, address and MAC in any
# order.

# Always give the host with Ethernet address 11:22:33:44:55:66
# the name fred and IP address 192.168.0.60 and lease time 45 minutes
#dhcp-host=11:22:33:44:55:66,fred,192.168.0.60,45m

# Run an executable when a DHCP lease is created or destroyed.
# The arguments sent to the script are "add" or "del",
# then the MAC address, the IP address and finally the hostname
# if there is one.
dhcp-script=/bin/echo

log-queries
log-dhcp

0 comments on commit b40e4a4

Please sign in to comment.