Linux網卡虛擬化

來源:互聯網
上載者:User

標籤:一張物理網卡虛擬化成兩虛擬網卡

一張物理網卡虛擬化成兩虛擬網卡(使用Vlan方法切分)使用操作步驟:

前期規劃準備:

  • eth1網卡正常使用

  • eth1所在交換器連接埠配置trunk allow vlan5 和public所需的vlanID(假如為2)

  • 舉例:假如eth1製成兩張虛擬網卡,一張作為儲存網路網卡為eth1.5,另外一張外部網路網卡為eth1.2

1. 載入802.1q模組

[[email protected] net]# modprobe 8021q     ---載入8021q

[[email protected] net]# lsmod |grep 8021q  ---檢查是否支援802.1q協議

8021q 28808 0

garp 14384 1 8021q

mrp 18542 1 8021q

[[email protected] net]# cat > /etc/sysconfig/modules/8021q.modules << EOF  ---開機自動掛在8021q模組

#!/bin/sh

if [ ! `lsmod | grep 8021q` ] ; then

exec /sbin/modprobe 8021q >/dev/null 2>&1

fi

EOF


2.虛擬網卡配置Vlan


儲存網路直接走vlan5,公網網路是vlan2

vi/etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1

ONBOOT=yes

BOOTPROTO=static


3.配置vlan虛擬網卡裝置

A.儲存虛擬網卡

[[email protected] net]#cd /etc/sysconfig/network-scripts/

[[email protected] net]#cp ifcfg-eth1 ifcfg-eth1.5

[[email protected] net]# vi ifcfg-eth1.5

DEVICE=eth1.5

TYPE=Ethernet

BOOTPROTO=static

ONBOOT=yes

IPADDR=192.168.10.1  ---儲存網路使用IP

PREFIX=24

VLAN=yes   ---保證在網路啟動時,去檢查這張虛擬網卡有沒有啟動


B.公網虛擬網卡

[[email protected] net]#cd /etc/sysconfig/network-scripts/

[[email protected] net]#cp ifcfg-eth1 ifcfg-eth1.2

[[email protected] net]# vi ifcfg-eth1.2

DEVICE=eth1.2         ---公網網路虛擬網卡,eth1.2 表示vlan2子介面,‘.’後面跟的數字幾就表示vlan幾

TYPE=Ethernet

BOOTPROTO=static

IPADDR=10.10.10.1  ---公網網路使用IP

PREFIX=24

ONBOOT=yes

VLAN=yes   ---保證在網路啟動時,去檢查這張虛擬網卡有沒有啟動


4.重啟網路 service network restart

A.檢查裝置

[[email protected] vlan]# ip a      ---能看到一個[email protected] 和[email protected]的網卡,表示配置成功


5.確認虛擬網卡可用

ping 192.168.10.3    測試儲存網路中其他物理伺服器,看是否網路能通



注意:最好再安裝vconfig-1.9-16.el7.x86_64.rpm


本文出自 “lucky dog” 部落格,請務必保留此出處http://703356.blog.51cto.com/693356/1670033

Linux網卡虛擬化

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.