配置网卡为vlan trunk

 http://www.microhowto.info/tutorials/802.1q.html

 

Configure an Ethernet interface as a VLAN trunk

host需要连接2个 VLANs, 192.168.2.1/24 on VLAN 2 and 192.168.3.1/24 on VLAN 3

# modprobe 8021q

# lsmod | grep 8021q

3种方法:

1 通过配置文件

auto eth0.2

iface eth0.2 inet static

  address 192.168.2.1

  netmask 255.255.255.0

 

auto eth0.3

iface eth0.3 inet static

  address 192.168.3.1

  netmask 255.255.255.0

 

ifup eth0.2
ifup eth0.3
ifconfig eth0.2
 
eth0.2    Link encap:Ethernet  HWaddr 00:00:00:00:00:00
          inet addr:192.168.2.1  Bcast:12.168.2.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500 Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

 

如果需要指定连到那个物理网卡:

auto vlan2
iface vlan2 inet static
  address 192.168.2.1
  netmask 255.255.255.0
  vlan-raw-device eth0

 

http://www.microhowto.info/tutorials/802.1q.html

 

2 Vconfig

vconfig add eth0 2
vconfig add eth0 3
# ifconfig eth0.2 192.168.2.1 netmask 255.255.255.0 broadcast 192.168.2.255 up

# ifconfig eth0.3 192.168.3.1 netmask 255.255.255.0 broadcast 192.168.3.255 up

 

获取VLAN interface的详细信息

# cat /proc/net/vlan/eth0.5

 

删除VLAN interface

# ifconfig eth0.5 down
# vconfig rem eth0.5

 

 

3 通过ip

# ip link add link eth0 name eth0.2 type vlan id 2
# ip link
# ip -d link show eth0.2

 

# ip addr add 192.168.2.1/24 brd 192.168.2.255 dev eth0.2
# ip link set dev eth0.2 up

 

删除:

# ip link set dev eth0.2 down
# ip link delete eth0.2

 

配置完后,来ping eth0的ip,会发生eth0可以收到并回复,但eth0.2收到但不回复。

 http://blog.csdn.net/suiyuan19840208/article/details/8221529

 

转载于:https://www.cnblogs.com/allcloud/p/4910463.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值