Chinaunix首页 | 论坛 | 博客
  • 博客访问: 5429105
  • 博文数量: 3857
  • 博客积分: 6409
  • 博客等级: 准将
  • 技术积分: 15947
  • 用 户 组: 普通用户
  • 注册时间: 2008-09-02 16:48
个人简介

迷彩 潜伏 隐蔽 伪装

文章分类

全部博文(3857)

文章存档

2017年(5)

2016年(63)

2015年(927)

2014年(677)

2013年(807)

2012年(1241)

2011年(67)

2010年(7)

2009年(36)

2008年(28)

分类: LINUX

2015-01-13 15:09:55

CentOS 7系统配置上的变化解析

网络

[日期:2014-09-29] 来源:Linux社区  作者:panblack [字体:  ]
三、网络

setup工具还是保留了,但有区别,没有了网络配置,多了RHN(到底是跟一家子了)
[root@localhost ~]# setup

好吧,我们看看网络配置。 

[root@localhost ~]# cat /etc/resolv.conf 
# Generated by NetworkManager
nameserver 192.168.150.254

[root@localhost ~]# cat /etc/sysconfig/network
# Created by anaconda

[root@localhost ~]# ll /etc/sysconfig/network-scripts/ifcfg-*
-rw-r--r--. 1 root root 298 Jul  9 00:13 /etc/sysconfig/network-scripts/ifcfg-Auto_Ethernet
-rw-r--r--. 1 root root 288 Jul  8 23:12 /etc/sysconfig/network-scripts/ifcfg-enp0s3
-rw-r--r--. 1 root root 254 Apr  2 23:30 /etc/sysconfig/network-scripts/ifcfg-lo

[root@localhost ~]# ifconfig
enp0s3: flags=4163  mtu 1500
        inet 192.168.150.180  netmask 255.255.255.0  broadcast 192.168.150.255
        inet6 fe80::a00:27ff:fe9a:a688  prefixlen 64  scopeid 0x20
        ether 08:00:27:9a:a6:88  txqueuelen 1000  (Ethernet)
        RX packets 39317  bytes 2487945 (2.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2216  bytes 740115 (722.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10
        loop  txqueuelen 0  (Local Loopback)
        RX packets 6  bytes 504 (504.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 6  bytes 504 (504.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost ~]#

先改改主机名: 

[root@localhost ~]# echo "hostname cenots7.localdomain" >>/etc/sysconfig/network
[root@localhost ~]# reboot
Connection to 192.168.150.180 closed by remote host.
Connection to 192.168.150.180 closed.
xw@Opt9010:~$ ssh root@192.168.150.180
root@192.168.150.180's password: 
Last login: Thu Jul 10 10:01:09 2014
[root@cenots7 ~]# 

看看网卡配置文件: 

[root@cenots7 ~]# cd /etc/sysconfig/network-scripts/

[root@cenots7 network-scripts]# cat ifcfg-Auto_Ethernet 
HWADDR=08:00:27:9A:A6:88
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME="Auto Ethernet"
UUID=76304098-8f46-4185-8337-bb7f0d90423e
ONBOOT=yes

[root@cenots7 network-scripts]# cat ifcfg-enp0s3 
HWADDR=08:00:27:9A:A6:88
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s3
UUID=66a635c2-9600-437b-8cfb-57e9569f68da
ONBOOT=no

看看两个文件有啥不同: 

[root@cenots7 network-scripts]# diff ifcfg-Auto_Ethernet ifcfg-enp0s3 
14,16c14,16
< NAME="Auto Ethernet"
< UUID=76304098-8f46-4185-8337-bb7f0d90423e
< ONBOOT=yes
---
> NAME=enp0s3
> UUID=66a635c2-9600-437b-8cfb-57e9569f68da
> ONBOOT=no

两个文件MAC地址一样,ifcfg-Auto_Ethernet ONBOOT=yes,但是ifconfig结果显示的是enp0s3,有点儿费解了。

再看看我复制KVM虚拟机时经常要改的网卡MAC地址: 

root@cenots7 network-scripts]# ll /etc/udev/rules.d/
total 8
-rw-r--r--. 1 root root 134 Jul  9 00:47 60-vboxadd.rules
-rw-r--r--. 1 root root 352 Jul  4 00:38 98-kexec.rules

[root@cenots7 network-scripts]# cat /etc/udev/rules.d/98-kexec.rules 
SUBSYSTEM=="cpu", ACTION=="online", PROGRAM="/bin/systemctl try-restart kdump.service"
SUBSYSTEM=="cpu", ACTION=="offline", PROGRAM="/bin/systemctl try-restart kdump.service"
SUBSYSTEM=="memory", ACTION=="add", PROGRAM="/bin/systemctl try-restart kdump.service"
SUBSYSTEM=="memory", ACTION=="remove", PROGRAM="/bin/systemctl try-restart kdump.service"

[root@cenots7 network-scripts]# cat /etc/udev/rules.d/60-vboxadd.rules 
KERNEL=="vboxguest", NAME="vboxguest", OWNER="vboxadd", MODE="0660"
KERNEL=="vboxuser", NAME="vboxuser", OWNER="vboxadd", MODE="0666"

 

70-persistent-net.rules呢?

网卡MAC只在网卡配置文件里有,一旦变了我只需要改网卡配置文件?

[root@cenots7 network-scripts]# grep -r "08:00:27:9A:A6:88" /etc/
/etc/sysconfig/network-scripts/ifcfg-enp0s3:HWADDR=08:00:27:9A:A6:88
/etc/sysconfig/network-scripts/ifcfg-Auto_Ethernet:HWADDR=08:00:27:9A:A6:88

改一下网卡MAC 0800279AA688 -> 0800278C3746

 

改MAC后网卡不认了,测试结果是只需要改网卡配置文件的MAC,而且两个配置文件都要改才行。我顺便把DHCP改成了固定IP。

[root@cenots7 ~]# cat /etc/sysconfig/network-scripts/ifcfg-Auto_Ethernet 
HWADDR=08:00:27:8C:37:46
# HWADDR=08:00:27:9A:A6:88
TYPE=Ethernet
BOOTPROTO=static
IPADDR=192.168.150.180
NETMASK=255.255.255.0
GATEWAY=192.168.150.254
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=no
IPV6_DEFROUTE=no
IPV6_PEERDNS=no
IPV6_PEERROUTES=no
IPV6_FAILURE_FATAL=no
NAME="Auto Ethernet"
UUID=76304098-8f46-4185-8337-bb7f0d90423e
ONBOOT=yes

[root@cenots7 ~]# cat /etc/sysconfig/network-scripts/ifcfg-enp0s3 
HWADDR=08:00:27:8C:37:46
# HWADDR=08:00:27:9A:A6:88
TYPE=Ethernet
BOOTPROTO=static
IPADDR=192.168.150.180
NETMASK=255.255.255.0
GATEWAY=192.168.150.254
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=no
IPV6_AUTOCONF=no
IPV6_DEFROUTE=no
IPV6_PEERDNS=no
IPV6_PEERROUTES=no
IPV6_FAILURE_FATAL=no
NAME=enp0s3
UUID=66a635c2-9600-437b-8cfb-57e9569f68da
ONBOOT=no

好吧,这样初步解决了基础问题。

阅读(1251) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~