概述
本文以Redhat6.5为基础,通过配置网络安装服务器,实现Redhat Linux的网络安装。主要用到的软件(服务)有DHCP,TFTP,NFS,Kickstart等。本文只列出具体步骤,不含原理说明。
1. 基础配置
1.1 更改IP地址
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 [root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0
HWADDR=08:00:27:53:44:fb TYPE=Ethernet
UUID=82affeef-922e-40b2-b89f-a5df8e9fa236 ONBOOT=yes
NM_CONTROLLED=yes BOOTPROTO=none IPADDR=192.168.7.30 NETMASK=255.255.255.0 GATEWAY=192.168.7.1 IPV6INIT=no USERCTL=no
[root@localhost ~]# ifup eth0
Active connection state: activated
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/1 1.2 更改hostnme
[root@localhost ~]# vi /etc/sysconfig/network [root@redhatnis ~]# cat /etc/sysconfig/network NETWORKING=yes HOSTNAME=redhatnis
[root@localhost ~]# vi /etc/hosts [root@localhost ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.7.30 redhatnis
1.3 关闭SELINUX及防火墙(iptables)
[root@localhost ~]# vi /etc/selinux/config
[root@redhatnis ~]# cat /etc/selinux/config |grep disa # disabled - SELinux is fully disabled. SELINUX=disabled
[root@localhost ~]# chkconfig |grep ipta iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@localhost ~]# chkconfig --level 2345 iptables off [root@localhost ~]# shutdown -ry 0
2. 软件安装
2.1 挂载安装光盘
[root@redhatnis ~]# mount /dev/sr0 /mnt
mount: block device /dev/sr0 is write-protected, mounting read-only [root@redhatnis ~]# df -h
Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_root-lv_root 20G 6.2G 12G 35% /
tmpfs 940M 72K 940M 1% /dev/shm /dev/sda1 485M 39M 421M 9% /boot /dev/sr0 3.6G 3.6G 0 100% /mnt 2.2 配置YUM源
[root@redhatnis ~]# cd /etc/yum.repos.d
[root@redhatnisyum.repos.d]# vi installmedia.repo [root@redhatnisyum.repos.d]# cat installmedia.repo [InstallMedia]
name=Red Hat Enterprise Linux 6.5 baseurl=file:///mnt/Server enabled=1 gpgcheck=0
[root@redhatnisyum.repos.d]# yum list
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
InstallMedia | 3.9 kB 00:00 ... Installed Packages
ConsoleKit.x86_64 0.4.1-3.el6 @anaconda-RedHatEnterpriseLinux-201311111358.x86_64/6.5 2.3 安装所需软件
[root@redhatnis ~]# yum install -y -q xinetdtftptftp-server ftp vsftpddhcpnfs-utils
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
3. 配置DHCP Server
[root@redhatnis ~]# cd /etc/dhcp [root@redhatnisdhcp]# vi dhcpd.conf
[root@redhatnisdhcp]# cat dhcpd.conf #
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample # see 'man 5 dhcpd.conf' #
allow booting; allow bootp; #Boot 所需文件 filename \#TFTP服务器IP
next-server 192.168.7.30;
subnet 192.168.7.0 netmask 255.255.255.0{ option subnet-mask 255.255.255.0; #IP地址范围
range 192.168.7.31 192.168.7.100; default-lease-time 21600; max-lease-time 43200; }
[root@redhatnisdhcp]# service dhcpd start
Starting dhcpd: [ OK ] [root@redhatnisdhcp]# chkconfig --level 345 dhcpd on [root@redhatnisdhcp]# chkconfig |grep dhcpd dhcpd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
4. 通过FTP(vsftpd)方式上传ISO镜像
[root@redhatnis ~]# cd /etc/vsftpd/ [root@redhatnisvsftpd]# vi ftpusers
[root@redhatnisvsftpd]# cat ftpusers |grep root #root
[root@redhatnisvsftpd]# vi user_list
[root@redhatnisvsftpd]# cat user_list |grep root #root
[root@redhatnis ~]# service vsftpd start
Starting vsftpd for vsftpd: [ OK ] [root@redhatnis ~]# chkconfig --level 345 vsftpd on 此处上传ISO镜像
[root@redhatnis ~]# ll /tmp |grep iso
-rw-r--r-- 1 root root 3853516800 Feb 16 08:40 rhel-server-6.5-x86_64-dvd.iso