樹心幽徑

« 20160108換Linux核心(kernel-3.19.8)過程 | Main | 20160113換Linux核心(kernel-3.16.7)過程 »

20160112換Linux核心(kernel-3.19.8)過程
2016/01/13,13:21

20160112換Linux核心(kernel-3.19.8)過程
(1) 查系統現況
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.9.5 #1 SMP Thu Jan 7 13:12:24 CST 2016 i686 i686 i386 GNU/Linux
[root@localhost ~]# date
Mon Jan 11 15:09:55 CST 2016
[root@localhost ~]#

(2) 下載核心linux-3.19.8.tar.gz

[root@localhost ~]# wget ftp://linux.cis.nctu.edu.tw/kernel/linux/kernel/v3.x/linux-3.19.8.tar.gz
:
2016-01-11 15:16:03 (355 KB/s) - ‘linux-3.19.8.tar.gz’ saved [123146642]
[root@localhost ~]#

(3)解開核心

[root@localhost ~]# tar xvzf linux-3.19.8.tar.gz

(4) 建立/usr/src/linux符號連結

[root@localhost ~]# rm  /usr/src/linux
rm: remove symbolic link ‘/usr/src/linux’? y
[root@localhost ~]# ln -s /root/linux-3.19.8 /usr/src/linux
[root@localhost ~]# ls /usr/src -l
total 12
drwxr-xr-x. 2 root root 4096 Jul  8  2013 debug
drwxr-xr-x  2 root root 4096 Jan 11 13:06 ipt-netflow-
drwxr-xr-x. 4 root root 4096 Jan  6 17:06 kernels
lrwxrwxrwx  1 root root   18 Jan 11 17:07 linux -> /root/linux-3.19.8
[root@localhost ~]#


(5)用現有的組態為預設值建立核心組態

[root@localhost ~]# cd /usr/src/linux/

[root@localhost linux]# cp /boot/old.config-3.14.27-100.fc19.i686.PAE .config

[root@localhost linux]# make menuconfig

(6)閱讀說明檔
[root@localhost linux]# cat README |more

(7)編譯核心
[root@localhost linux]# make
ok

(8)列出剛編譯完成的核心
[root@localhost linux]# ls arch/x86/boot/bzImage -l
-rw-r--r-- 1 root root 5675104 Jan 12 15:54 arch/x86/boot/bzImage
[root@localhost linux]#

(9)查看不可手動修改的開機選單設定檔
[root@localhost linux]# cat /boot/grub2/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
:
(10)將新編的核心 及 組態檔 及System.map 拷至/boot目錄分別為vmlinuz-3.19.8及config-3.19.8 及 System.map-3.19.8
[root@localhost linux]# cp arch/x86/boot/bzImage /boot/vmlinuz-3.19.8
[root@localhost linux]# cp .config /boot/config-3.19.8
[root@localhost linux]# cp System.map /boot/System.map-3.19.8
[root@localhost linux]#

(11)安裝新的核心模組至/lib/modules/3.19.8
[root@localhost linux]# rm -rf /lib/modules/3.19.8
[root@localhost linux]# ls /lib/modules
3.14.27-100.fc19.i686.PAE  3.9.5  3.9.5-301.fc19.i686  3.9.5-301.fc19.i686.PAE
[root@localhost linux]# make modules_install
:
:
  INSTALL /lib/firmware/yam/9600.bin
  DEPMOD  3.19.8

[root@localhost linux]# ll /lib/modules/
total 20
drwxr-xr-x  6 root root 4096 Jan  5 17:34 3.14.27-100.fc19.i686.PAE
drwxr-xr-x  3 root root 4096 Jan 12 16:19 3.19.8
drwxr-xr-x  4 root root 4096 Jan 11 13:06 3.9.5
drwxr-xr-x  6 root root 4096 Jan  6 16:03 3.9.5-301.fc19.i686
drwxr-xr-x. 6 root root 4096 Jan  6 12:46 3.9.5-301.fc19.i686.PAE
[root@localhost linux]#

(12)建立initramfs
[root@localhost linux]# dracut -v /boot/initramfs-3.19.8.img 3.19.8
:
I: Wrote /boot/initramfs-3.19.8.img:
I: -rw------- 1 root root 26308183 Jan 12 16:29 /boot/initramfs-3.19.8.img
[root@localhost linux]#

(13)列出/boot
[root@localhost linux]# ll /boot
total 168178
-rw-r--r--  1 root root   148506 Jan 12 16:14 config-3.19.8
-rw-r--r--  1 root root   130928 Jun 12  2013 config-3.9.5-301.fc19.i686
-rw-r--r--. 1 root root   128562 Jun 12  2013 config-3.9.5-301.fc19.i686.PAE
-rw-r--r--  1 root root   128296 Jan 11 07:34 config-3.9.5-treehrt
drwxr-xr-x. 6 root root     1024 Jan 11 17:47 grub2
-rw-------. 1 root root 25509635 Dec 23 12:26 initramfs-0-rescue-fe190f81d1ab45818aafd3f4c1c5edd8.img
-rw-------  1 root root 26308183 Jan 12 16:29 initramfs-3.19.8.img
-rw-------  1 root root  8745331 Jan  6 16:03 initramfs-3.9.5-301.fc19.i686.img
-rw-------. 1 root root 16779573 Dec 23 12:26 initramfs-3.9.5-301.fc19.i686.PAE.img
-rw-------  1 root root 17736016 Jan 11 07:42 initramfs-3.9.5.img
-rw-------  1 root root  8236814 Jan 11 07:47 initramfs-3.9.5-treehrt.img
-rw-r--r--. 1 root root   557284 Jan  5 17:34 initrd-plymouth.img
drwx------. 2 root root    12288 Dec 23 12:05 lost+found
-rw-r--r--  1 root root   142005 Dec 18  2014 old.config-3.14.27-100.fc19.i686.PAE
-rw-r--r--  1 root root    97454 Jan 11 17:27 old.config-3.19.8
-rw-------  1 root root  9162360 Jan  5 17:34 old.initramfs-3.14.27-100.fc19.i686.PAE.img
-rw-------  1 root root  8242449 Jan 11 17:31 old.initramfs-3.19.8.img
-rw-------  1 root root  2244508 Dec 18  2014 old.System.map-3.14.27-100.fc19.i686.PAE
-rw-r--r--  1 root root  2513181 Jan 11 17:28 old.System.map-3.19.8
-rwxr-xr-x  1 root root  5471888 Dec 18  2014 old.vmlinuz-3.14.27-100.fc19.i686.PAE
-rwxr-xr-x  1 root root  5738112 Jan 11 17:27 old.vmlinuz-3.19.8
-rw-r--r--  1 root root  2348934 Jan 12 16:14 System.map-3.19.8
-rw-------  1 root root  2017641 Jun 12  2013 System.map-3.9.5-301.fc19.i686
-rw-------. 1 root root  2055042 Jun 12  2013 System.map-3.9.5-301.fc19.i686.PAE
-rw-r--r--  1 root root  2052858 Jan 11 07:35 System.map-3.9.5-treehrt
-rwxr-xr-x. 1 root root  5025072 Dec 23 12:26 vmlinuz-0-rescue-fe190f81d1ab45818aafd3f4c1c5edd8
-rw-r--r--  1 root root  5675104 Jan 12 16:14 vmlinuz-3.19.8
-rwxr-xr-x  1 root root  4939088 Jun 12  2013 vmlinuz-3.9.5-301.fc19.i686
-rwxr-xr-x. 1 root root  5025072 Jun 12  2013 vmlinuz-3.9.5-301.fc19.i686.PAE
-rwxr-xr-x  1 root root  5013728 Jan 11 07:33 vmlinuz-3.9.5-treehrt
[root@localhost linux]#
[root@localhost linux]# chmod 755 /boot/vmlinuz-3.19.8

(14)建立核心開機選單,最新編譯者為第1選項(預設選項)
[root@localhost linux]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.19.8
Found initrd image: /boot/initramfs-3.19.8.img
Found linux image: /boot/vmlinuz-3.9.5-treehrt
Found initrd image: /boot/initramfs-3.9.5-treehrt.img
Found linux image: /boot/vmlinuz-3.9.5-301.fc19.i686.PAE
Found initrd image: /boot/initramfs-3.9.5-301.fc19.i686.PAE.img
Found linux image: /boot/vmlinuz-3.9.5-301.fc19.i686
Found initrd image: /boot/initramfs-3.9.5-301.fc19.i686.img
Found linux image: /boot/vmlinuz-0-rescue-fe190f81d1ab45818aafd3f4c1c5edd8
Found initrd image: /boot/initramfs-0-rescue-fe190f81d1ab45818aafd3f4c1c5edd8.img
done
[root@localhost linux]#


[root@localhost linux]# date
Tue Jan 12 16:38:34 CST 2016
[root@localhost linux]# uname -a
Linux localhost.localdomain 3.9.5 #1 SMP Thu Jan 7 13:12:24 CST 2016 i686 i686 i386 GNU/Linux
[root@localhost linux]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/i686-redhat-linux/4.8.3/lto-wrapper
Target: i686-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-isl=/builddir/build/BUILD/gcc-4.8.3-20140911/obj-i686-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.3-20140911/obj-i686-redhat-linux/cloog-install --with-tune=generic --with-arch=i686 --build=i686-redhat-linux
Thread model: posix
gcc version 4.8.3 20140911 (Red Hat 4.8.3-7) (GCC)
[root@localhost linux]#

(15)遠端重開機查看,新的Linux核心成功運中中
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.19.8 #2 SMP Tue Jan 12 15:54:22 CST 2016 i686 i686 i386 GNU  /Linux

Good, It's success!!
(15b)But
[root@localhost ~]# iptables -t nat -L
iptables v1.6.0: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
[root@localhost ~]#


(16)參考文章
REF 1:http://linux.vbird.org/linux_basic/0540kernel.php
REF 2:http://linux.vbird.org/linux_basic/redhat6.1/linux_10kernel.php

(17)
[root@localhost linux]# make menuconfig

(18)
[root@localhost linux]# make
scripts/kconfig/conf --silentoldconfig Kconfig
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CALL    scripts/checksyscalls.sh
  CHK     include/generated/compile.h
  CERTS   kernel/x509_certificate_list
  - Including cert signing_key.x509
  AS      kernel/system_certificates.o
  LD      kernel/built-in.o
  CC [M]  net/ipv4/netfilter/nf_nat_l3proto_ipv4.o
  CC [M]  net/ipv4/netfilter/nf_nat_proto_icmp.o
  LD [M]  net/ipv4/netfilter/nf_nat_ipv4.o
  CC [M]  net/ipv4/netfilter/nf_nat_h323.o
  CC [M]  net/ipv4/netfilter/nf_nat_pptp.o
  CC [M]  net/ipv4/netfilter/nf_nat_snmp_basic.o
  CC [M]  net/ipv4/netfilter/nf_nat_masquerade_ipv4.o
  CC [M]  net/ipv4/netfilter/nf_nat_proto_gre.o
  CC [M]  net/ipv4/netfilter/nft_chain_nat_ipv4.o
  CC [M]  net/ipv4/netfilter/nft_masq_ipv4.o
  CC [M]  net/ipv4/netfilter/iptable_nat.o
  CC [M]  net/ipv4/netfilter/ipt_MASQUERADE.o
  CC [M]  net/ipv6/netfilter/nf_nat_l3proto_ipv6.o
  CC [M]  net/ipv6/netfilter/nf_nat_proto_icmpv6.o
  LD [M]  net/ipv6/netfilter/nf_nat_ipv6.o
  CC [M]  net/ipv6/netfilter/nft_chain_nat_ipv6.o
  CC [M]  net/netfilter/nf_conntrack_core.o
  LD [M]  net/netfilter/nf_conntrack.o
  CC [M]  net/netfilter/nf_conntrack_netlink.o
  CC [M]  net/netfilter/nf_nat_core.o
  CC [M]  net/netfilter/nf_nat_proto_unknown.o
  CC [M]  net/netfilter/nf_nat_proto_common.o
  CC [M]  net/netfilter/nf_nat_proto_udp.o
  CC [M]  net/netfilter/nf_nat_proto_tcp.o
  CC [M]  net/netfilter/nf_nat_helper.o
  LD [M]  net/netfilter/nf_nat.o
  CC [M]  net/netfilter/nf_nat_redirect.o
  CC [M]  net/netfilter/nf_nat_proto_dccp.o
  CC [M]  net/netfilter/nf_nat_proto_udplite.o
  CC [M]  net/netfilter/nf_nat_proto_sctp.o
  CC [M]  net/netfilter/nf_nat_ftp.o
  CC [M]  net/netfilter/nf_nat_irc.o
  CC [M]  net/netfilter/nf_nat_sip.o
  CC [M]  net/netfilter/nft_nat.o
  CC [M]  net/netfilter/nft_masq.o
  CC [M]  net/netfilter/xt_nat.o
  CC [M]  net/netfilter/xt_NETMAP.o
  CC [M]  net/netfilter/xt_REDIRECT.o
  CC [M]  net/netfilter/ipvs/ip_vs_ftp.o
  CHK     include/generated/uapi/linux/version.h
  LINK    vmlinux
  LD      vmlinux.o
  MODPOST vmlinux.o
  GEN     .version
  CHK     include/generated/compile.h
  UPD     include/generated/compile.h
  CC      init/version.o
  LD      init/built-in.o
  KSYM    .tmp_kallsyms1.o
  KSYM    .tmp_kallsyms2.o
  LD      vmlinux
  SORTEX  vmlinux
  SYSMAP  System.map
  TEST    posttest
Succeed: decoded and checked 1990523 instructions
  TEST    posttest
arch/x86/tools/insn_sanity: Success: decoded and checked 1000000 random instructions with 0 errors (seed:0xd3597a2f)
  VOFFSET arch/x86/boot/voffset.h
  OBJCOPY arch/x86/boot/compressed/vmlinux.bin
  RELOCS  arch/x86/boot/compressed/vmlinux.relocs
  GZIP    arch/x86/boot/compressed/vmlinux.bin.gz
  MKPIGGY arch/x86/boot/compressed/piggy.S
  AS      arch/x86/boot/compressed/piggy.o
  LD      arch/x86/boot/compressed/vmlinux
  ZOFFSET arch/x86/boot/zoffset.h
  AS      arch/x86/boot/header.o
  CC      arch/x86/boot/version.o
  LD      arch/x86/boot/setup.elf
  OBJCOPY arch/x86/boot/setup.bin
  OBJCOPY arch/x86/boot/vmlinux.bin
  BUILD   arch/x86/boot/bzImage
Setup is 17100 bytes (padded to 17408 bytes).
System is 5526 kB
CRC abdc9002
Kernel: arch/x86/boot/bzImage is ready  (#3)
  Building modules, stage 2.
  MODPOST 2629 modules
  CC      net/ipv4/netfilter/ipt_MASQUERADE.mod.o
  LD [M]  net/ipv4/netfilter/ipt_MASQUERADE.ko
  CC      net/ipv4/netfilter/iptable_nat.mod.o
  LD [M]  net/ipv4/netfilter/iptable_nat.ko
  LD [M]  net/ipv4/netfilter/nf_nat_h323.ko
  LD [M]  net/ipv4/netfilter/nf_nat_ipv4.ko
  CC      net/ipv4/netfilter/nf_nat_masquerade_ipv4.mod.o
  LD [M]  net/ipv4/netfilter/nf_nat_masquerade_ipv4.ko
  LD [M]  net/ipv4/netfilter/nf_nat_pptp.ko
  LD [M]  net/ipv4/netfilter/nf_nat_proto_gre.ko
  LD [M]  net/ipv4/netfilter/nf_nat_snmp_basic.ko
  LD [M]  net/ipv4/netfilter/nft_chain_nat_ipv4.ko
  CC      net/ipv4/netfilter/nft_masq_ipv4.mod.o
  LD [M]  net/ipv4/netfilter/nft_masq_ipv4.ko
  LD [M]  net/ipv6/netfilter/nf_nat_ipv6.ko
  LD [M]  net/ipv6/netfilter/nft_chain_nat_ipv6.ko
  LD [M]  net/netfilter/ipvs/ip_vs_ftp.ko
  LD [M]  net/netfilter/nf_conntrack.ko
  LD [M]  net/netfilter/nf_conntrack_netlink.ko
  LD [M]  net/netfilter/nf_nat.ko
  LD [M]  net/netfilter/nf_nat_ftp.ko
  LD [M]  net/netfilter/nf_nat_irc.ko
  LD [M]  net/netfilter/nf_nat_proto_dccp.ko
  LD [M]  net/netfilter/nf_nat_proto_sctp.ko
  LD [M]  net/netfilter/nf_nat_proto_udplite.ko
  LD [M]  net/netfilter/nf_nat_redirect.ko
  LD [M]  net/netfilter/nf_nat_sip.ko
  CC      net/netfilter/nft_masq.mod.o
  LD [M]  net/netfilter/nft_masq.ko
  LD [M]  net/netfilter/nft_nat.ko
  LD [M]  net/netfilter/xt_NETMAP.ko
  LD [M]  net/netfilter/xt_REDIRECT.ko
  CC      net/netfilter/xt_nat.mod.o
  LD [M]  net/netfilter/xt_nat.ko

(19)
[root@localhost boot]# mv vmlinuz-3.19.8 old2.vmlinuz-3.19.8
[root@localhost boot]# mv initramfs-3.19.8.img old2.initramfs-3.19.8.img
[root@localhost boot]# mv System.map-3.19.8 old2.System.map-3.19.8
[root@localhost boot]# mv config-3.19.8 old2.config-3.19.8

(20)
[root@localhost boot]# cd /usr/src/linux/
[root@localhost linux]# cp arch/x86/boot/bzImage /boot/vmlinuz-3.19.8
[root@localhost linux]# cp .config /boot/config-3.19.8
[root@localhost linux]# cp System.map /boot/System.map-3.19.8
[root@localhost linux]#

(21)
[root@localhost linux]# make modules_install
:
  INSTALL sound/usb/usx2y/snd-usb-us122l.ko
  INSTALL sound/usb/usx2y/snd-usb-usx2y.ko
  DEPMOD  3.19.8
[root@localhost linux]#
(22)
[root@localhost linux]# ll /lib/modules/
total 20
drwxr-xr-x  6 root root 4096 Jan  5 17:34 3.14.27-100.fc19.i686.PAE
drwxr-xr-x  3 root root 4096 Jan 13 07:55 3.19.8
drwxr-xr-x  4 root root 4096 Jan 11 13:06 3.9.5
drwxr-xr-x  6 root root 4096 Jan  6 16:03 3.9.5-301.fc19.i686
drwxr-xr-x. 6 root root 4096 Jan  6 12:46 3.9.5-301.fc19.i686.PAE
[root@localhost linux]#

(23)
[root@localhost linux]#  dracut -v /boot/initramfs-3.19.8.img 3.19.8
:
I: Wrote /boot/initramfs-3.19.8.img:
I: -rw------- 1 root root 19461944 Jan 13 07:57 /boot/initramfs-3.19.8.img

(24)
[root@localhost linux]#  ll /boot
total 195167
-rw-r--r--  1 root root   148612 Jan 13 07:51 config-3.19.8
-rw-r--r--  1 root root   130928 Jun 12  2013 config-3.9.5-301.fc19.i686
-rw-r--r--. 1 root root   128562 Jun 12  2013 config-3.9.5-301.fc19.i686.PAE
-rw-r--r--  1 root root   128296 Jan 11 07:34 config-3.9.5-treehrt
drwxr-xr-x. 6 root root     1024 Jan 12 17:53 grub2
-rw-------. 1 root root 25509635 Dec 23 12:26 initramfs-0-rescue-fe190f81d1ab45818aafd3f4c1c5edd8.img
-rw-------  1 root root 19461944 Jan 13 07:57 initramfs-3.19.8.img
-rw-------  1 root root  8745331 Jan  6 16:03 initramfs-3.9.5-301.fc19.i686.img
-rw-------. 1 root root 16779573 Dec 23 12:26 initramfs-3.9.5-301.fc19.i686.PAE.img
-rw-------  1 root root 17736016 Jan 11 07:42 initramfs-3.9.5.img
-rw-------  1 root root  8236814 Jan 11 07:47 initramfs-3.9.5-treehrt.img
-rw-r--r--. 1 root root   557284 Jan  5 17:34 initrd-plymouth.img
drwx------. 2 root root    12288 Dec 23 12:05 lost+found
-rw-r--r--  1 root root   148506 Jan 12 16:14 old2.config-3.19.8
-rw-------  1 root root 26308183 Jan 12 16:29 old2.initramfs-3.19.8.img
-rw-r--r--  1 root root  2348934 Jan 12 16:14 old2.System.map-3.19.8
-rwxr-xr-x  1 root root  5675104 Jan 12 16:14 old2.vmlinuz-3.19.8
-rw-r--r--  1 root root   142005 Dec 18  2014 old.config-3.14.27-100.fc19.i686.PAE
-rw-r--r--  1 root root    97454 Jan 11 17:27 old.config-3.19.8
-rw-------  1 root root  9162360 Jan  5 17:34 old.initramfs-3.14.27-100.fc19.i686.PAE.img
-rw-------  1 root root  8242449 Jan 11 17:31 old.initramfs-3.19.8.img
-rw-------  1 root root  2244508 Dec 18  2014 old.System.map-3.14.27-100.fc19.i686.PAE
-rw-r--r--  1 root root  2513181 Jan 11 17:28 old.System.map-3.19.8
-rwxr-xr-x  1 root root  5471888 Dec 18  2014 old.vmlinuz-3.14.27-100.fc19.i686.PAE
-rwxr-xr-x  1 root root  5738112 Jan 11 17:27 old.vmlinuz-3.19.8
-rw-r--r--  1 root root  2348934 Jan 13 07:51 System.map-3.19.8
-rw-------  1 root root  2017641 Jun 12  2013 System.map-3.9.5-301.fc19.i686
-rw-------. 1 root root  2055042 Jun 12  2013 System.map-3.9.5-301.fc19.i686.PAE
-rw-r--r--  1 root root  2052858 Jan 11 07:35 System.map-3.9.5-treehrt
-rwxr-xr-x. 1 root root  5025072 Dec 23 12:26 vmlinuz-0-rescue-fe190f81d1ab45818aafd3f4c1c5edd8
-rw-r--r--  1 root root  5675104 Jan 13 07:51 vmlinuz-3.19.8
-rwxr-xr-x  1 root root  4939088 Jun 12  2013 vmlinuz-3.9.5-301.fc19.i686
-rwxr-xr-x. 1 root root  5025072 Jun 12  2013 vmlinuz-3.9.5-301.fc19.i686.PAE
-rwxr-xr-x  1 root root  5013728 Jan 11 07:33 vmlinuz-3.9.5-treehrt
[root@localhost linux]#

(25)
[root@localhost linux]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.19.8
Found initrd image: /boot/initramfs-3.19.8.img
Found linux image: /boot/vmlinuz-3.9.5-treehrt
Found initrd image: /boot/initramfs-3.9.5-treehrt.img
Found linux image: /boot/vmlinuz-3.9.5-301.fc19.i686.PAE
Found initrd image: /boot/initramfs-3.9.5-301.fc19.i686.PAE.img
Found linux image: /boot/vmlinuz-3.9.5-301.fc19.i686
Found initrd image: /boot/initramfs-3.9.5-301.fc19.i686.img
Found linux image: /boot/vmlinuz-0-rescue-fe190f81d1ab45818aafd3f4c1c5edd8
Found initrd image: /boot/initramfs-0-rescue-fe190f81d1ab45818aafd3f4c1c5edd8.img
done
[root@localhost linux]#
[root@localhost linux]# uname -a
Linux localhost.localdomain 3.19.8 #2 SMP Tue Jan 12 15:54:22 CST 2016 i686 i686 i386 GNU/Linux
[root@localhost linux]# reboot


(26)

[root@localhost ~]# uname -a
Linux localhost.localdomain 3.19.8 #3 SMP Wed Jan 13 07:43:30 CST 2016 i686 i686 i386 GNU/Linux
[root@localhost ~]#

(27) But
[root@localhost ~]# iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination

(28)

[root@localhost ~]# /etc/rc.d/rc.local
[root@localhost ~]# iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination

Chain INPUT (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination
MASQUERADE  all  --  10.2.2.0/24          anywhere
[root@localhost ~]#

[root@localhost ~]# cat /etc/rc.d/rc.local
#!/bin/sh
#/usr/sbin/dhcpd &

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 -o eth0 -s 10.1.1.0/24  -j MASQUERADE
iptables -t nat -A POSTROUTING -s 10.2.2.0/24  -j MASQUERADE

[root@localhost ~]#

迴響

Comment Icon
Posted by: sadsad at 2016/04/27, 14:56
 
Accessible and Valid XHTML 1.0 Strict and CSS Powered by LifeType