1.libvirt起来生辰的网卡信息(nat) [[email protected] ~]# ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:0f:a1:08 brd ff:ff:ff:ff:ff:ff inet 192.168.56.12/24 brd 192.168.56.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe0f:a108/64 scope link valid_lft forever preferred_lft forever 3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN link/ether 52:54:00:36:61:85 brd ff:ff:ff:ff:ff:ff inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 valid_lft forever preferred_lft forever 4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 500 link/ether 52:54:00:36:61:85 brd ff:ff:ff:ff:ff:ff [[email protected] ~]# cd /etc/sysconfig/network-scripts/
删除默认的网卡
[[email protected] network-scripts]# virsh net-destroy default Network default destroyed [[email protected] network-scripts]# virsh net-undefine default Network default has been undefined [[email protected] network-scripts]# systemctl restart libvirtd [[email protected] network-scripts]# [[email protected] network-scripts]# ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:0f:a1:08 brd ff:ff:ff:ff:ff:ff inet 192.168.56.12/24 brd 192.168.56.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe0f:a108/64 scope link valid_lft forever preferred_lft forever [[email protected] network-scripts]#
3.添加新的网卡
[[email protected] network-scripts]# cat ifcfg-br0 DEVICE=br0 BOOTPROTO=none ONBOOT=yes TYPE=Bridge IPADDR=192.168.56.12 NETMASK=255.255.255.0 GATEWAY=192.168.56.2 DEFROUTE=yes PV4_FAILURE_FATAL=yes IPV6INIT=no DELAY=0 USERCTL=no [[email protected] network-scripts]# cat ifcfg-eth0 TYPE=Ethernet BOOTPROTO=static DEFROUTE=yes PEERDNS=yes PEERROUTES=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes #IPV6_AUTOCONF=yes #IPV6_DEFROUTE=yes #IPV6_PEERDNS=yes #IPV6_PEERROUTES=yes #IPV6_FAILURE_FATAL=no NAME=eth0 #UUID=6c0f1aec-5cad-46d5-b213-572aeffd8c2e DEVICE=eth0 ONBOOT=yes #IPADDR=192.168.56.12 #NETMASK=255.255.255.0 GATEWAY=192.168.56.2 BRIDGE=br0 [[email protected] network-scripts]#
3.重启启动(写成脚本)
ifdown br0 ifdown eth0 ifup br0 ifup eth0 如果四步骤结束后还有eth0 的IP 建议重启服务器
4.virt-manager 创建虚拟机 (默认创建了以后键盘会不一样 安装以后调整键盘)
自己创建qcow2 格式的硬盘 用virt-manager 加路径选择 iso镜像也是加绝对路径选择
时间: 2024-11-09 02:22:00