CentOS 7.2下KVM安装及初步使用(3)

[root@kvm-node1 ~]# brctl show ##查看已有网桥 bridge name bridge id STP enabled interfaces virbr0 8000.525400fbb155 yes virbr0-nic vnet0

创建一个脚本,删除ens33网卡的ip信息,新建一个桥接网卡,并且将ens33网卡的ip信息富裕新建的桥接网卡

[root@kvm-node1 ~]# vim br0.sh #!/bin/bash brctl addbr br0 #创建一个桥接网卡br0 brctl addif br0 ens33 #将ens33网卡的桥接信息转到br0网卡 ip addr del dev ens33 10.0.0.12/24 #将ens33网卡的ip信息删除 ifconfig br0 10.0.0.12/24 up #将ens33网卡的ip信息这只到br0网卡上 route add default gw 10.0.0.2 #添加网关
[root@kvm-node1 ~]# chmod u+x br0.sh
[root@kvm-node1 ~]# ./br0.sh

使用ifocnfig查看网卡的ip信息,可以看到br0的地址已经变为了10.0.0.12/24

[root@kvm-node1 ~]# ifconfig br0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 10.0.0.12 netmask 255.255.255.0 broadcast 10.0.0.255 inet6 fe80::20c:29ff:fe51:970 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:51:09:70 txqueuelen 1000 (Ethernet) RX packets 553 bytes 41723 (40.7 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 680 bytes 63511 (62.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet6 fe80::5505:5aa:3f96:f3f8 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:51:09:70 txqueuelen 1000 (Ethernet) RX packets 6107998 bytes 8708309251 (8.1 GiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 534420 bytes 68906654 (65.7 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1 (Local Loopback) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 virbr0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255 ether 52:54:00:fb:b1:55 txqueuelen 1000 (Ethernet) RX packets 6685 bytes 278745 (272.2 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 6981 bytes 34351624 (32.7 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 vnet0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet6 fe80::fc54:ff:fe6b:5fee prefixlen 64 scopeid 0x20<link> ether fe:54:00:6b:5f:ee txqueuelen 1000 (Ethernet) RX packets 16 bytes 1650 (1.6 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 987 bytes 52236 (51.0 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

使用命令修改KVM虚拟机的信息

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/13558.html