Skip to content

通过知识获得解放,通过技术获得自由

Menu
  • 专题目录
  • 液压相关
    • 液压技术
    • 液压相邻技术
    • 液压应用
  • 计算机相关
    • 计算机和软件
    • 网络和网站技术
  • 哲学
  • 关于本站
Menu

centos8 vlan设置[0]

Posted on 2023年11月14日2025年4月14日 by

本篇是centos8 添加网卡和设置静态ip的升级设置。

由于采用了新的网络架构,因此对于技术而言,需要解决vlan所涉及的所有设备的使用问题,本篇主要说明linux下的vlan的使用问题。

PVE下创建vlan网络设备

1)检查linux内核中的模块

lsmod | grep -i 8021q

若没有加载成功需要运行

# 加载802.1q模块
modprobe --first-time 8021q

2)命令创建vlan

创建vlan可以在现有的物理网口和现有的虚拟设备上添加,也可以给虚拟机新添加网络设备再添加vlan,推荐采用第二种。

现在第二个centos8网络设备上创建vlanid=10的设备

nmcli c add type vlan con-name vlan10 ifname vlan10 vlan.parent ens19 vlan.id 10

3)查看vlan设置

cd /etc/sysconfig/network-scripts/

会显示新创建的文件

查看创建的vlan设备

ls /proc/net/vlan/
cat /proc/net/vlan/config

设置后建议重启centos检查设置生效情况。

一个网口可以创建多个vlanid,每个vlan可以单独设置网络IP,就如真实存在的网卡一样。

4)删除vlan

nmcli device
ip link delete vlan10
ip add

 

补充说明:

1)PVE直接在虚拟机创建时设置vlan是对虚拟机内的网络是无效的

 

参考资料:

  1. https://blog.csdn.net/qq_44982815/article/details/117987276
  2. https://docs.oracle.com/zh-cn/learn/ol-vlans/index.html#view-vlan-configuration-files

欢迎回来

希望本站对你有所帮助!

如有疑问请联系info@fanlog.org
2023 年 11 月
一二三四五六日
 12345
6789101112
13141516171819
20212223242526
27282930 
« 6 月    

AI辅助 (17)

© 2025 | Powered by Superbs Personal Blog theme
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT