1、學(xué)習(xí)rhel7中新的網(wǎng)絡(luò)配置工具和網(wǎng)卡命名規(guī)則
下面這段文字參考紅帽官網(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個(gè)參數(shù)給kernel:net.ifnames=0 ipv6.disable=1,重新生成grub.cfg配置文件即可
我們來(lái)具體操作一把: [root@station71 network-scripts]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 #這塊叫啥沒(méi)有關(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了、如果改個(gè)網(wǎng)卡的名字都需要重啟,那還搞毛線,事實(shí)上是uptime在幾千的很常見(jiàn)。 [root@station71 network-scripts]# ifconfig eno16777736 down [root@station71 network-scripts]# ethtool-i eno16777736 #網(wǎng)卡的驅(qū)動(dòng)名字 driver: e1000 [root@station71 network-scripts]# modinfo e1000 #網(wǎng)卡的驅(qū)動(dòng)程序所在的模塊 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ū)動(dòng)模塊 [root@station71 network-scripts]# lsmod|grep e1000 #查看一下 [root@station71 network-scripts]# modprobee1000 #重新加載網(wǎng)卡驅(qū)動(dòng) |
3、nmcli工具使用及NetworkManager服務(wù)
需求1:
配置倆個(gè)虛擬機(jī)網(wǎng)絡(luò),一個(gè)橋接到物理網(wǎng)絡(luò)的無(wú)線路由器,一個(gè)選擇自定義網(wǎng)絡(luò)配置一個(gè)192.168.99.0的網(wǎng)段,編輯虛擬機(jī)配置2張網(wǎng)卡。eno16777736用于橋接和eno33554984用于虛擬機(jī)私有網(wǎng)絡(luò)
1、給eno16777736配置三個(gè)connection,其中兩個(gè)dhcp自動(dòng)獲取,另外一個(gè)需手動(dòng)配置ip地址信息192.168.100.77/24和gateway配置192.168.100.1域名解析地址配置為202.106.46.151
2、給eno33554984配置一個(gè)connection,需手動(dòng)配置一個(gè)ip地址信息
工作一個(gè)號(hào),家庭一個(gè)號(hào),兩不耽誤!
[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元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
名稱欄目:四、confignetwork-創(chuàng)新互聯(lián)
文章網(wǎng)址:http://jinyejixie.com/article0/coeeio.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開(kāi)發(fā)、App開(kāi)發(fā)、品牌網(wǎng)站建設(shè)、云服務(wù)器、ChatGPT、面包屑導(dǎo)航
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容