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

 

相關文章
相關標籤/搜索