Thursday, August 25, 2016

Mac binding in DHCP along with mobile phone restriction

As we have setup TSIG along with master-slave of bind DNS. Now we are configuring dhcp setup.
Below are the steps.

[root@dlp ~]# yum -y install dhcp

[root@dlp ~]# vi /etc/dhcp/dhcpd.conf
================
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample
#   see 'man 5 dhcpd.conf'
#
# atpl-subnet
ddns-updates on;
ddns-update-style interim;

set vendor-string = option vendor-class-identifier;

class "android" {
        match if substring (option vendor-class-identifier,0,6) = "dhcpcd";
        }

class "android-1" {
        match if substring (option vendor-class-identifier,0,7) = "android";
        }

class "BlackBerry" {
        match if substring (option vendor-class-identifier,0,10) = "BlackBerry";
        }

class "iPhones" {
        match if suffix (option host-name,6) = "iPhone";
        }
key rndc-key {
        algorithm hmac-md5;
        secret e511iZsuCmKS4BPfBje7hQ==;
};

allow client-updates;
authoritative;
#update-optimization off;

subnet 172.24.40.0 netmask 255.255.255.0 {
        interface eth0;
        pool {
        deny members of "android";
        deny members of "android-1";
        deny members of "BlackBerry";
        deny members of "iPhones";
        range 172.24.40.1 172.24.40.200;
        option broadcast-address 172.24.40.255;
        option subnet-mask 255.255.255.0;
        option routers 172.24.40.253;
        option domain-name "domain40.example.com";
        option domain-name-servers 172.24.40.100;
        default-lease-time 900;
        max-lease-time 900;
        }
        }

host station-x.domain40.example.com. {
        hardware ethernet 00:8e:f2:5d:07:17;
        fixed-address 172.24.40.100;
        }
host station-y.domain40.example.com. {
        hardware ethernet 00:26:b9:86:02:73;
        fixed-address 172.24.40.101;
        }
zone domain40.example.com. {
        primary localhost;
        key rndc-key;
        }
zone 40.24.192.in-addr.arpa. {
        primary localhost;
        key rndc-key;
        }
====================================

Bind with TSIG Transfer key

As we have configured master slave DNS on my previous link. Lets have replication with TSIG.

Step 1) On system-x
# cd /var/named/chroot/etc
# dnssec-keygen -a HMAC-MD5 -b 128 -n HOST station-x-station-y.

Now two files will be create

# cat  Kstation-x-station-y.+157+01233.private  (copy the key from here)

# cp -p rndc.key transfer.key
# vim transfer.key
key "station-x-station-y." {
        algorithm       hmac-md5;
        secret          "e511iZsuCmKS4BPfBje7hQ==";
};

# vim named.conf


include "/etc/transfer.key";
acl mylan {172.24.40.0/24;};

allow-transfer {key station-x-station-y.; };
        allow-query     { localhost; mylan; any; };
        allow-query-cache { localhost; mylan; any; };

(save)

#  ln -s transfer.key /etc/transfer.key
#service named restart
#named-checkconf named.conf

#scp transfer.key station-y:/var/named/chroot/etc/


# vi domain40.example.com.forward (add one more record)

secret-x.domain40.example.com.  IN A            172.24.40.100

(save)

# /etc/init.d/named restart

On system -y
# chgrp named transfer.key

# vim named.conf

include "/etc/transfer.key";
acl mylan {172.24.40.0/24;};
server 172.24.40.100 {
keys {station-x-station-y.; };
};


# rndc refresh domain40.example.com

# grep -i tsig /var/log/messages --color

# /etc/init.d/named restart

Renew k8s certificates

Check If certificate expires: amikum@~:03:06:54(⎈ |local-cluster:default):sudo kubeadm certs check-expiration CERTIFICATE                EXP...