-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdhcpd.sh
85 lines (68 loc) · 1.86 KB
/
dhcpd.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
[root@nb3ds2 ~]# cat dhcpd.sh
#!/bin/sh
#set -x
# Configure dhcpd
echo "Please give enodeb information."
echo -e "MAC address: \c"
read MACADDR
echo -e "IP address: \c"
read IPADDR
echo -e "Gateway: \c"
read GATEWAY
echo -e "Netmask: \c"
read NETMASK
SUBNET=`echo $GATEWAY|cut -d. -f1-3`.$((`echo $GATEWAY|cut -d. -f4`-1))
echo
echo "Will configure the following parameters:"
echo "MAC address: $MACADDR"
echo "IP address: $IPADDR"
echo "Sub network: $SUBNET"
echo "Netmask: $NETMASK"
echo "Gateway: $GATEWAY"
echo
echo -e "Is this OK? (y/n) \c"
read CORRECT
test "$CORRECT" = "y" || { echo "Please re-run this script and enter the correct parameters"; exit 1; }
SERVER_IP=`/sbin/ifconfig bond0|grep -oP '(?<=addr:)[\d\.]+'`
cat >/etc/dhcpd.conf <<EOF
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
#
server-identifier $SERVER_IP;
not authoritative;
one-lease-per-client on;
ddns-update-style none;
option vendor-encapsulated-options code 43 = string;
class "TDDLTESYVE" {
match if option vendor-class-identifier = "NSNBTS01";
}
default-lease-time 1200;
max-lease-time 1200;
min-lease-time 1200;
subnet $SUBNET netmask $NETMASK {
option routers $GATEWAY;
#pool {
# allow members of "TDDLTESYVE";
# range dynamic-bootp $IPADDR;
#}
### option vendor-encapsulated-options 00:00:00:00:01:04:0A:D4:C1:48;
host ENB_MAC_BINDING { hardware ethernet $MACADDR; fixed-address $IPADDR; }
}
subnet 10.212.193.0 netmask 255.255.255.128{}
EOF
echo
echo 'DHCP Server will restart in 2 seconds!'
echo
sleep 2
service dhcpd restart
if [ $? -ne 0 ];then
echo
echo "parameters not correct!Please re-run this script and enter the correct parameters!"
echo
exit 28;
else
echo
echo "DHCP Server Restart Successfully!"
echo
fi