四、confignetwork-創(chuàng)新互聯(lián)

1、學(xué)習(xí)rhel7中新的網(wǎng)絡(luò)配置工具和網(wǎng)卡命名規(guī)則

成都創(chuàng)新互聯(lián)公司-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價比雙陽網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式雙陽網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋雙陽地區(qū)。費(fèi)用合理售后完善,十載實(shí)體公司更值得信賴。

下面這段文字參考紅帽官網(wǎng)網(wǎng)絡(luò)配置第8章2節(jié),在rhel7/centos7中網(wǎng)卡的命名規(guī)則有些改變,增加了nmcli網(wǎng)絡(luò)管理工具。

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、配置網(wǎng)卡使用rhel6版本的網(wǎng)卡配置方式:

[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

  • 編輯網(wǎng)卡配置文件ifcfg-eno16777736修改為ifcfg-eth0,修改DEVICE,NAME,HWADDR,NM_CONTROLLED等參數(shù).

  • 禁用ipv6和biosdevname功能,傳遞這2個參數(shù)給kernel:net.ifnames=0 ipv6.disable=1,重新生成grub.cfg配置文件即可

我們來具體操作一把:

[root@station71 network-scripts]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 #這塊叫啥沒有關(guān)系的哈!

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  #給內(nèi)核傳遞參數(shù)關(guān)閉biosdevname功能關(guān)閉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

現(xiàn)在重啟看到我們的網(wǎng)卡應(yīng)該是eth0了、如果改個網(wǎng)卡的名字都需要重啟,那還搞毛線,事實(shí)上是uptime在幾千的很常見。

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

[root@station71 network-scripts]# ethtool-i  eno16777736   #網(wǎng)卡的驅(qū)動名字

driver: e1000

[root@station71 network-scripts]# modinfo  e1000      #網(wǎng)卡的驅(qū)動程序所在的模塊

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     #卸載網(wǎng)卡驅(qū)動模塊

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

[root@station71 network-scripts]# modprobee1000      #重新加載網(wǎng)卡驅(qū)動

3、nmcli工具使用及NetworkManager服務(wù)

需求1:

配置倆個虛擬機(jī)網(wǎng)絡(luò),一個橋接到物理網(wǎng)絡(luò)的無線路由器,一個選擇自定義網(wǎng)絡(luò)配置一個192.168.99.0的網(wǎng)段,編輯虛擬機(jī)配置2張網(wǎng)卡。eno16777736用于橋接和eno33554984用于虛擬機(jī)私有網(wǎng)絡(luò)

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 ---

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

名稱欄目:四、confignetwork-創(chuàng)新互聯(lián)
文章網(wǎng)址:http://muchs.cn/article0/coeeio.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)、App開發(fā)、品牌網(wǎng)站建設(shè)、云服務(wù)器、ChatGPT、面包屑導(dǎo)航

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計(jì)公司