Linux 如何配置网络桥接设备brd:简明教程 (linux配置brd)

在 Linux 系统中,网络桥接设备 brd 使得虚拟机的网络通信可以和宿主机器一样与外部网络通信。本文将介绍如何在 Linux 系统中配置网络桥接设备 brd,让读者可以更好地使用和管理虚拟机的网络。

步骤一:安装所需软件包

在 Linux 系统中,使用网络桥接设备 brd 需要安装桥接设备的软件包,可以使用以下命令进行安装:

“`

sudo apt-get install bridge-utils

“`

安装完成后,可以使用以下命令检查安装是否成功:

“`

sudo brctl show

“`

如果提示“bridge name bridge id STP enabled interfaces”,说明 bridge-utils 包已经成功安装。

步骤二:创建网络桥接设备

在创建网络桥接设备之前,需要先确认当前系统之中的网络接口。

“`

ifconfig

“`

此命令将列出当前可用的网络接口,例如 eth0、wlan0 等。

接下来,输入以下命令,创建一个名为 br0 的网络桥接设备:

“`

sudo brctl addbr br0

“`

此时,再次使用 ifconfig 命令,可以发现一个新的网络接口已经出现:br0。

步骤三:将物理网卡添加到桥接设备

在创建网络桥接设备之后,需要将物理网卡添加到桥接设备之中,从而实现虚拟机的网络通信。

需要检查当前系统中的物理网卡信息:

“`

ifconfig

“`

找到需要添加到桥接设备中的物理网卡,例如 eth0。

接下来,使用以下命令将物理网卡添加到桥接设备中:

“`

sudo brctl addif br0 eth0

“`

此时,可以再次使用 ifconfig 命令查看网络地址是否已经分配成功。

步骤四:配置桥接设备

在配置桥接设备的过程中,需要分配网络地址,从而让虚拟机可以和外部网络通信。

需要停止当前系统中的物理网卡,例如 eth0:

“`

sudo ifconfig eth0 0

“`

接下来,需要给桥接设备 br0 分配网络地址,例如 192.168.1.1:

“`

sudo ifconfig br0 192.168.1.1

“`

启动桥接设备 br0:

“`

sudo ifconfig br0 up

“`

此时,桥接设备 br0 就已经成功配置完成,可以在虚拟机中使用该网络接口访问外部网络。

通过以上步骤,我们可以在 Linux 系统之中配置网络桥接设备 brd,实现虚拟机的网络通信和宿主机器的网络通信一样畅通无阻,让我们更加方便地使用和管理虚拟机的各种服务。

相关问题拓展阅读:

Linux如何查看系统及硬件信息

用硬件检测程序kuduz探测新硬件:service kudzu start ( or restart)

查看CPU信息:cat /proc/cpuinfo

查看板卡信息:枯羡cat /proc/pci

查看PCI信息:lspci (相比cat /proc/pci更直观)

查看内存信息:cat /proc/meminfo

查看USB设备:cat /proc/bus/u/devices

查看键盘和鼠标:cat /proc/bus/input/devices

查看系统硬盘信息和使用情况:fdisk & disk – l & df

查看各设备的没闭拍中断请求(IRQ):cat /proc/interrupts

查看启动硬件检测信息日志:dmesg more /var/log/dmesg

uname -a

uptime

几种查看Linux版本信息的方法:

1. uname -a

2. cat /proc/version

3. cat /etc/issue

4. l_release -a

5.cat /etc/redhat-release

6.rpm -q redhat-release

详解 l_release -a

登录到态哗服务器执行 l_release -a ,即可列出所有版本信息

lscpu命令,查看的是cpu的统计信息.

blue@blue-pc:~$ lscpu

Architecture:i #cpu架构

CPU op-mode(s):bit, 64-bit

Byte Order:Little Endian #小尾序

CPU(s): #总共有4核

On-line CPU(s) list: 0-3

Thread(s) per core: #每个cpu核,只能支持一个线程,即不支持闷陪绝超线程

Core(s) per socket: #每个cpu,有4个核

Socket(s): #总共有1一个cpu

Vendor ID:GenuineIntel #cpu产商 intel

CPU family:

Model: 42

Stepping:7

CPU MHz: 1600.000

BogoMIPS:5986.12

Virtualization:VT-x#支持cpu虚拟化技术

L1d cache:2K

L1i cache:2K

L2 cache:256K

L3 cache:6144K

查看/proc/cpuinfo,可以知道每个蚂姿cpu信息,如每个CPU的型号,主频等。

#cat /proc/cpuinfo

processor : 0

vendor_id : GenuineIntel

cpu family : 6

model: 42

model name : Intel(R) Core(TM) iCPU @ 3.00GHz

…..

上面输出的是个cpu部分信息,还有3个cpu信息省略了。

内存

概要查看内存情况

free -m

totalusedfree shared buffers cached

Mem:

-/+ buffers/cache:

Swap:

这里的单位是MB,总共的内存是3926MB。

查看内存详细使用

# cat /proc/meminfo

MemTotal:8 kB

MemFree:84 kB

Buffers:00 kB

Cached:772 kB

SwapCached:kB

…..

查看内乱戚存硬件信息

dmidecode -t memory

# dmidecode 2.11

BIOS 2.7 present.

Handle 0x0008, DMI type 16, 23 bytes

Physical Memory Array

Location: System Board Or Motherboard

….

Maximum Capacity: 32 GB

….

Handle 0x000A, DMI type 17, 34 bytes

….

Memory Device

Array Handle: 0x0008

Error Information Handle: Not Provided

Total Width: 64 bits

Data Width: 64 bits

Size: 4096 MB

…..

我的主板有4个槽位,只用了一个槽位,上面插了一条4096MB的内存。

磁盘

查看硬盘和分区分布

# llk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

sda:.8G 0 disk

├—sda1 8:G 0 part /boot

├—sda2 8:.3G 0 part

├—sda3 8:.5G 0 part /

├—sda4 8:K 0 part

├—sda5 8:.8G 0 part /home

└—sda6 8:.2G 0 part

显示很直观

如果要看硬盘和分区的详细信息

# fdisk -l

Disk /dev/sda: 500.1 GB,bytes

255 heads, 63 sectors/track,cylinders, totalsectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk identifier: 0x

Device Boot StartEnd Blocks Id System

/dev/sda1 * Linux

/dev/sda 82 Linux swap / Solaris

/dev/sda 83 Linux

/dev/sda 5 Extended/dev/sda 83 Linux

/dev/sda 83 Linux

网卡

查看网卡硬件信息

# lspci | grep -i ‘eth’

02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 06)

查看系统的所有网络接口

# ifconfig -a

ethLink encap:以太网 硬件地址 b8:97:5a:17:b3:8f

…..

loLink encap:本地环回

…..

或者是

ip link show

1: lo: mtuqdisc noqueue state DOWN

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000

link/ether b8:97:5a:17:b3:8f brd ff:ff:ff:ff:ff:ff

如果要查看某个网络接口的详细信息,例如eth0的详细参数和指标

# ethtool eth0

Settings for eth0:

Supported ports:

Supported link modes: 10baseT/Half 10baseT/Full

100baseT/Half 100baseT/Full

1000baseT/Half 1000baseT/Full #支持千兆半双工,全双工模式

Supported pause frame use: No

Supports auto-negotiation: Yes #支持自适应模式,一般都支持

Advertised link modes: 10baseT/Half 10baseT/Full

100baseT/Half 100baseT/Full

1000baseT/Half 1000baseT/Full

Advertised pause frame use: Symmetric Receive-only

Advertised auto-negotiation: Yes #默认使用自适应模式

Link partner advertised link modes: 10baseT/Half 10baseT/Full

00baseT/Half 100baseT/Full

…..

Speed: 100Mb/s #现在网卡的速度是100Mb,网卡使用自适应模式,所以推测路由是100Mb,导致网卡从支 持千兆,变成要支持百兆

Duplex: Full #全双工

…..

Link detected: yes #表示有网线连接,和路由是通的

其他

查看pci信息,即主板所有硬件槽信息。

lspci

00:00.0 Host bridge: Intel Corporation 2nd Generation Core Processor Family DRAM Controller (rev 09) #主板芯片

00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09) #显卡

00:14.0 USB controller: Intel Corporation Panther Point USB xHCI Host Controller (rev 04) #u控制器

00:16.0 Communication controller: Intel Corporation Panther Point MEI Controller #1 (rev 04)

00:1a.0 USB controller: Intel Corporation Panther Point USB Enhanced Host Controller #2 (rev 04)

00:1b.0 Audio device: Intel Corporation Panther Point High Definition Audio Controller (rev 04) #声卡

00:1c.0 PCI bridge: Intel Corporation Panther Point PCI Express Root Port 1 (rev c4) #pci 插槽

00:1c.2 PCI bridge: Intel Corporation Panther Point PCI Express Root Port 3 (rev c4)

00:1c.3 PCI bridge: Intel Corporation Panther Point PCI Express Root Port 4 (rev c4)

00:1d.0 USB controller: Intel Corporation Panther Point USB Enhanced Host Controller #1 (rev 04)

00:1f.0 ISA bridge: Intel Corporation Panther Point LPC Controller (rev 04)

00:1f.2 IDE interface: Intel Corporation Panther Point 4 port SATA Controller (rev 04) #硬盘接口

00:1f.3 Bus: Intel Corporation Panther Point Bus Controller (rev 04)

00:1f.5 IDE interface: Intel Corporation Panther Point 2 port SATA Controller (rev 04) #硬盘接口

02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 06) #网卡

03:00.0 PCI bridge: Integrated Technology Express, Inc. Device 8893 (rev 41)

如果要更详细的信息:lspci -v 或者 lspci -vv

如果要看设备树:lscpi -t

查看bios信息

# dmidecode -t bios

……

BIOS Information

Vendor: American Megatrends Inc.

Version: 4.6.5

Release Date: 04/25/2023

…….

BIOS Revision: 4.6

……

dmidecode以一种可读的方式dump出机器的DMI(Desktop Management Interface)信息。这些信息包括了硬件以及BIOS,既可以得到当前的配置,也可以得到系统支持的配置,比如说支持的内存数等。

如果要查看所有有用信息

dmidecode -q

LINUX 网络方面的问题,ip add ls显示的IP地址疑惑

link/ipip 0.0.0.0 brd 0.0.0.0

通过IPIP隧道方式实现的,比如tunl0就是tunnel,是互联网上最常见的一种隧道方式,最早用思科路由器实现塌衡的居多。

没做指侍过IPIP的方式,只做过GRE的方式,操作方法很类似:

CENTOS5的操作方法如下:

1、modprobe ip_gre //加载GRE模块

2、ip tunnel add tunnel0 mode gre remote x.x.x.x local y.y.y.y ttl 255

意思是以本地的y.y.y.y与远端建立隧道,远端IP是x.x.x.x

3、ip addr add A.B.C.D netmask 255.255.255.x dev tunnel0,为隧道端口加上IP地址团逗做

远端同样。

结果就是这样:

tunl0: mtu 1480 qdisc noop

link/gre A.B.C.D brd 255.255.255.X

与你看到的区别就是link/后面这个字段。

关于linux配置brd的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。


数据运维技术 » Linux 如何配置网络桥接设备brd:简明教程 (linux配置brd)