概述

更新时间:
2024-03-14
下载文档

概述

网桥是将一台机器上的多个网口连接在一起的一种方式。网桥将网络的同一网段在数据链路层连接起来,只能连接同构网络(同一网段),不能连接异构网络(不同网段)。由于网桥转发在网络二层发生,不会经过复杂的协议栈,所以会比路由转发的效率要高。

实现方式

在 SylixOS 系统中,使用 netbr 命令来设置网桥功能。在Shell界面通过 help netbr 命令可以查看到该指令的实际使用方式。

[root@sylixos:/root]# help netbr
add / delete / control net bridge.
eg. netbr show bridge0           (Show all net device in 'bridge0' net brigdge)
    netbr addbr bridge0          (Add a net brigdge named 'bridge0')
    netbr delbr bridge0          (Delete a net brigdge named 'bridge0')
    netbr flush bridge0          (Flush all MAC cache in net brigdge named 'bridge0')
    netbr adddev bridge0 ethdev0 (Add a net device in net brigdge named 'bridge0')
    netbr deldev bridge0 ethdev0 (Delete a net device from net brigdge named 'bridge0')
    netbr addif bridge0 en1      (Same as 'adddev' but use interface name)
    netbr delif bridge0 en1      (Same as 'deldev' but use interface name)
netbr [...]
[root@sylixos:/root]# 

添加网桥

  • 添加一个名为 bridge0 的网桥,通过命令 netbr addbr [网桥接口名] 来实现。

    [root@sylixos:/root]# netbr addbr bridge0
    [ifparam]No network parameter for [bridge0] from /etc/ifparam.ini, default parameters will be used.
    net bridge device add ok, if index: 4.
    [root@sylixos:/root]# 
    
  • 通过 ifconfig 命令查看添加的网桥。

    [root@sylixos:/root]# ifconfig 
    br3       Link encap: Ethernet HWaddr: 00:00:00:00:00:00
              Dev: bridge0 Ifidx: 4 DHCP: D4 D6 Spd: N/A
              inet addr: 0.0.0.0 netmask: 0.0.0.0
              gateway: 0.0.0.0 broadcast: 255.255.255.255
              inet6 addr: fe80::200:ff:fe00:0 Scope:Link<T0>
              BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              collisions:0 txqueue:0 tcpaf:1 tcpwnd:65535
              RX ucast packets:0 nucast packets:0 dropped:0
              TX ucast packets:0 nucast packets:0 dropped:0
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
    
    en2       Link encap: Ethernet HWaddr: be:7a:3c:c9:9a:e5
              Dev: dw_1 Ifidx: 3 DHCP: D4 D6 Spd: N/A
              inet addr: 10.4.130.210 netmask: 255.255.255.0
              gateway: 10.4.0.1 broadcast: 10.4.130.255
              inet6 addr: fe80::bc7a:3cff:fec9:9ae5 Scope:Link<T0>
              UP BROADCAST MULTICAST  MTU:1500  Metric:1
              collisions:0 txqueue:0 tcpaf:2 tcpwnd:65535
              RX ucast packets:0 nucast packets:0 dropped:0
              TX ucast packets:0 nucast packets:0 dropped:0
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
    
    en1       Link encap: Ethernet HWaddr: 00:11:22:33:44:98
              Dev: dw_0 Ifidx: 2 DHCP: D4 D6 Spd: 1000 Mbps
              inet addr: 10.4.120.211 netmask: 255.255.0.0
              gateway: 10.4.0.1 broadcast: 10.4.255.255
              inet6 addr: fe80::211:22ff:fe33:4498 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              collisions:0 txqueue:512 tcpaf:2 tcpwnd:65535
              RX ucast packets:335 nucast packets:1372777 dropped:0
              TX ucast packets:10 nucast packets:8 dropped:0
              RX bytes:85060062 (81.1 MB)  TX bytes:1108 (1.0 KB)
    
    lo0       Link encap: Local Loopback
              Dev: N/A Ifidx: 1 DHCP: D4 D6 Spd: N/A
              inet addr: 127.0.0.1 netmask: 255.0.0.0
              P-to-P: 127.0.0.1 broadcast: N/A
              inet6 addr: ::1 Scope:Loopback
              UP LOOPBACK RUNNING  MTU:0  Metric:1
              collisions:0 txqueue:0 tcpaf:2 tcpwnd:262140
              RX ucast packets:3 nucast packets:0 dropped:0
              TX ucast packets:3 nucast packets:0 dropped:0
              RX bytes:168 (168.0 B)  TX bytes:168 (168.0 B)
    
    dns0: 0.0.0.0
    dns1: 0.0.0.0
    dns2: 0.0.0.0
    dns3: 0.0.0.0
    default device is: en1
    list net interface: 4
    

添加网络接口

  • 网桥添加完成后,需要向网桥接口 bridge0 添加网络接口 en1、en2,通过命令 netbr addif [网桥接口名] [网络接口名] 来实现。

    [root@sylixos:/root]# netbr addif bridge0 en1
    [root@sylixos:/root]# netbr addif bridge0 en2
    
  • 通过 ifconfig 命令查看到网络接口 en1、en2 无法再配置,不再显示在Shell界面。

    [root@sylixos:/root]# ifconfig 
    br3       Link encap: Ethernet HWaddr: 00:11:22:33:44:98
              Dev: bridge0 Ifidx: 4 DHCP: D4 D6 Spd: N/A
              inet addr: 0.0.0.0 netmask: 0.0.0.0
              gateway: 0.0.0.0 broadcast: 255.255.255.255
              inet6 addr: fe80::211:22ff:fe33:4498 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              collisions:0 txqueue:0 tcpaf:1 tcpwnd:65535
              RX ucast packets:19 nucast packets:1335 dropped:0
              TX ucast packets:0 nucast packets:7 dropped:0
              RX bytes:2049956 (1.9 MB)  TX bytes:546 (546.0 B)
    
    lo0       Link encap: Local Loopback
              Dev: N/A Ifidx: 1 DHCP: D4 D6 Spd: N/A
              inet addr: 127.0.0.1 netmask: 255.0.0.0
              P-to-P: 127.0.0.1 broadcast: N/A
              inet6 addr: ::1 Scope:Loopback
              UP LOOPBACK RUNNING  MTU:0  Metric:1
              collisions:0 txqueue:0 tcpaf:2 tcpwnd:262140
              RX ucast packets:3 nucast packets:0 dropped:0
              TX ucast packets:3 nucast packets:0 dropped:0
              RX bytes:168 (168.0 B)  TX bytes:168 (168.0 B)
    
    dns0: 0.0.0.0
    dns1: 0.0.0.0
    dns2: 0.0.0.0
    dns3: 0.0.0.0
    default device is: null
    list net interface: 2
    

添加网络设备

与上文的添加网络接口名类似,仅仅是将命令参数网络接口名改为了网络设备名,网络设备名通过 ifconfig 命令显示的 [Dev:] 查出。

  • 网桥添加完成后,需要向网桥接口 bridge0 添加网络设备 dw_0、dw_1,通过命令 netbr adddev [网桥接口名] [网络设备名] 来实现。

    [root@sylixos:/root]# netbr adddev bridge0 dw_0
    [root@sylixos:/root]# netbr adddev bridge0 dw_1
    
  • 通过 ifconfig 命令查看到网络接口 en1、en2 无法再配置,不再显示在Shell界面。

    [root@sylixos:/root]# ifconfig 
    br3       Link encap: Ethernet HWaddr: 00:11:22:33:44:98
              Dev: bridge0 Ifidx: 4 DHCP: D4 D6 Spd: N/A
              inet addr: 0.0.0.0 netmask: 0.0.0.0
              gateway: 0.0.0.0 broadcast: 255.255.255.255
              inet6 addr: fe80::211:22ff:fe33:4498 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              collisions:0 txqueue:0 tcpaf:1 tcpwnd:65535
              RX ucast packets:19 nucast packets:1335 dropped:0
              TX ucast packets:0 nucast packets:7 dropped:0
              RX bytes:2049956 (1.9 MB)  TX bytes:546 (546.0 B)
    
    lo0       Link encap: Local Loopback
              Dev: N/A Ifidx: 1 DHCP: D4 D6 Spd: N/A
              inet addr: 127.0.0.1 netmask: 255.0.0.0
              P-to-P: 127.0.0.1 broadcast: N/A
              inet6 addr: ::1 Scope:Loopback
              UP LOOPBACK RUNNING  MTU:0  Metric:1
              collisions:0 txqueue:0 tcpaf:2 tcpwnd:262140
              RX ucast packets:3 nucast packets:0 dropped:0
              TX ucast packets:3 nucast packets:0 dropped:0
              RX bytes:168 (168.0 B)  TX bytes:168 (168.0 B)
    
    dns0: 0.0.0.0
    dns1: 0.0.0.0
    dns2: 0.0.0.0
    dns3: 0.0.0.0
    default device is: null
    list net interface: 2
    

查看网桥接口信息

  • 网桥添加完成后,可以通过命令 netbr show [网桥接口名] 来查看网桥的接口信息。

    [root@sylixos:/root]# netbr show bridge0
    <0> Dev: dw_1 Prev-Ifname: en2 Spd: N/A Linkup: Disable Prev-HWaddr: be:7a:3c:c9:9a:e5
    <1> Dev: dw_0 Prev-Ifname: en1 Spd: 1000 Mbps Linkup: Enable Prev-HWaddr: 00:11:22:33:44:98
    

删除网络接口

  • 网络接口添加到网桥后,还可通过命令 netbr delif [网桥接口名] [网络接口名] 来实现。

    [root@sylixos:/root]# netbr delif bridge0 en1
    [root@sylixos:/root]# netbr delif bridge0 en2
    
  • 通过 ifconfig 命令查看到网络接口可以再次配置,接口名由 en1、en2 变成了 en4、en5。

    [root@sylixos:/root]# ifconfig 
    en5       Link encap: Ethernet HWaddr: be:7a:3c:c9:9a:e5
              Dev: dw_1 Ifidx: 6 DHCP: D4 D6 Spd: N/A
              inet addr: 10.4.130.210 netmask: 255.255.255.0
              gateway: 10.4.0.1 broadcast: 10.4.130.255
              inet6 addr: fe80::bc7a:3cff:fec9:9ae5 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              collisions:0 txqueue:0 tcpaf:2 tcpwnd:65535
              RX ucast packets:0 nucast packets:0 dropped:0
              TX ucast packets:0 nucast packets:6 dropped:0
              RX bytes:0 (0.0 B)  TX bytes:448 (448.0 B)
    
    en4       Link encap: Ethernet HWaddr: 00:11:22:33:44:98
              Dev: dw_0 Ifidx: 5 DHCP: D4 D6 Spd: 1000 Mbps
              inet addr: 10.4.120.211 netmask: 255.255.0.0
              gateway: 10.4.0.1 broadcast: 10.4.255.255
              inet6 addr: fe80::211:22ff:fe33:4498 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              collisions:0 txqueue:512 tcpaf:2 tcpwnd:65535
              RX ucast packets:8 nucast packets:333 dropped:0
              TX ucast packets:0 nucast packets:7 dropped:0
              RX bytes:30702 (29.9 KB)  TX bytes:510 (510.0 B)
    
    br3       Link encap: Ethernet HWaddr: 00:11:22:33:44:98
              Dev: bridge0 Ifidx: 4 DHCP: D4 D6 Spd: N/A
              inet addr: 0.0.0.0 netmask: 0.0.0.0
              gateway: 0.0.0.0 broadcast: 255.255.255.255
              inet6 addr: fe80::211:22ff:fe33:4498 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              collisions:0 txqueue:0 tcpaf:1 tcpwnd:65535
              RX ucast packets:34 nucast packets:85732 dropped:0
              TX ucast packets:0 nucast packets:7 dropped:0
              RX bytes:129849724 (123.8 MB)  TX bytes:546 (546.0 B)
    
    lo0       Link encap: Local Loopback
              Dev: N/A Ifidx: 1 DHCP: D4 D6 Spd: N/A
              inet addr: 127.0.0.1 netmask: 255.0.0.0
              P-to-P: 127.0.0.1 broadcast: N/A
              inet6 addr: ::1 Scope:Loopback
              UP LOOPBACK RUNNING  MTU:0  Metric:1
              collisions:0 txqueue:0 tcpaf:2 tcpwnd:262140
              RX ucast packets:3 nucast packets:0 dropped:0
              TX ucast packets:3 nucast packets:0 dropped:0
              RX bytes:168 (168.0 B)  TX bytes:168 (168.0 B)
    
    dns0: 0.0.0.0
    dns1: 0.0.0.0
    dns2: 0.0.0.0
    dns3: 0.0.0.0
    default device is: en5
    list net interface: 4
    

删除网桥

  • 删除一个名为 bridge0 的网桥,通过命令 netbr delbr [网桥接口名] 来实现。

    [root@sylixos:/root]# netbr delbr bridge0
    net bridge device delete.
    [root@sylixos:/root]# 
    
  • 通过 ifconfig 命令查看上文添加的网桥已经被成功删除。

    [root@sylixos:/root]# ifconfig 
    en5       Link encap: Ethernet HWaddr: be:7a:3c:c9:9a:e5
              Dev: dw_1 Ifidx: 6 DHCP: D4 D6 Spd: N/A
              inet addr: 10.4.130.210 netmask: 255.255.255.0
              gateway: 10.4.0.1 broadcast: 10.4.130.255
              inet6 addr: fe80::bc7a:3cff:fec9:9ae5 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              collisions:0 txqueue:0 tcpaf:2 tcpwnd:65535
              RX ucast packets:0 nucast packets:0 dropped:0
              TX ucast packets:0 nucast packets:8 dropped:0
              RX bytes:0 (0.0 B)  TX bytes:588 (588.0 B)
    
    en4       Link encap: Ethernet HWaddr: 00:11:22:33:44:98
              Dev: dw_0 Ifidx: 5 DHCP: D4 D6 Spd: 1000 Mbps
              inet addr: 10.4.120.211 netmask: 255.255.0.0
              gateway: 10.4.0.1 broadcast: 10.4.255.255
              inet6 addr: fe80::211:22ff:fe33:4498 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              collisions:0 txqueue:512 tcpaf:2 tcpwnd:65535
              RX ucast packets:37 nucast packets:43861 dropped:0
              TX ucast packets:0 nucast packets:8 dropped:0
              RX bytes:2699281 (2.5 MB)  TX bytes:580 (580.0 B)
    
    lo0       Link encap: Local Loopback
              Dev: N/A Ifidx: 1 DHCP: D4 D6 Spd: N/A
              inet addr: 127.0.0.1 netmask: 255.0.0.0
              P-to-P: 127.0.0.1 broadcast: N/A
              inet6 addr: ::1 Scope:Loopback
              UP LOOPBACK RUNNING  MTU:0  Metric:1
              collisions:0 txqueue:0 tcpaf:2 tcpwnd:262140
              RX ucast packets:3 nucast packets:0 dropped:0
              TX ucast packets:3 nucast packets:0 dropped:0
              RX bytes:168 (168.0 B)  TX bytes:168 (168.0 B)
    
    dns0: 0.0.0.0
    dns1: 0.0.0.0
    dns2: 0.0.0.0
    dns3: 0.0.0.0
    default device is: en5
    list net interface: 3
    

实际场景

通过网桥配置可以将一台 SylixOS 设备变成一个交换机,用于局域网通信。

当主机 A 想同时与主机 B、主机 C、主机 D 进行通信时,需要用到一台交换机。当手头没有交换机时,可以使用网桥配置将一台 SylixOS 设备变成一台交换机。

  • 进入 SylixOS 设备的Shell界面,通过 ifconfig 命令查看网络接口信息。

    [root@sylixos:/root]# ifconfig
    en6       Link encap: Ethernet HWaddr: 00:e0:67:08:10:12
              Dev: e1000e_5 Ifidx: 7 DHCP: D4 D6 Spd: 1000 Mbps
              inet addr: 10.7.130.100 netmask: 255.255.0.0
              gateway: 10.7.0.1 broadcast: 10.7.255.255
              inet6 addr: fe80::2e0:67ff:fe08:1012 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              collisions:0 txqueue:0 tcpaf:2 tcpwnd:131070
              RX ucast packets:43814 nucast packets:1065362 dropped:0
              TX ucast packets:42161 nucast packets:9 dropped:0
              RX bytes:77501180 (73.9 MB)  TX bytes:2261243 (2.1 MB)
    
    en5       Link encap: Ethernet HWaddr: 00:e0:67:08:10:13
              Dev: e1000e_4 Ifidx: 6 DHCP: D4 D6 Spd: 1000 Mbps
              inet addr: 192.168.11.2 netmask: 255.255.255.0
              gateway: 192.168.11.1 broadcast: 192.168.11.255
              inet6 addr: fe80::2e0:67ff:fe08:1013 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              collisions:0 txqueue:0 tcpaf:2 tcpwnd:131070
              RX ucast packets:6 nucast packets:5459 dropped:0
              TX ucast packets:7 nucast packets:133 dropped:0
              RX bytes:483712 (472.3 KB)  TX bytes:11144 (10.8 KB)
    
    en4       Link encap: Ethernet HWaddr: 00:e0:67:08:10:14
              Dev: e1000e_3 Ifidx: 5 DHCP: D4 D6 Spd: N/A
              inet addr: 192.168.12.12 netmask: 255.255.255.0
              gateway: 192.168.12.1 broadcast: 192.168.12.255
              inet6 addr: fe80::2e0:67ff:fe08:1014 Scope:Link
              UP BROADCAST MULTICAST  MTU:1500  Metric:1
              collisions:0 txqueue:0 tcpaf:2 tcpwnd:131070
              RX ucast packets:13 nucast packets:101 dropped:0
              TX ucast packets:34 nucast packets:130 dropped:0
              RX bytes:9936 (9.7 KB)  TX bytes:13020 (12.7 KB)
    
    en3       Link encap: Ethernet HWaddr: 00:e0:67:08:10:15
              Dev: e1000e_2 Ifidx: 4 DHCP: D4 D6 Spd: N/A
              inet addr: 10.4.0.94 netmask: 255.255.0.0
              gateway: 10.4.0.1 broadcast: 10.4.255.255
              inet6 addr: fe80::2e0:67ff:fe08:1015 Scope:Link<T0>
              UP BROADCAST MULTICAST  MTU:1500  Metric:1
              collisions:0 txqueue:0 tcpaf:1 tcpwnd:131070
              RX ucast packets:0 nucast packets:0 dropped:0
              TX ucast packets:0 nucast packets:0 dropped:0
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
    
    en2       Link encap: Ethernet HWaddr: 00:e0:67:08:10:16
              Dev: e1000e_1 Ifidx: 3 DHCP: D4 D6 Spd: N/A
              inet addr: 10.4.0.93 netmask: 255.255.0.0
              gateway: 10.4.0.1 broadcast: 10.4.255.255
              inet6 addr: fe80::2e0:67ff:fe08:1016 Scope:Link<T0>
              UP BROADCAST MULTICAST  MTU:1500  Metric:1
              collisions:0 txqueue:0 tcpaf:1 tcpwnd:131070
              RX ucast packets:0 nucast packets:0 dropped:0
              TX ucast packets:0 nucast packets:0 dropped:0
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
    
    en1       Link encap: Ethernet HWaddr: 00:e0:67:08:10:17
              Dev: e1000e_0 Ifidx: 2 DHCP: D4 D6 Spd: N/A
              inet addr: 10.4.0.92 netmask: 255.255.0.0
              gateway: 10.4.0.1 broadcast: 10.4.255.255
              inet6 addr: fe80::2e0:67ff:fe08:1017 Scope:Link<T0>
              UP BROADCAST MULTICAST  MTU:1500  Metric:1
              collisions:0 txqueue:0 tcpaf:1 tcpwnd:131070
              RX ucast packets:0 nucast packets:0 dropped:0
              TX ucast packets:0 nucast packets:0 dropped:0
              RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
    
    lo0       Link encap: Local Loopback
              Dev: N/A Ifidx: 1 DHCP: D4 D6 Spd: N/A
              inet addr: 127.0.0.1 netmask: 255.0.0.0
              P-to-P: 127.0.0.1 broadcast: N/A
              inet6 addr: ::1 Scope:Loopback
              UP LOOPBACK RUNNING  MTU:0  Metric:1
              collisions:0 txqueue:0 tcpaf:2 tcpwnd:262140
              RX ucast packets:233 nucast packets:0 dropped:0
              TX ucast packets:233 nucast packets:0 dropped:0
              RX bytes:16108 (15.7 KB)  TX bytes:16108 (15.7 KB)
    
    dns0: 0.0.0.0
    dns1: 0.0.0.0
    dns2: 0.0.0.0
    dns3: 0.0.0.0
    default device is: en6
    list net interface: 7
    
  • 创建一个网桥,并将网络接口 en1 ~ en5 添加到网桥上。

    [root@sylixos:/root]# netbr addbr bridge0
    [ifparam]No network parameter for [bridge0] from /etc/ifparam.ini, default parameters will be used.
    net bridge device add ok, if index: 8.
    [root@sylixos:/root]#  netbr addif bridge0 en1
    [root@sylixos:/root]#  netbr addif bridge0 en2
    [root@sylixos:/root]#  netbr addif bridge0 en3
    [root@sylixos:/root]#  netbr addif bridge0 en4
    [root@sylixos:/root]#  netbr addif bridge0 en5
    
  • 通过 ifconfig 命令查看网络接口信息,并修改网桥接口 IP 地址。

    [root@sylixos:/root]# ifconfig
    br7       Link encap: Ethernet HWaddr: 00:e0:67:08:10:17
              Dev: bridge0 Ifidx: 8 DHCP: D4 D6 Spd: N/A
              inet addr: 0.0.0.0 netmask: 0.0.0.0
              gateway: 0.0.0.0 broadcast: 255.255.255.255
              inet6 addr: fe80::2e0:67ff:fe08:1017 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              collisions:0 txqueue:0 tcpaf:1 tcpwnd:131070
              RX ucast packets:0 nucast packets:12 dropped:0
              TX ucast packets:0 nucast packets:7 dropped:0
              RX bytes:842 (842.0 B)  TX bytes:538 (538.0 B)
    
    en6       Link encap: Ethernet HWaddr: 00:e0:67:08:10:12
              Dev: e1000e_5 Ifidx: 7 DHCP: D4 D6 Spd: 1000 Mbps
              inet addr: 10.7.130.100 netmask: 255.255.0.0
              gateway: 10.7.0.1 broadcast: 10.7.255.255
              inet6 addr: fe80::2e0:67ff:fe08:1012 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              collisions:0 txqueue:0 tcpaf:2 tcpwnd:131070
              RX ucast packets:43986 nucast packets:1066679 dropped:0
              TX ucast packets:42325 nucast packets:9 dropped:0
              RX bytes:77601757 (74.0 MB)  TX bytes:2275192 (2.1 MB)
    
    lo0       Link encap: Local Loopback
              Dev: N/A Ifidx: 1 DHCP: D4 D6 Spd: N/A
              inet addr: 127.0.0.1 netmask: 255.0.0.0
              P-to-P: 127.0.0.1 broadcast: N/A
              inet6 addr: ::1 Scope:Loopback
              UP LOOPBACK RUNNING  MTU:0  Metric:1
              collisions:0 txqueue:0 tcpaf:2 tcpwnd:262140
              RX ucast packets:233 nucast packets:0 dropped:0
              TX ucast packets:233 nucast packets:0 dropped:0
              RX bytes:16108 (15.7 KB)  TX bytes:16108 (15.7 KB)
    
    dns0: 0.0.0.0
    dns1: 0.0.0.0
    dns2: 0.0.0.0
    dns3: 0.0.0.0
    default device is: en6
    list net interface: 3
    [root@sylixos:/root]# ifconfig br7 inet 192.168.11.3
    [root@sylixos:/root]# ifconfig br7 netmask 255.255.255.0
    [root@sylixos:/root]# ifconfig br7 gateway 192.168.11.1 
    
  • 打开主机 A 的Shell界面,对主机 B、主机 C 发送 ping 包,通信正常,证明 SylixOS 设备的网桥配置有效。

    [root@sylixos:/root]# ping 192.168.11.4
    Pinging 192.168.11.4
    
    Reply from 192.168.11.4: bytes=32 time=0.295ms TTL=255
    Reply from 192.168.11.4: bytes=32 time=0.215ms TTL=255
    Reply from 192.168.11.4: bytes=32 time=0.201ms TTL=255
    Reply from 192.168.11.4: bytes=32 time=0.205ms TTL=255
    
    Ping statistics for 192.168.11.4:
        Packets: Send = 4, Received = 4, Lost = 0(0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 0.201ms, Maximum = 0.295ms, Average = 0.229ms
    
    [root@sylixos:/root]# ping 192.168.11.6
    Pinging 192.168.11.6
    
    Reply from 192.168.11.6: bytes=32 time=0.292ms TTL=255
    Reply from 192.168.11.6: bytes=32 time=0.208ms TTL=255
    Reply from 192.168.11.6: bytes=32 time=0.225ms TTL=255
    Reply from 192.168.11.6: bytes=32 time=0.212ms TTL=255
    
    Ping statistics for 192.168.11.6:
        Packets: Send = 4, Received = 4, Lost = 0(0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 0.208ms, Maximum = 0.292ms, Average = 0.234ms
    
    [root@sylixos:/root]# 
    
文档内容是否对您有所帮助?
有帮助
没帮助