快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

四、confignetwork-创新互联

1、学习rhel7中新的网络配置工具和网卡命名规则

成都创新互联公司-专业网站定制、快速模板网站建设、高性价比双阳网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式双阳网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖双阳地区。费用合理售后完善,十载实体公司更值得信赖。

下面这段文字参考红帽官网网络配置第8章2节,在rhel7/centos7中网卡的命名规则有些改变,增加了nmcli网络管理工具。

1、A rule in /usr/lib/udev/rules.d/60-net.rules instructs the udev helper utility, /lib/udev/rename_device, to look into all /etc/sysconfig/network-scripts/ifcfg-suffix files. If it finds an ifcfg file with a HWADDR entry matching the MAC address of an interface it renames the interface to the name given in the ifcfg file by the DEVICE directive.
2、A rule in /usr/lib/udev/rules.d/71-biosdevname.rules instructs biosdevname to rename the interface according to its naming policy, provided that it was not renamed in a previous step, biosdevname is installed, and biosdevname=0 was not given as a kernel command on the boot command line.

3、A rule in /lib/udev/rules.d/75-net-description.rules instructs udev to fill in the internal udev device property values ID_NET_NAME_ONBOARD, ID_NET_NAME_SLOT, ID_NET_NAME_PATH, ID_NET_NAME_MAC by examining the network interface device. Note, that some device properties might be undefined.

4、A rule in /usr/lib/udev/rules.d/80-net-name-slot.rules instructs udev to rename the interface, provided that it was not renamed in step 1 or 2, and the kernel parameter net.ifnames=0 was not given, according to the following priority: ID_NET_NAME_ONBOARD, ID_NET_NAME_SLOT, ID_NET_NAME_PATH. It falls through to the next in the list, if one is unset. If none of these are set, then the interface will not be renamed.

2、配置网卡使用rhel6版本的网卡配置方式:

[root@station66 ~]# cat /etc/udev/rules.d/70-persistent-net.rules

# This file was automatically generated by the /lib/udev/write_net_rules

# program, run by the persistent-net-generator.rules rules file.

#

# You can modify it, as long as you keep each rule on a single

# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100f (e1000)

SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:36:87:62", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

[root@station71 ~]# cat /etc/udev/rules.d/70-persistent-ipoib.rules

# This is a sample udev rules file that demonstrates how to get udev to

# set the name of IPoIB interfaces to whatever you wish.  There is a

# 16 character limit on network device names though, so don't go too nuts

#

# Important items to note: ATTR{type}=="32" is IPoIB interfaces, and the

# ATTR{address} match must start with ?* and only reference the last 8

# bytes of the address or else the address might not match on any given

# start of the IPoIB stack

#

# Note: as of rhel7, udev is case sensitive on the address field match

# and all addresses need to be in lower case.

#

# ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="32", ATTR{address}=="?*00:02:c9:03:00:31:78:f2", NAME="mlx4_ib3

  • 编辑网卡配置文件ifcfg-eno16777736修改为ifcfg-eth0,修改DEVICE,NAME,HWADDR,NM_CONTROLLED等参数.

  • 禁用ipv6和biosdevname功能,传递这2个参数给kernel:net.ifnames=0 ipv6.disable=1,重新生成grub.cfg配置文件即可

我们来具体操作一把:

[root@station71 network-scripts]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 #这块叫啥没有关系的哈!

TYPE=Ethernet

HWADDR=00:0c:29:95:b5:21

BOOTPROTO=none

NAME=eth0

DEVICE=eth0

ONBOOT=yes

IPADDR=192.168.99.71

PREFIX=24

GATEWAY=192.168.99.1

DNS1=202.106.46.151

[root@station71 ~]#vim  /etc/default/grub  +6  #给内核传递参数关闭biosdevname功能关闭ipv6.

GRUB_CMDLINE_LINUX="net.ifnames=0 ipv6.disable=1 rd.lvm.lv=rootvg/root rd.lvm.lv=rootvg/swap rhgb quiet"

[root@station71 ~]# grub2-mkconfig   /boot/grub2/grub.cfg

现在重启看到我们的网卡应该是eth0了、如果改个网卡的名字都需要重启,那还搞毛线,事实上是uptime在几千的很常见。

[root@station71 network-scripts]# ifconfig  eno16777736  down

[root@station71 network-scripts]# ethtool-i  eno16777736   #网卡的驱动名字

driver: e1000

[root@station71 network-scripts]# modinfo  e1000      #网卡的驱动程序所在的模块

filename:    /lib/modules/3.10.0-327.el7.x86_64/kernel/drivers/net/ethernet/intel/e1000/e1000.ko

[root@station71 network-scripts]# modprobe  -r  e1000     #卸载网卡驱动模块

[root@station71 network-scripts]# lsmod|grep  e1000   #查看一下

[root@station71 network-scripts]# modprobee1000      #重新加载网卡驱动

3、nmcli工具使用及NetworkManager服务

需求1:

配置俩个虚拟机网络,一个桥接到物理网络的无线路由器,一个选择自定义网络配置一个192.168.99.0的网段,编辑虚拟机配置2张网卡。eno16777736用于桥接和eno33554984用于虚拟机私有网络

1、给eno16777736配置三个connection,其中两个dhcp自动获取,另外一个需手动配置ip地址信息192.168.100.77/24和gateway配置192.168.100.1域名解析地址配置为202.106.46.151

2、给eno33554984配置一个connection,需手动配置一个ip地址信息

工作一个号,家庭一个号,两不耽误!

[root@station71 ~]# nmcli  device

DEVICE    TYPE    STATE     CONNECTION

virbr0    bridge   connected   virbr0

eno50332208  ethernet  connected   eth3

eno16777736  ethernet  disconnected  --

eno33554984  ethernet  disconnected  --

lo      loopback  unmanaged   --

virbr0-nic  tap    unmanaged   --

[root@station71 ~]# nmcli connection add type ethernet ifname eno16777736  con-name eth0

Connection 'eth0' (3d0ea27f-aee7-4598-9c23-679fde3de18f) successfully added.

[root@station71 ~]# nmcli connection add type ethernet ifname eno16777736  con-name eth0.home

Connection 'eth0.home' (54ef6f15-7981-4f0d-9958-15d6adabb05c) successfully added.

[root@station71 ~]# nmcli connection add type ethernet ifname eno16777736  con-name eth0.work

Connection 'eth0.work' (07d80f13-d36d-43f0-9b07-0648dd91e164) successfully added.

[root@station71 ~]# nmcli connection modify eth0 ipv4.method manual ipv4.addresses 192.168.100.71/24 ipv4.gateway 192.168.100.1 ipv4.dns 202.106.46.151

[root@station71 ~]# nmcli connection modify eth0.home ipv4.method auto ipv4.dns 202.106.46.151

[root@station71 ~]# nmcli connection modify eth0.work ipv4.method auto ipv4.dns 202.106.195.68

[root@station71 ~]# nmcli connection add type ethernet ifname eno33554984  con-name eth2

Connection 'eth2' (8a97025f-4581-410f-80bd-31b5759970de) successfully added.

[root@station71 ~]# nmcli connection modify eth2 ipv4.method manual ipv4.addresses 192.168.99.71/24 ipv4.gateway 192.168.99.1

[root@station71 ~]# nmcli connection up eth0 ; nmcli  connection  up eth2

Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/31)

Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/32)

[root@station71 ~]# nmcli device

DEVICE    TYPE    STATE    CONNECTION

virbr0    bridge   connected  virbr0

eno16777736  ethernet  connected  eth0

eno33554984  ethernet  connected  eth2

eno50332208  ethernet  connected  eth3

lo      loopback  unmanaged  --

virbr0-nic  tap    unmanaged  --

[root@station71 ~]# nmcli connection show

NAME    UUID                  TYPE       DEVICE

virbr0   0d0064a4-b64e-44de-82c7-5f4eb991f1bd  bridge      virbr0

eth2    8a97025f-4581-410f-80bd-31b5759970de  802-3-ethernet  eno33554984

eth0.work  07d80f13-d36d-43f0-9b07-0648dd91e164  802-3-ethernet  --

eth0.home  54ef6f15-7981-4f0d-9958-15d6adabb05c  802-3-ethernet  --

eth0    3d0ea27f-aee7-4598-9c23-679fde3de18f  802-3-ethernet  eno16777736

eth3    919158d0-ecfc-468a-aa99-85891161a972  802-3-ethernet  eno50332208

[root@station71 ~]# nmcli connection show  --active

NAME   UUID                  TYPE       DEVICE

virbr0  0d0064a4-b64e-44de-82c7-5f4eb991f1bd  bridge      virbr0

eth2   8a97025f-4581-410f-80bd-31b5759970de  802-3-ethernet  eno33554984

eth0   3d0ea27f-aee7-4598-9c23-679fde3de18f  802-3-ethernet  eno16777736

eth3   919158d0-ecfc-468a-aa99-85891161a972  802-3-ethernet  eno50332208

[root@station71 ~]# ping  www.baidu.com

PING www.a.shifen.com (61.135.169.125) 56(84) bytes of data.

64 bytes from 61.135.169.125: icmp_seq=1 ttl=57 time=6.31 ms

^C

--- www.a.shifen.com ping statistics ---

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


分享文章:四、confignetwork-创新互联
网站网址:http://6mz.cn/article/coeeio.html

其他资讯