CentOS6.5的网卡配置和yum配置

前端之家收集整理的这篇文章主要介绍了CentOS6.5的网卡配置和yum配置前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

前言

给web同事写了so和java测试程序,在他的CentOS6.5虚拟机上,因为没有g++导致编译不过.
用yum安装g++时,提示没有这个软件包,于是就更新软件源,报错 “Couldn’t resolve host ‘apt.sw.be’”
前段正好做过在RedHat上更新软件源的实验,照着做了一次,还是报这个错。
没时间思考了,也没时间做实验,就将虚拟机克隆一份回来玩.
回来将yum源配通了,其实是原有系统中有其他.repo文件中有描述apt.sw.be这个挂掉的源,删掉就好。
既然花了时间做实验,就记录一下,下次就省时间了。照着实验记录做,我估计下次最多半小时搞定。

实验

实验分2个部分
* eth0网卡配置(vmware14.0 桥接)
问题: 克隆后,eth0无效了,网络配置变成了eth1,但是并没有eth1的实际配置文件
* yum源配置
问题: 报错 “Couldn’t resolve host ‘apt.sw.be’”

实验1-eth0网卡配置

  1. 克隆同事的虚拟机后,eth0配置无效,变成了eth1
  2.  
  3. 编辑 /etc/udev/rules.d/70-persistent-net.rules
  4. 删掉 eth0的配置,将最后一条eth1改为eth0
  5.  
  6. 修改完的/etc/udev/rules.d/70-persistent-net.rules
  7.  
  8. [root@localhost ~]# cat /etc/udev/rules.d/70-persistent-net.rules
  9. # This file was automatically generated by the /lib/udev/write_net_rules
  10. # program,run by the persistent-net-generator.rules rules file.
  11. #
  12. # You can modify it,as long as you keep each rule on a single
  13. # line,and change only the value of the NAME= key.
  14.  
  15. # PCI device 0x8086:0x100f (e1000)
  16. SUBSYSTEM=="net",ACTION=="add",DRIVERS=="?*",ATTR{address}=="00:0c:29:f7:df:e6",ATTR{type}=="1",KERNEL=="eth*",NAME="eth0"
  17.  
  18. eth0网卡配置文件中要定义正确的HWADDR,UUID
  19. ifconfig -a 查看正确的HWADDR
  20. uuidgen ifcfg-eth0 来产生ifcfg-eth0需要的新UUID
  21.  
  22. cd /etc/sysconfig/network-scripts/
  23. mkdir ./bk
  24. mv ./ifcfg-eth0 ./bk/ifcfg-eth0
  25.  
  26. 修改完的eth0网卡配置文件
  27. [root@localhost network-scripts]# cat ./ifcfg-eth0
  28. # @file /etc/sysconfig/network-scripts/ifcfg-eth0
  29.  
  30. DEVICE="eth0"
  31.  
  32. # how to get HWADDR ?
  33. # ifconfig -a
  34. HWADDR="00:0C:29:F7:DF:E6"
  35.  
  36. # how to gen uuid for eth0 ?
  37. # uuidgen ifcfg-eth0
  38. # 03e57a7a-7c71-4646-b0d2-9edf1fd34afe
  39. UUID="03e57a7a-7c71-4646-b0d2-9edf1fd34afe"
  40.  
  41. # IPV6INIT="yes"
  42. ONBOOT="yes"
  43. BOOTPROTO="static"
  44. TYPE="Ethernet"
  45. NM_CONTROLLED="no"
  46.  
  47. IPADDR=192.168.2.201
  48. NETMASK=255.255.255.0
  49. GATEWAY=192.168.2.2
  50.  
  51. DNS1=8.8.8.8
  52. DNS2=8.8.4.4
  53.  
  54. 重启计算机使网卡配置生效(好像重启网络服务并不好使)
  55. reboot

实验2-yum源配置

  1. # config CentOS6.5's yum source
  2.  
  3. # use xshell connect CentOS6.5
  4. ssh root@192.168.2.201
  5.  
  6. # view yum that was installed
  7. [root@localhost dev]# rpm -qa|grep yum
  8. yum-Metadata-parser-1.1.2-16.el6.x86_64
  9. yum-plugin-fastestmirror-1.1.30-30.el6.noarch
  10. yum-3.2.29-69.el6.centos.noarch
  11.  
  12. # uninstall yum that was installed
  13. rpm -e yum-Metadata-parser-1.1.2-16.el6.x86_64 yum-plugin-fastestmirror-1.1.30-30.el6.noarch yum-3.2.29-69.el6.centos.noarch python-meh-0.12.1-3.el6.noarch firstboot-1.110.15-1.el6.x86_64
  14.  
  15. # download yum component
  16. wget http://vault.centos.org/6.7/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm
  17. wget http://vault.centos.org/6.7/os/x86_64/Packages/yum-Metadata-parser-1.1.2-16.el6.x86_64.rpm
  18. wget http://vault.centos.org/6.7/os/x86_64/Packages/yum-3.2.29-69.el6.centos.noarch.rpm
  19. wget http://vault.centos.org/6.7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-30.el6.noarch.rpm
  20.  
  21. # install new yum
  22. rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm
  23. rpm -ivh yum-Metadata-parser-1.1.2-16.el6.x86_64.rpm
  24. rpm -ivh yum-3.2.29-69.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-30.el6.noarch.rpm
  25.  
  26. # open http://mirrors.163.com/.help/centos.html,download centos6's repo
  27. wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
  28.  
  29. # view OS's .repo files
  30. [root@localhost dev]# ls /etc/yum.repos.d/
  31. CentOS6-Base-163.repo CentOS-Base.repo.backup CentOS-Debuginfo.repo CentOS-Media.repo CentOS-Vault.repo mirrors-rpmforge mirrors-rpmforge-extras mirrors-rpmforge-testing rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm rpmforge.repo
  32.  
  33. # delete old .repo
  34. cd /etc/yum.repos.d/
  35. rm -f ./CentOS6-Base-163.repo
  36. rm -f ./CentOS-Base.repo.backup
  37.  
  38. # copy 163.repo as the new .repo
  39. cd /home/dev/
  40. cp ./CentOS6-Base-163.repo /etc/yum.repos.d/
  41.  
  42. # edit CentOS6-Base-163.repo,replace all $releasever to 6
  43. vi /etc/yum.repos.d/CentOS6-Base-163.repo
  44. :%s/$releasever/6
  45. wq
  46.  
  47. # clean yum cache,and make new yum cache
  48. yum clean all
  49. yum makecache
  50.  
  51. # when run yum makecache,report error below
  52. #"Couldn't resolve host 'apt.sw.be'"
  53. # view /etc/yum.repos.d/*.repo,find which .repo include apt.sw.be :)
  54. # find the apt.sw.be desc on /etc/yum.repos.d/rpmforge.repo,delete this repo file
  55. rm -f /etc/yum.repos.d/rpmforge.repo
  56.  
  57. # i remember,on RH5.x,when replace 163.repo,the /etc/yum.repos.d/ was empty
  58. # so,i want to try delete all the .repo file on /etc/yum.repos.d/ :)
  59. # rm other .repo,only keep the /etc/yum.repos.d/CentOS6-Base-163.repo
  60. rm -f /etc/yum.repos.d/CentOS-Vault.repo
  61. rm -f /etc/yum.repos.d/CentOS-Media.repo
  62. rm -f /etc/yum.repos.d/CentOS-Debuginfo.repo
  63.  
  64. # retry clean yum cache and make new yum cache
  65. yum clean all
  66. yum makecache
  67.  
  68. # now yum config ok
  69.  
  70. # can install all dev component for me
  71. yum install gcc
  72. yum install gcc-c++
  73. yum install gdb
  74.  
  75. # install bashdb
  76. cd /home/dev/
  77. wget --no-check-certificate https://sourceforge.net/projects/bashdb/files/bashdb/4.4-0.94/bashdb-4.4-0.94.tar.bz2/download
  78. bzip2 -dk ./bashdb-4.4-0.94.tar.bz2
  79. tar -xvf ./bashdb-4.4-0.94.tar
  80. cd ./bashdb-4.4-0.94
  81. ./configure --prefix=/usr
  82. make all
  83. make install
  84.  
  85. # download tcpdump and libpcap
  86. cd /home/dev/
  87. wget http://www.tcpdump.org/release/tcpdump-4.9.2.tar.gz
  88. tar -xzvf ./tcpdump-4.9.2.tar.gz
  89.  
  90. wget http://www.tcpdump.org/release/libpcap-1.8.1.tar.gz
  91. tar -xzvf ./libpcap-1.8.1.tar.gz
  92.  
  93. # build libpcap
  94. cd ./libpcap-1.8.1
  95.  
  96. # install component for libpcap
  97. yum install flex
  98. yum install bison
  99.  
  100. ./configure
  101. make all
  102. make install
  103.  
  104. # build tcpdump
  105. cd /home/dev/tcpdump-4.9.2
  106. ./configure --prefix=/home/dev/tcpdump_4.9.2_release
  107. make all
  108. make install
  109.  
  110. # run tcpdump for test
  111. cd /home/dev/tcpdump_4.9.2_release/sbin
  112. ./tcpdump
  113.  
  114. # perfect,this is a good nice day :)
  115. shutdown -hP now

猜你在找的CentOS相关文章