Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # setup dhcp server
- # run this script as root
- if [ "$#" -gt 1 ]; then
- echo "usage: $0 [file]" 1>&2
- exit 1
- elif [ "$#" -eq 1 ]; then
- if ! [ -f "$1" ]; then
- echo "$1 is not a valid file" 1>&2
- exit 1
- fi
- fi
- if [ "$EUID" -ne 0 ]; then
- echo "Require root privilege" 1>&2
- exit 1
- fi
- yum install -y dhcp
- if [ "$?" -ne 0 ]; then
- exit $?
- elif [ "$#" -eq 1 ]; then
- cat "$1" > /etc/dhcp/dhcpd.conf
- else
- # printf "Enter your network IP range [192.168.1.0/255.255.255.0]: "
- # read NET_IP
- # printf "Enter your available IP range [192.168.1.100-192.168.1.254]: "
- # read AVA_IP
- cat <<- EOF >> /etc/dhcp/dhcpd.conf
- #
- # DHCP Server Configuration file.
- # see /usr/share/doc/dhcp*/dhcpd.conf.example
- # see dhcpd.conf(5) man page
- #
- subnet 192.168.122.0 255.255.255.0 {
- }
- subnet 10.0.0.0 netmask 255.255.255.0 {
- range 10.0.0.200 10.0.0.254;
- option domain-name "december.io";
- option domain-name-servers ns.december.io;
- option routers 10.0.0.1;
- host ns {
- hardware ethernet 00:00:00:00:00:00;
- fixed-address 10.0.0.3;
- }
- }
- EOF
- fi
- systemctl enable dhcpd
- systemctl start dhcpd
Add Comment
Please, Sign In to add comment