Ubuntu网络配置三种方式

Ubuntu网络配置

以下操作都是通过编辑文件/etc/network/interface来实现网络的配置,配置完成后要重启网络sudo /etc/init.d/networking restart

DHCP配置

auto eth0
iface eth0 inet dhcp

静态IP配置

参数配置根据实际环境做相应的改变,以下是我的网络环境
auto eth0
iface eth0 inet static
address 192.168.0.100
gateway 192.168.0.1
netmask 255.255.255.0
network 192.168.0.255
dns-nameservers 192.168.0.254

桥接配置

配置之前先安装: bridge-utils,sudo apt-get install bridge-utils

iface eth0 inet manual

auto br0
iface br0 inet static

      address 192.168.1.104
      netmask 255.255.255.0
      network 192.168.1.0
      broadcast 192.168.1.255
      gateway  192.168.1.1
      dns-nameservers 192.168.1.1
      bridge_ports eth0
      bridge_stp off
      bridge_fd 0
      bridge_maxwait 0

 
注意,如果没有配dns-nameservers 将没法ping通外网
 
无关内容:用libvirt启动虚拟机,虚拟机使用桥接方式配置,vnc连接到虚拟机时,如果vnc 没法连接到虚拟机,检查 /etc/libvirt/qemu.conf文件  vnc_listen="0.0.0.0"是否启用。启用之后,原有的虚拟机需要重启,libvirt 也要重启。

猜你喜欢

转载自liuzhijun.iteye.com/blog/1715260