RHEL7.2 配置VLAN連接網(wǎng)絡(luò)

CONFIGURE 802.1Q VLAN TAGGING USING THE COMMAND LINE

In Red Hat Enterprise Linux 7, the8021qmodule is loaded by default. If necessary, you can make sure that the module is loaded by issuing the following command asroot:

~]#modprobe --first-time 8021qmodprobe: ERROR: could not insert '8021q': Module already in kernel

To display information about the module, issue the following command:

~]$modinfo 8021q

See themodprobe(8)man page for more command options.

7.4.1.?Setting Up 802.1Q VLAN Tagging Using ifcfg Files

Configure the parent interface in/etc/sysconfig/network-scripts/ifcfg-ethX, whereXis a unique number corresponding to a specific interface, as follows:

DEVICE=ethX

TYPE=Ethernet

BOOTPROTO=none

ONBOOT=yes

Configure the VLAN interface configuration in the/etc/sysconfig/network-scripts/directory. The configuration file name should be the parent interface plus a.character plus the VLAN ID number. For example, if the VLAN ID is 192, and the parent interface iseth0, then the configuration file name should beifcfg-eth0.192:

DEVICE=ethX.192

BOOTPROTO=none

ONBOOT=yes

IPADDR=192.168.1.1

PREFIX=24

NETWORK=192.168.1.0

VLAN=yes

If there is a need to configure a second VLAN, with for example, VLAN ID 193, on the same interface,eth0, add a new file with the nameeth0.193with the VLAN configuration details.

Restart the networking service in order for the changes to take effect. Asrootissue the following command:

~]#systemctl restart network

7.4.2.?Configure 802.1Q VLAN Tagging Using ip Commands

To create an 802.1Q VLAN interface on Ethernet interfaceeth0, with nameVLAN8and ID8, issue a command asrootas follows:

~]#ip link add linketh0nameeth0.8type vlan id 8

To view the VLAN, issue the following command:

~]$ip -d link showeth0.84: eth0.8@eth0: mtu 1500 qdisc noqueue state UP mode DEFAULT? ? link/ether 52:54:00:ce:5f:6c brd ff:ff:ff:ff:ff:ff promiscuity 0? ? vlan protocol 802.1Q id 8

Note that theiputility interprets the VLAN ID as a hexadecimal value if it is preceded by0xand as an octal value if it has a leading0. This means that in order to assign a VLAN ID with a decimal value of22, you must not add any leading zeros.

To remove the VLAN, issue a command asrootas follows:

~]#ip link deleteeth0.8

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末立肘,一起剝皮案震驚了整個(gè)濱河市边坤,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌谅年,老刑警劉巖茧痒,帶你破解...
    沈念sama閱讀 218,284評(píng)論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異融蹂,居然都是意外死亡文黎,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,115評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門(mén)殿较,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)耸峭,“玉大人,你說(shuō)我怎么就攤上這事淋纲±湍郑” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 164,614評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵洽瞬,是天一觀的道長(zhǎng)本涕。 經(jīng)常有香客問(wèn)我,道長(zhǎng)伙窃,這世上最難降的妖魔是什么菩颖? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 58,671評(píng)論 1 293
  • 正文 為了忘掉前任,我火速辦了婚禮为障,結(jié)果婚禮上晦闰,老公的妹妹穿的比我還像新娘放祟。我一直安慰自己,他們只是感情好呻右,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,699評(píng)論 6 392
  • 文/花漫 我一把揭開(kāi)白布跪妥。 她就那樣靜靜地躺著,像睡著了一般声滥。 火紅的嫁衣襯著肌膚如雪眉撵。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書(shū)人閱讀 51,562評(píng)論 1 305
  • 那天落塑,我揣著相機(jī)與錄音纽疟,去河邊找鬼。 笑死憾赁,一個(gè)胖子當(dāng)著我的面吹牛污朽,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播缠沈,決...
    沈念sama閱讀 40,309評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼膘壶,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了洲愤?” 一聲冷哼從身側(cè)響起颓芭,我...
    開(kāi)封第一講書(shū)人閱讀 39,223評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎柬赐,沒(méi)想到半個(gè)月后亡问,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,668評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡肛宋,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,859評(píng)論 3 336
  • 正文 我和宋清朗相戀三年州藕,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片酝陈。...
    茶點(diǎn)故事閱讀 39,981評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡床玻,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出沉帮,到底是詐尸還是另有隱情锈死,我是刑警寧澤,帶...
    沈念sama閱讀 35,705評(píng)論 5 347
  • 正文 年R本政府宣布穆壕,位于F島的核電站待牵,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏喇勋。R本人自食惡果不足惜缨该,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,310評(píng)論 3 330
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望川背。 院中可真熱鬧贰拿,春花似錦蛤袒、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 31,904評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)皱碘。三九已至团赏,卻和暖如春账阻,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 33,023評(píng)論 1 270
  • 我被黑心中介騙來(lái)泰國(guó)打工斜纪, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人咪橙。 一個(gè)月前我還...
    沈念sama閱讀 48,146評(píng)論 3 370
  • 正文 我出身青樓层扶,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親都办。 傳聞我的和親對(duì)象是個(gè)殘疾皇子嫡锌,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,933評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容