linux VLAN配置(vconfig)

1.安装vlan(vconfig)和加载8021q模块
#aptitude install vlan
#modprobe 8021q
或:
#yum install vconfig
#modprobe 8021q
#lsmod |grep -i 8021q

2.使用linux vconfig命令配置vlan
#vconfig add eth0 100
#vconfig add eth0 200
在eth0接口上配置两个VLAN
#vconfig set_flag eth0.100 1 1
#vconfig set_flag eth0.200 1 1
设置VLAN的REORDER_HDR参数,默认就行了。
可以使用cat /proc/net/vlan/eth0.100查看eth0.100参数
配置网络信息
#ifconfig eth0 0.0.0.0
#ifconfig eth0.100 192.168.100.50 netmask 255.255.255.0 up
#ifconfig eth0.200 192.168.200.50 netmask 255.255.255.0 up
删除VLAN命令
#vconfig rem eth0.100
#vconfig rem eth0.200 
3.将VLAN信息写入配置文件
#echo "modprobe 8021q">>/etc/rc.local
开机加载8021q模块,或者使用echo "8021q">>/etc/modules
#cp /etc/network/interfaces /etc/network/interfaces.default
#vim /etc/network/interfaces
auto lo eth0
iface lo inet loopback
iface eth0.100 inet static
    address 192.168.100.50
    netmask 255.255.255.0
iface eth0.200 inet static 
    address 192.168.200.50
    netmask 255.255.255.0
======================================================
VCONFIG(8)                                                          VCONFIG(8)
 
NAME
       vconfig - VLAN (802.1q) configuration program.
 
SYNOPSIS
       vconfig [lots of long options]
 
DESCRIPTION
       The  vconfig  program allows you to create and remove vlan-devices on a vlan enabled kernel. Vlan-devices are virtual ethernet devices
       which represents the virtual lans on the physical lan.
 
OPTIONS
       add [interface-name] [vlan-id]
              Creates a vlan-device on [interface-name]. The resulting vlan-device will be called according to the nameing convention set.
 
       rem [vlan-device]
              Removes the named vlan-device.
 
       set_flag [vlan-device] 0 | 1
              When 1, ethernet header reorders are turned on. Dumping the device will appear as a common ethernet device without vlans.  When
              0(default)  however,  ethernet headers are not reordered, which results in vlan tagged packets when dumping the device. Usually
              the default gives no problems, but some packet filtering programs might have problems with it.
 
       set_egress_map [vlan-device] [skb-priority] [vlan-qos]
              This flags that outbound packets with a particular skb-priority should be tagged with the particular  vlan  priority  vlan-qos.
              The default vlan priority is 0.
 
       set_ingress_map [vlan-device] [skb-priority] [vlan-qos]
              This flags that inbound packets with the particular vlan priority vlan-qos should be queued with a particular skb-priority. The
              default skb-priority is 0.
 
       set_name_type VLAN_PLUS_VID | VLAN_PLUS_VID_NO_PAD | DEV_PLUS_VID | DEV_PLUS_VID_NO_PAD
              Sets the way vlan-device names are created. Use vconfig without arguments to see the different formats.
 
       NOTES  VLAN will use Broadcom’s NICE interface when the network device supports it. This is necessary, since usually the  hardware  of
              these  devices  already  removes  the  vlan tag from the ethernet packet. The set_flag option on vlan-devices created on such a
              physical network device will be ignored.  Dumping the network-device will show only untagged(non-vlan) traffic, and dumping the
              vlan-devices will only show traffic intended for that vlan, without the tags.
 
FILES
       /proc/net/vlan/config
       /proc/net/vlan/[vlan-device]
 
SEE ALSO
       ip(8), ifconfig(8)
 
AUTHORS
       This manual page was written by Ard van Breemen <ard@kwaak.net>
       The vlan patch is written by Ben Greear <greearb@candelatech.com>
 
                                                                    VCONFIG(8)
(END) 
  • 0
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Linux VLAN配置是指在Linux操作系统中,通过虚拟局域网(VLAN)技术将一个物理网络划分为多个逻辑独立的虚拟网络,以实现不同网络设备之间的隔离与通信。 首先,在Linux系统中,我们可以使用vconfig命令来创建和管理VLAN。通过该命令,我们可以创建一个或多个虚拟网络接口,并为每个接口指定一个VLAN ID。例如,可以使用以下命令创建一个VLAN接口: vconfig add eth0 10 上述命令将为eth0物理接口创建一个VLAN ID为10的虚拟接口。接下来,我们可以使用ifconfig命令给该虚拟接口分配IP地址和其他相关网络参数,从而使其能够与其他设备进行通信。 另外,我们还可以通过修改系统的网络配置文件来实现VLAN的持久化配置。在大多数Linux发行版中,网络配置文件通常位于/etc/network/interfaces或/etc/sysconfig/network-scripts目录中。我们可以在该文件中添加类似如下的配置: auto eth0.10 iface eth0.10 inet static address 192.168.1.10 netmask 255.255.255.0 vlan_raw_device eth0 上述配置将为VLAN ID为10的虚拟接口eth0.10分配静态IP地址为192.168.1.10,并指定其底层的物理接口为eth0。 最后,为了实现不同VLAN之间的通信,我们还需要在Linux系统上配置路由策略。可以使用ip命令来添加静态路由或者使用动态路由协议,如OSPF或RIP等。路由配置的具体方法与网络环境和需求有关。 总结起来,Linux VLAN配置涉及创建虚拟网络接口、为其分配IP地址、修改网络配置文件以及配置路由策略等步骤。这些操作可通过命令行工具来完成,也可以通过修改网络配置文件实现持久化配置。使用Linux VLAN技术,可以灵活地划分和管理网络资源,实现网络设备之间的隔离和通信。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值