root@ubuntu:~# nano /etc/default/dhcp3-server # Defaults for dhcp initscript # sourced by /etc/init.d/dhcp # installed at /etc/default/dhcp3-server by the maintainer scripts
# # This is a POSIX shell fragment #
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests? # Separate multiple interfaces with spaces, e.g. "eth0 eth1".
# The ddns-updates-style parameter controls whether or not the server will # attempt to do a DNS update when a lease is confirmed. We default to the # behavior of the version 2 packages ('none', since DHCP v2 didn't # have support for DDNS.) ddns-update-style none;
#下面是全局設置,這裡定義的信息全dhcp伺服器生效 #我一般註釋掉了,下面可以分不同的子網進行設置 # option definitions common to all supported networks... #option domain-name "apt-get.cn"; #option domain-name-servers 202.103.0.117, 202.103.24.68; #default-lease-time 600; #max-lease-time 7200;
# If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. #authoritative;
# Use this to send dhcp log messages to a different log file (you also # have to hack syslog.conf to complete the redirection). log-facility local7;
# No service will be given on this subnet, but declaring it helps the # DHCP server to understand the network topology.
# A slightly different configuration for an internal subnet. #subnet設置一個子網192.168.1.0/24 #range定義可以分配出去的地址為1.50到1.70 #option domain-name-servers定義dns為202.103.0.117等三個,這裡注意每個之間要有個逗號 #option domain-name定義域名稱 #option routers定義網關地址 #broadcast-address定義廣播地址 #default-lease-time默認租約時間 #max-lease-time 最大租約時間 subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.50 192.168.1.70; option domain-name-servers 202.103.0.117,202.103.24.68,202.103.150.44; option domain-name "apt-get.cn"; option routers 192.168.1.1; option broadcast-address 192.168.1.255; default-lease-time 864000; max-lease-time 86400000; filename "pxelinux.0"; }
# Hosts which require special configuration options can be listed in # host statements. If no address is specified, the address will be # allocated dynamically (if possible), but the host-specific information # will still come from the host declaration.
# Fixed IP addresses can also be specified for hosts. These addresses # should not also be listed as being available for dynamic assignment. # Hosts for which fixed IP addresses have been specified can boot using # BOOTP or DHCP. Hosts for which no fixed address is specified can only # be booted with DHCP, unless there is an address range on the subnet # to which a BOOTP client is connected which has the dynamic-bootp flag # set. #host fantasia { # hardware ethernet 08:00:07:26:c0:a5; # fixed-address fantasia.fugue.com; #}
# You can declare a class of clients and then do address allocation # based on that. The example below shows a case where all clients # in a certain class get addresses on the 10.17.224/24 subnet, and all # other clients get addresses on the 10.0.29/24 subnet.
#class "foo" { # match if substring (option vendor-class-identifier, 0, 4) = "SUNW"; #}
#shared-network 224-29 { # subnet 10.17.224.0 netmask 255.255.255.0 { # option routers rtr-224.example.org; # } # subnet 10.0.29.0 netmask 255.255.255.0 { # option routers rtr-29.example.org; # } # pool { # allow members of "foo"; # range 10.17.224.10 10.17.224.250; # } # pool { # deny members of "foo"; # range 10.0.29.10 10.0.29.230; # } #}
5 啟動伺服器
root@ubuntu:/# /etc/init.d/dhcp3-server start * Starting DHCP server dhcpd3 [ OK ] root@ubuntu:/# 如果原來啟動了的就restart
# /etc/exports: the access control list for filesystems which may be exported # to NFS clients. See exports(5). # # Example for NFSv2 and NFSv3: # /srv/homes hostname1(rw,sync) hostname2(ro,sync) # # Example for NFSv4: # /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt) # /srv/nfs4/homes gss/krb5i(rw,sync) #暫時只為弄清楚安裝方法,安全問題以後再慢慢說 /home/cache/netboot 192.168.1.0/24(rw,no_root_squash,sync)
3 啟動nfs或者重新載入 啟動nfs root@ubuntu:/# /etc/init.d/nfs-kernel-server start * Exporting directories for NFS kernel daemon... exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "192.168.1.0/24:/home/cache/netboot". Assuming default behaviour ('no_subtree_check'). NOTE: this default has changed since nfs-utils version 1.0.x ...done. * Starting NFS kernel daemon ...done. 如果是修改了/etc/exports 配置文件,不需要重新啟動nfs伺服器,只需要刷新一下,命令如下 root@ubuntu:/# exportfs -r exportfs: /etc/exports [1]: Neither 'subtree_check' or 'no_subtree_check' specified for export "192.168.1.0/24:/home/cache/netboot". Assuming default behaviour ('no_subtree_check'). NOTE: this default has changed since nfs-utils version 1.0.x 情滅緣盡 2007.12.21
2 安裝initramfs-tools root@netfs:~# apt-get install initramfs-tools Reading package lists... Done Building dependency tree Reading state information... Done initramfs-tools is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 14 not upgraded. root@netfs:~#
3 編輯initramfs.conf把BOOT=local改為BOOT=nfs # # initramfs.conf # Configuration file for mkinitramfs(. See initramfs.conf(5). #
# # MODULES: [ most | netboot | dep | list ] # # most - Add all framebuffer, acpi, filesystem, and harddrive drivers. # # dep - Try and guess which modules to load. # # netboot - Add the base modules, network modules, but skip block devices. # # list - Only include modules from the 'additional modules' list #
MODULES=most
# BUSYBOX: [ y | n ] # # Use busybox if available. #
BUSYBOX=y
# # NFS Section of the config. #
# # BOOT: [ local | nfs ] # # local - Boot off of local media (harddrive, USB stick). # # nfs - Boot using an NFS drive as the root of the drive. #
BOOT=nfs
# # DEVICE: ... # # Specify the network interface, like eth0 #
root@ubuntu:/home/cache/netboot/root# tar zxvf netfs.tgz && rm -fr netfs.tgz root@ubuntu:/home/cache/netboot/root# ls bin dev home initrd.img media opt root srv tmp var cdrom etc initrd lib mnt proc sbin sys usr vmlinuz 刪除mtab文件 root@ubuntu:/# cd /home/cache/netboot/root/etc/ root@ubuntu:/home/cache/netboot/root/etc# rm mtab root@ubuntu:/home/cache/netboot/root/etc#