-
Notifications
You must be signed in to change notification settings - Fork 42
/
README
167 lines (127 loc) · 6.29 KB
/
README
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
Thirty-second upgrade guide for people who hate using diff:
Install and go. Except in very rare cases, which will be documented here,
your old conf.py, extensions, and scripting logic will be
forwards-compatible with this version.
If coming from anything before 1.6.1, move conf.py into the conf/ directory
or create /etc/staticDHCPd/ and move it there. Your old file needs no TLC.
-------------------------------------------------------------------------------
Installation instructions:
Run install.sh with privileges that can create content in
/etc and /usr/local/bin. Follow the resulting on-screen text to integrate
the server with your OS's daemon-management engine.
Just remember to set up conf.py and everything should Just Work(TM). Before
installing the server, though, run through the five-minute quickstart
described below; it doesn't require that you make any permanent changes to
your host and it'll run out of the source distribution as-is.
-------------------------------------------------------------------------------
Five-minute "does this really work?" setup guide for busy administrators
Uses an INI file or sqlite3 to avoid unnecessary installations
(If you need more information, see the project page at
http://uguu.ca/puukusoft/staticDHCPd/ or
http://code.google.com/p/staticdhcpd/)
Step 1: Gather resources
You need the code, which came with this lovely text file, and a computer
on which to run it. Since this is a Unix-formatted file, you've probably
already got that, too. (Also Python 2.5+, but no modern Unix-like system is
without that)
The last thing you need is enough access to bind to the DHCP ports.
Since there's no way you're going to just run this server on a production
box without testing it first, you've almost certainly satisfied this
requirement, too.
So you're done. That was easy.
Step 2: Set up the DHCP database
(This example assumes your network is similar to that of a typical home
user; if this is not the case, you will need to adjust things, but you
probably wouldn't be playing with a DHCP server if you were a typical home
user anyway)
The example values below will give the MAC 'aa:bb:cc:dd:ee:ff' the IP
'192.168.0.197' and no hostname. You'll notice that non-host-specific
parameters are inherited from its subnet-classification, specifically
things like lease-time and basic routing parameters. DNS, NTP, and
other properties aren't specified in this example, but are in the samples/
directory.
(The term "subnet" is used loosely here: the only thing that matters is that
the "subnet" and "serial" values match for inheritance -- you could put
"floor 3" in as a "subnet" if you wanted to. The term "subnet" was chosen
because it seemed like the most likely classification system for
administrators to use and recognise; similarly, "serial" is also up to you,
it just allows for multiple definitions within the same "subnet" -- you
might want to use the VLAN, or maybe you'll just always make it 0)
INI method:
Create a file with the following contents; the name is up to you.
[192.168.0.0/24|0]
lease-time: 14400
gateway: 192.168.0.1
subnet-mask: 255.255.255.0
broadcast-address: 192.168.0.255
[aa:bb:cc:dd:ee:ff]
ip: 192.168.0.197
subnet: 192.168.0.0/24
serial: 0
SQLite method:
Open a terminal and run `sqlite3 dhcp.sqlite3`
Copy and paste the contents of databases/sqlite.sql into the prompt.
Now that your database is ready to go (SQLite is easy), add some rules.
INSERT INTO subnets (
subnet,
serial,
lease_time,
gateway,
subnet_mask,
broadcast_address,
ntp_servers,
domain_name_servers,
domain_name
) VALUES (
'192.168.0.0/24',
0,
14400,
'192.168.0.1',
'255.255.255.0',
'192.168.0.255',
NULL,
NULL,
NULL
);
INSERT INTO maps (
mac,
ip,
hostname,
subnet,
serial
) VALUES (
'aa:bb:cc:dd:ee:ff',
'192.168.0.197',
NULL,
'192.168.0.0/24',
0
);
Step 3: Set up conf.py
Copy 'conf/conf.py.sample' to 'conf/conf.py'.
Edit the file and make the following changes:
Set DAEMON to False. If you don't, it'll do daemonsy things, like kill
console output and detach from the controlling terminal, which aren't
good for helping to identify configuration problems quickly.
Set DHCP_SERVER_IP to whichever IP you want to listen on.
If you are working with clients that do not understand the DHCP
broadcast bit (mostly embedded devices running busybox/udhcpc), read
about the DHCP_RESPONSE_INTERFACE option in the configuration doc. If
not, don't worry about it.
INI method:
Set DATABASE_ENGINE to 'INI'; capitalization matters.
Add the line "INI_FILE = '/home/you/ini-file-you-created'"
SQLite method:
Set DATABASE_ENGINE to 'SQLite'; capitalization matters.
Add the line "SQLITE_FILE = '/home/you/sqlite-file-you-created'"
Step 4: Start the server
Run `sudo python staticDHCPd`.
You should see a bunch of lines appear, explaining that the server is now
running.
Tell the device with the MAC given in step 3 to request an address and
everything should Just Work(tm).
Go to http://localhost:30880/ if you want to check out the web interface.
Step 5: Kill the process
When satisifed that the system works, hit ^C or send SIGTERM (15) to the
process.
You now have proof that what you have in your hands is a functional,
ready-to-customise DHCP server.