(1)
root@pig webadm]# vi /etc/default/grub [root@pig webadm]# cat /etc/default/grub GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR="Fedora" GRUB_DEFAULT=saved GRUB_CMDLINE_LINUX="rd.md=0 rd.dm=0 rd.lvm.lv=vg_pig/lv_root LANG=zh_TW.UTF-8 KEYTABLE=us SYSFONT=False rd.luks=0 rd.lvm.lv= vg_pig/lv_swap rhgb quiet biosdevname=0" #GRUB_THEME="/boot/grub2/themes/system/theme.txt" [root@pig webadm]#
(2) [webadm@pig ~]$ su 密碼: [root@pig webadm]# system-config-network-tui
(3) [root@pig webadm]# vi startnat [root@pig webadm]# cat startnat #!/bin/sh iptables -F iptables -t nat -F
echo "1" > /proc/sys/net/ipv4/ip_forward modprobe ip_nat_ftp modprobe ip_nat_irc modprobe ip_conntrack_ftp modprobe ip_conntrack_irc
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j MASQUERADE
[root@pig webadm]# ./startnat [root@pig webadm]#
(4) [root@pig webadm]# cd /etc/sysconfig/network-scripts/ [root@pig network-scripts]# ls ifcfg-em1 ifdown-eth ifdown-ppp ifup-aliases ifup-ipx ifup-ppp init.ipv6-global ifcfg-lo ifdown-ippp ifdown-routes ifup-bnep ifup-isdn ifup-routes net.hotplug ifcfg-p34p1 ifdown-ipv6 ifdown-sit ifup-eth ifup-plip ifup-sit network-functions ifdown ifdown-isdn ifdown-tunnel ifup-ippp ifup-plusb ifup-tunnel network-functions-ipv6 ifdown-bnep ifdown-post ifup ifup-ipv6 ifup-post ifup-wireless [root@pig network-scripts]# mv ifcfg-em1 ifcfg-eth0 [root@pig network-scripts]# mv ifcfg-p34p1 ifcfg-eth1 [root@pig network-scripts]#
(5) [webadm@pig ~]$ su 密碼: [root@pig webadm]# systemctl enable rc-local.service Warning: unit files do not carry install information. No operation executed. [root@pig webadm]#
(6) [root@pig webadm]# vi /etc/rc.d/rc.local [root@pig webadm]# cat /etc/rc.d/rc.local #!/bin/sh iptables -F iptables -t nat -F
echo "1" > /proc/sys/net/ipv4/ip_forward modprobe ip_nat_ftp modprobe ip_nat_irc modprobe ip_conntrack_ftp modprobe ip_conntrack_irc iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j MASQUERADE
[root@pig webadm]# ls -l /etc/rc.d/rc.local -rw-r--r--. 1 root root 240 9月 4 08:17 /etc/rc.d/rc.local [root@pig webadm]# chmod +x /etc/rc.d/rc.local [root@pig webadm]# ls -l /etc/rc.d/rc.local -rwxr-xr-x. 1 root root 240 9月 4 08:17 /etc/rc.d/rc.local [root@pig webadm]#
[root@pig webadm]# reboot
9/4
(7)
[webadm@pig ~]$ su 密碼: [root@pig webadm]# yum -y install dhcp
Installed: dhcp.i686 12:4.2.5-3.fc17
Dependency Updated: bind-libs.i686 32:9.9.3-3.P1.fc17 bind-libs-lite.i686 32:9.9.3-3.P1.fc17 bind-license.noarch 32:9.9.3-3.P1.fc17 bind-utils.i686 32:9.9.3-3.P1.fc17 dhclient.i686 12:4.2.5-3.fc17 dhcp-common.i686 12:4.2.5-3.fc17 dhcp-libs.i686 12:4.2.5-3.fc17
Complete! [root@pig webadm]#
(10) [root@pig webadm]# vi /etc/dhcp/dhcpd.conf [root@pig webadm]# cat /etc/dhcp/dhcpd.conf # # DHCP Server Configuration file. # see /usr/share/doc/dhcp*/dhcpd.conf.sample # see dhcpd.conf(5) man page # option domain-name "langB.kmvs.km.edu.tw";
option domain-name-servers dns.kmvs.km.edu.tw; default-lease-time 600; max-lease-time 7200;
authoritative;
subnet 192.168.1.0 netmask 255.255.255.0 { range dynamic-bootp 192.168.1.10 192.168.1.90; option broadcast-address 192.168.1.255; option routers 192.168.1.254; } [root@pig webadm]#
(11) [root@pig webadm]# systemctl start dhcpd.service [root@pig webadm]# systemctl enable dhcpd.service ln -s '/usr/lib/systemd/system/dhcpd.service' '/etc/systemd/system/multi-user.target.wants/dhcpd.service' [root@pig webadm]# ps ax|grep dhcp 1902 ? Ss 0:00 /usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid 1911 pts/0 S+ 0:00 grep --color=auto dhcp [root@pig webadm]#
(12) [root@pig webadm]# /sbin/dhcpd & [1] 1932 [root@pig webadm]# Internet Systems Consortium DHCP Server 4.2.5 Copyright 2004-2013 Internet Systems Consortium. All rights reserved. For info, please visit https://www.isc.org/software/dhcp/ Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file Wrote 0 leases to leases file.
No subnet declaration for em1 (163.25.20.164). ** Ignoring requests on em1. If this is not what you want, please write a subnet declaration in your dhcpd.conf file for the network segment to which interface em1 is attached. **
Listening on LPF/p34p1/ec:88:8f:f2:f4:2f/192.168.1.0/24 Sending on LPF/p34p1/ec:88:8f:f2:f4:2f/192.168.1.0/24 Sending on Socket/fallback/fallback-net
[1]+ Done /sbin/dhcpd [root@pig webadm]#
|