AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1097
Accepted
chris
chris
Asked: 2010-08-06 04:54:27 +0800 CST2010-08-06 04:54:27 +0800 CST 2010-08-06 04:54:27 +0800 CST

如何设置 VLAN 转发?

  • 772

我有一个带有多个 VLAN 接口的 DAAP 服务器。我想在所有 VLAN 上转发流量。从 eth0 转发到 eth1.010* 我已将交换机配置为具有正确 VLAN 的中继端口,并启用/proc/sys/net/ipv4/ip_forward

但这似乎并不奏效。还有什么我需要做的吗?

这是我的 ifconfig 结果,您可以看到 VLAN 接口并没有真正获得任何流量:

eth0      Link encap:Ethernet  HWaddr 00:14:d1:10:ca:fc  
          inet addr:192.168.1.20  Bcast:172.21.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:536 errors:0 dropped:0 overruns:0 frame:0
          TX packets:259 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:264232 (258.0 KiB)  TX bytes:37425 (36.5 KiB)
          Interrupt:20 Base address:0xe000 

eth1      Link encap:Ethernet  HWaddr 00:1c:c4:31:28:22  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:303 errors:0 dropped:0 overruns:0 frame:0
          TX packets:202 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:225213 (219.9 KiB)  TX bytes:47118 (46.0 KiB)
          Interrupt:17 

eth1.0101 Link encap:Ethernet  HWaddr 00:1c:c4:31:28:22  
          inet addr:172.17.1.20  Bcast:172.17.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:40 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:9076 (8.8 KiB)

eth1.0102 Link encap:Ethernet  HWaddr 00:1c:c4:31:28:22  
          inet addr:172.18.1.20  Bcast:172.18.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:40 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:9076 (8.8 KiB)

eth1.0103 Link encap:Ethernet  HWaddr 00:1c:c4:31:28:22  
          inet addr:172.19.1.20  Bcast:172.19.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:40 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:9076 (8.8 KiB)

eth1.0104 Link encap:Ethernet  HWaddr 00:1c:c4:31:28:22  
          inet addr:172.20.1.20  Bcast:172.20.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:40 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:9076 (8.8 KiB)

eth1.0105 Link encap:Ethernet  HWaddr 00:1c:c4:31:28:22  
          inet addr:172.21.1.20  Bcast:172.21.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:40 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 B)  TX bytes:9076 (8.8 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:113 errors:0 dropped:0 overruns:0 frame:0
          TX packets:113 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:20777 (20.2 KiB)  TX bytes:20777 (20.2 KiB)

这是我的 /etc/network/interfaces 文件:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# Automagically configured network interfaces
auto eth0
auto eth1.0101
auto eth1.0102
auto eth1.0103
auto eth1.0104
auto eth1.0105

iface eth0 inet static
   address 192.168.1.20
   netmask 255.255.0.0
   gateway 192.168.1.3
   network 172.21.0.0
   broadcast 172.21.255.255

iface eth1.0101 inet static
   address 172.17.1.20
   netmask 255.255.255.0


iface eth1.0102 inet static
   address 172.18.1.20
   netmask 255.255.255.0


iface eth1.0103 inet static
   address 172.19.1.20
   netmask 255.255.255.0


iface eth1.0104 inet static
   address 172.20.1.20
   netmask 255.255.255.0


iface eth1.0105 inet static
   address 172.21.1.20
   netmask 255.255.255.0

感谢您的帮助,我已经为此工作了很长时间。

networking server
  • 3 3 个回答
  • 10165 Views

3 个回答

  • Voted
  1. Li Lo
    2010-08-06T16:53:18+08:002010-08-06T16:53:18+08:00

    我还没有在 Ubuntu 上这样做,但这是我迄今为止的研究:

    你需要坚持

    vconfig add eth1 101  
    vconfig add eth1 102  
    vconfig add eth1 103  
    vconfig add eth1 104  
    vconfig add eth1 105
    

    在启动脚本中。

    接口文件看起来像这样:

    auto lo
    iface lo inet loopback
    auto eth0 eth1 vlan2 vlan3 vlan4 vlan5
    iface eth0 inet dhcp
    
    # VLAN 1 - native management VLAN
    iface eth1 inet static
            address 10.0.0.1
            netmask 255.255.255.224
            vlan_raw_device eth1
    
    # VLAN 2 - DMZ
    iface vlan2 inet static
            address 10.0.0.33
            netmask 255.255.255.224
            vlan_raw_device eth1
    
    # VLAN 3 - Accounting
    iface vlan3 inet static
            address 10.0.0.65
            netmask 255.255.255.224
            vlan_raw_device eth1
    
    # VLAN 2 - DMZ
    iface vlan2 inet static
            address 10.0.0.33
            netmask 255.255.255.224
            vlan_raw_device eth1
    
    # VLAN 3 - Accounting
    iface vlan3 inet static
            address 10.0.0.65
            netmask 255.255.255.224
            vlan_raw_device eth1
    
    # VLAN 4 - Engineering
    iface vlan4 inet static
            address 10.0.0.97
            netmask 255.255.255.224
            vlan_raw_device eth1
    
    # VLAN 5 - Sales & Marketing
    iface vlan5 inet static
            address 10.0.0.129
            netmask 255.255.255.224
            vlan_raw_device eth1
    

    显然,您将在接口文件中使用自己的 IP。让我们知道它是否有效。

    参考文献: 1 2

    • 4
  2. Ressu
    2010-08-06T05:21:38+08:002010-08-06T05:21:38+08:00

    如果我正确阅读了您的问题,那么您正在寻找桥接。桥接将所有流量从一个接口转发到另一个接口。

    您将需要安装 bridge-utils 包并设置您的配置,如下所示:

    auto br0
    iface br0 inet static
      address 192.168.1.20
      netmask 255.255.0.0
      gateway 192.168.1.3
      bridge_ports eth0 eth1.0101 eth1.0102 eth1.0103 eth1.0104 eth1.0105
    

    无需对各个端口进行配置。

    这会将端口配置在一个网桥中,并且应该使所有内容都可以访问。brctl您可以使用命令查看网桥的状态。

    • 0
  3. Best Answer
    chris
    2010-08-07T10:04:10+08:002010-08-07T10:04:10+08:00

    有效!我现在对 DAAP 有一个单独的问题,但我认为它与 Avahi 有关。我会尝试自己解决这个问题。万分感谢。

    • 0

相关问题

  • 使用 dpkg 手动安装软件包是否会阻止未来的升级路径?

  • 如何从命令行刻录双层 dvd iso

  • 如果在服务器机器上运行 Ubuntu 桌面版,性能损失是多少?

  • 将桌面版剥离为服务器版的最简单方法是什么?

  • 如何与无头服务器进行图形交互?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何安装 .run 文件?

    • 7 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    如何获得 CPU 温度?

    • 21 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Marko Smith

    如何使用命令行将用户添加为新的 sudoer?

    • 7 个回答
  • Marko Smith

    更改文件夹权限和所有权

    • 9 个回答
  • Marko Smith

    你如何重新启动Apache?

    • 13 个回答
  • Marko Smith

    如何卸载软件?

    • 11 个回答
  • Marko Smith

    如何删除 PPA?

    • 26 个回答
  • Martin Hope
    NES 如何启用或禁用服务? 2010-12-30 13:03:32 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    Olivier Lalonde 如何在结束 ssh 会话后保持进程运行? 2010-10-22 04:09:13 +0800 CST
  • Martin Hope
    David B 如何使用命令行将用户添加为新的 sudoer? 2010-10-16 04:02:45 +0800 CST
  • Martin Hope
    Hans 如何删除旧内核版本以清理启动菜单? 2010-08-21 19:37:01 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve