[root@dywH add]# vim natlivecd-ks.cfg %post --log=/kspost export PATH="/usr/bin:/bin:/sbin:/usr/sbin:/var/ftp/pub/centos6/bin:" %end
[root@dywH add]# vim natlivecd-ks.cfg %post --log=/kspost sed -i 's/\(^net.ipv4.ip_forward =\).*$/\1 1/g' /etc/sysctl.conf %end
/etc/udev/rules.d/70-persistent-net.rules 中紀錄 網卡 MAC 位址,會造成網卡啟動失敗,故必須刪除網卡 MAC 位址紀錄檔,且將其連結至 /dev/null,讓其無法產生。
%post --log=/kspost ln -sf /dev/null /etc/udev/rules.d/70-persistent-net.rules %end
[root@dywH add]# vim natlivecd-ks.cfg
%post --log=/kspost
cat > /etc/named.conf << END
// named.conf for NAT
//
// Provided by Red Hat bind package to configure the ISC BIND named(8) DNS
// server as a caching only nameserver (as a localhost DNS resolver only).
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
options {
listen-on port 53 { any; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query { any; };
recursion yes;
dnssec-enable yes;
dnssec-validation yes;
dnssec-lookaside auto;
/* Path to ISC DLV key */
bindkeys-file "/etc/named.iscdlv.key";
forward only;
forwarders {
163.17.3.1;
168.95.1.1;
139.175.10.20;
};
};
END
%end
[root@dywH add]# vim natlivecd-ks.cfg
%post --log=/kspost
cat > /etc/dhcp/dhcpd.conf << END
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
# see 'man 5 dhcpd.conf'
#
authoritative;
ddns-update-style none;
subnet 192.168.1.0 netmask 255.255.255.0 {
# The following lines are standard all of the time.
option routers 192.168.1.254;
option subnet-mask 255.255.255.0;
option domain-name "deyu.wang";
option domain-name-servers 192.168.1.254,163.17.3.1,168.95.1.1;
default-lease-time 600;
max-lease-time 720;
range 192.168.1.100 192.168.1.199;
next-server 192.168.1.254;
}
END
%end
[root@dywH add]# vim natlivecd-ks.cfg %post --log=/kspost sed -i 's/\(^net.ipv4.ip_forward =\).*$/\1 1/g' /etc/sysctl.conf %end
/etc/init/tty.conf,讓 LiveCD 開機自動以 root 身份登入。
[root@dywH add]# vim natlivecd-ks.cfg %post --log=/kspost sed -i 's/\(exec \/sbin\/mingetty \$TTY\).*/\1 --autologin root \$TTY/' /etc/init/tty.conf %end
.bash_profile 加入 natboot.sh,讓系統以 root 身分登入後,自動執行網路設定腳本。
[root@dywH add]# vim natlivecd-ks.cfg %post --log=/kspost echo 'natboot.sh' >> /root/.bash_profile %end