网桥的功能有两个:
一.连接不同的网段,使得不同网段的主机之间无需通过路由就可以传输数据,交换机就起到这种功能。如果两个不同网段通过网桥连接的话,那么每台主机的route表都应当包含这两个网段的路由选项了。也就理解了鸟哥的route表这么奇怪了:
[root@linux ~]# route -n
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface192.168.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
0.0.0.0 192.168.10.30 0.0.0.0 UG 0 0 0 eth0
二.体会最深的就是虚拟机的桥接了。
ubuntu下kvm桥接,先安装
apt-get install bridge-utilsuml-utilities
配置/etc/network/interfaces:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 192.168.2.110
network 192.16821.0
netmask 255.255.255.0
gateway 192.168.2.1
broadcast 192.168.2.255
auto tap0
iface tap0 inet manual
up ifconfig $IFACE 0.0.0.0 up
down ifconfig $IFACE down
tunctl_user yourname
auto br0
iface br0 inet static
address 192.168.1.111
network 192.168.1.0
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1
bridge_ports eth0 tap0
bridge_stp off
bridge_fd 0
bridge_maxwait 0
启动kvm虚拟机:
kvm -smp 2 -m 1024 -net nic,vlan=0,macaddr=52-54-00-12-34-01 -net tap,vlan=0,ifname=tap0,script=no -hda ~/kvm/image/ubuntu11.10.qcow2
参考资料: