Debian kvm网络配置

安装brctlpython

apt-get install bridge-utils

 

设置网桥linux

可编辑 /etc/network/interface 文件。不过,我建议在 /etc/network/interface.d/ 目录下放置一个全新的配置。在 Debian Linux 配置网桥的过程以下:网络

步骤 1 - 找出物理接口编辑器

$ ip -f inet a s

  输出以下:oop

eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
inet 192.168.2.23/24 brd 192.168.2.255 scope global eno1
valid_lft forever preferred_lft forever

  eno1是物理网卡rest

更新 /etc/network/interfaces 文件code

确保只有 lo(loopback 在 /etc/network/interface 中处于活动状态)。(LCTT 译注:loopback 指本地环回接口,也称为回送地址)删除与 eno1 相关的任何配置。orm

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
 
source /etc/network/interfaces.d/*
 
# The loopback network interface
auto lo
iface lo inet loopback

  

在 /etc/network/interfaces.d/br0 中配置网桥(br0)server

使用文本编辑器建立一个文本文件,好比 vi 命令:blog

$ sudo vi /etc/network/interfaces.d/br0

 在其中添加配置: 

## static ip config file for br0 ##
auto br0
iface br0 inet static
address 192.168.2.23
broadcast 192.168.2.255
netmask 255.255.255.0
gateway 192.168.2.254
# If the resolvconf package is installed, you should not edit
# the resolv.conf configuration file manually. Set name server here
#dns-nameservers 192.168.2.254
# If you have muliple interfaces such as eth0 and eth1
# bridge_ports eth0 eth1
bridge_ports eno1
bridge_stp off # disable Spanning Tree Protocol
bridge_waitport 0 # no delay before a port becomes available
bridge_fd 0 # no forwarding delay

 

若想DHCP 来得到 IP 地址

## DHCP ip config file for br0 ##
auto br0
 
# Bridge setup
iface br0 inet dhcp
bridge_ports eno1

  保存并关闭文件

在从新启动网络服务以前,请确保防火墙已关闭。防火墙可能会引用较老的接口,例如 eno1。一旦服务从新启动,你必须更新 br0 接口的防火墙规则。键入如下命令从新启动防火墙:

$ sudo systemctl restart network-manager

  

确认服务已经从新启动:

$ systemctl status network-manager

  

借助 ip 命令寻找新的 br0 接口和路由表:

$ ip a s
$ ip r
$ ping -c 2 cyberciti.biz

  

示例输出:

 

 

brctl 命令查看网桥有关信息:

 

brctl show

 

 显示当前网桥:

$ bridge link

 

相关文章
相关标签/搜索