使用KVM服务创建虚拟机
目录
(1)安装KVM组件
(2)编写和使用NAT启动脚本
(3)在NAT模式下启动虚拟机
前期准备
使用VM Workstation 安装CentOS 7.2操作系统,镜像使用后提供的CentOS-7-x86_64-DVD-1511.iso,关闭防火墙并配置Selinux安全规则,配置IP地址。YUM源使用提供的kvm_yum文件夹。
实施步骤
1、安装KVM
配置本地YUM安装源,将提供的kvm_yum文件夹上传至/opt目录,并配置本地YUM源,命令如下。
[root@localhost ~]# yum install -y qemu-kvm openssl libvirt
启动Libvirt服务,命令如下。
[root@localhost ~]# systemctl start libvirtd
将/usr/libexec/qemu-kvm链接为/usr/bin/qemu-kvm,命令如下。
[root@localhost ~]# ln -s /usr/libexec/qemu-kvm /usr/bin/qemu-kvm
2、创建NAT模式KVM虚拟机
将cirros-0.3.3-x86_64-disk.img镜像与qemu-ifup-NAT脚本文件上传到系统/root目录下。
赋予脚本执行权限。
通过qemu-kvm命令启动KVM虚拟机。
[root@localhost ~]# qemu-kvm -m 1024 -drive file=/root/cirros-0.3.3-x86_64-disk.img,if=virtio -net nic,model=virtio -net tap,script=/root/qemu-ifup-NAT.txt -nographic -vnc :1
Warning:dnsmasq is already running. No need to run it again.
/root/qemu-ifup-NAT.txt: line 69: ifconfig: command not found [
0.000000] Initializing cgroup subsys cpuset [ 0.000000] Initializing cgroup subsys cpu [ 0.000000] Linux version
3.2.0-80-virtual (buildd@batsu) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #116-Ubuntu SMP Mon Mar 23 17:28:52 UTC 2015 (Ubuntu 3.2.0-80.116-virtual 3.2.68) [ 0.000000] Command line: LABEL=cirros-rootfs ro console=tty1 console=ttyS0 [ 0.000000]
KERNEL supported cpus: [ 0.000000] Intel GenuineIntel [
0.000000] AMD AuthenticAMD [ 0.000000] Centaur CentaurHauls [ 0.000000] BIOS-provided physical RAM map: [ 0.000000] BIOS-e820: 0000000000000000 - 000000000009fc00 (usable) [ 0.000000]
BIOS-e820: 000000000009fc00 - 00000000000a0000 (reserved) [
0.000000] BIOS-e820: 00000000000f0000 - 0000000000100000 (reserved) [ 0.000000] BIOS-e820: 0000000000100000 - 000000003fffe000 (usable) [ 0.000000] BIOS-e820: 000000003fffe000 - 0000000040000000 (reserved) [ 0.000000] BIOS-e820: 00000000feffc000 - 00000000ff000000 (reserved) [ 0.000000] BIOS-e820: 00000000fffc0000 - 0000000100000000 (reserved) [ 0.000000] NX (Execute Disable) protection: active [ 0.000000] SMBIOS 2.4 present. [ 0.000000] No AGP bridge found [ 0.000000]
last_pfn = 0x3fffe max_arch_pfn = 0x400000000 [ 0.000000] PAT not
supported by CPU. [ 0.000000] found SMP MP-table at
[ffff8800000f2000] f2000 [ 0.000000] init_memory_mapping:
0000000000000000-000000003fffe000 [ 0.000000] RAMDISK: 37c92000 -
37ff0000 [ 0.000000] ACPI: RSDP 00000000000f1e60 00014 (v00 BOCHS )
[ 0.000000] ACPI: RSDT 000000003ffffa9b 00030 (v01 BOCHS BXPCRSDT
00000001 BXPC 00000001) [ 0.000000] ACPI: FACP 000000003ffff177
00074 (v01 BOCHS BXPCFACP 00000001 BXPC 00000001) [ 0.000000]
ACPI: DSDT 000000003fffe040 01137 (v01 BXPC BXDSDT 00000001 INTL
20150619) [ 0.000000] ACPI: FACS 000000003fffe000 00040 [
0.000000] ACPI: SSDT 000000003ffff1eb 00838 (v01 BOCHS BXPCSSDT 00000001 BXPC 00000001) [ 0.000000] ACPI: APIC 000000003ffffa23
00078 (v01 BOCHS BXPCAPIC 00000001 BXPC 00000001) [ 0.000000] No
NUMA configuration found [ 0.000000] Faking a node at
0000000000000000-000000003fffe000 [ 0.000000] Initmem setup node 0
0000000000000000-000000003fffe000 [ 0.000000] NODE_DATA
[000000003fff9000 - 000000003fffdfff] [ 0.000000] kvm-clock: Using
msrs 4b564d01 and 4b564d00 [ 0.000000] kvm-clock: cpu 0, msr
0:1cf76c1, boot clock [ 0.000000] Zone PFN ranges: [ 0.000000]
DMA 0x00000010 -> 0x00001000 [ 0.000000] DMA32 0x00001000
-> 0x00100000 [ 0.000000] Normal empty [ 0.000000] Movable zone start PFN for each node [ 0.000000] early_node_map[2] active
PFN ranges [ 0.000000] 0: 0x00000010 -> 0x0000009f [
0.000000] 0: 0x00000100 -> 0x0003fffe [ 0.000000] ACPI: PM-Timer IO Port: 0x608 [ 0.000000] ACPI: LAPIC (acpi_id[0x00]
lapic_id[0x00] enabled) [ 0.000000] ACPI: LAPIC_NMI (acpi_id[0xff]
dfl dfl lint[0x1]) [ 0.000000] ACPI: IOAPIC (id[0x00]
address[0xfec00000] gsi_base[0]) [ 0.000000] IOAPIC[0]: apic_id 0,
version 17, address 0xfec00000, GSI 0-23 [ 0.000000] ACPI:
INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 dfl dfl) [ 0.000000]
ACPI: INT_SRC_OVR (bus 0 bus_irq 5 global_irq 5 high level) [
0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 high level) [ 0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 10 global_irq 10 high
level) [ 0.000000] ACPI: INT_SRC_OVR (bus 0 bus_irq 11 global_irq
11 high level) [ 0.000000] Using ACPI (MADT) for SMP configuration
information [ 0.000000] SMP: Allowing 1 CPUs, 0 hotplug CPUs [
0.000000] PM: Registered nosave memory: 000000000009f000 - 00000000000a0000 [ 0.000000] PM: Registered nosave memory:
00000000000a0000 - 00000000000f0000 [ 0.000000] PM: Registered
nosave memory: 00000000000f0000 - 0000000000100000 [ 0.000000]
Allocating PCI resources starting at 40000000 (gap: 40000000:beffc000)
[ 0.000000] Booting paravirtualized kernel on KVM [ 0.000000]
setup_percpu: NR_CPUS:64 nr_cpumask_bits:64 nr_cpu_ids:1 nr_node_ids:1
[ 0.000000] PERCPU: Embedded 27 pages/cpu @ffff88003fc00000 s78848
r8192 d23552 u2097152 [ 0.000000] kvm-clock: cpu 0, msr 0:3fc126c1,
primary cpu clock [ 0.000000] KVM setup async PF for cpu 0 [
0.000000] kvm-stealtime: cpu 0, msr 3fc0cd40 [ 0.000000] Built 1 zonelists in Node order, mobility grouping on. Total pages: 257928 [
0.000000] Policy zone: DMA32 [ 0.000000] Kernel command line: LABEL=cirros-rootfs ro console=tty1 console=ttyS0 [ 0.000000] PID
hash table entries: 4096 (order: 3, 32768 bytes) [ 0.000000]
Checking aperture… [ 0.000000] No AGP bridge found [ 0.000000]
Memory: 1012368k/1048568k available (6576k kernel code, 452k absent,
35748k reserved, 6620k data, 928k init) [ 0.000000] SLUB:
Genslabs=15, HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 [
0.000000] Hierarchical RCU implementation. [ 0.000000] RCU dyntick-idle grace-period acceleration is enabled. [ 0.000000]
NR_IRQS:4352 nr_irqs:256 16 [ 0.000000] Console: colour VGA+ 80x25
[ 0.000000] console [tty1] enabled [ 0.000000] console [ttyS0]
enabled [ 0.000000] allocated 8388608 bytes of page_cgroup [
0.000000] please try ‘cgroup_disable=memory’ option if you don’t want memory cgroups [ 0.000000] Detected 1800.001 MHz processor. [
0.008000] Calibrating delay loop (skipped) preset value… 3600.00 BogoMIPS (lpj=7200004) [ 0.008014] pid_max: default: 32768 minimum:
301 [ 0.012000] Security Framework initialized [ 0.012033]
AppArmor: AppArmor initialized [ 0.016000] Yama: becoming mindful.
[ 0.016113] Dentry cache hash table entries: 131072 (order: 8,
1048576 bytes) [ 0.020001] Inode-cache hash table entries: 65536
(order: 7, 524288 bytes) [ 0.021023] Mount-cache hash table
entries: 256 [ 0.024001] Initializing cgroup subsys cpuacct [
0.024016] Initializing cgroup subsys memory [ 0.027850] Initializing cgroup subsys devices [ 0.028001] Initializing cgroup
subsys freezer [ 0.028016] Initializing cgroup subsys blkio [
0.031871] Initializing cgroup subsys perf_event [ 0.032426] mce: CPU supports 10 MCE banks [ 0.036002] SMP alternatives: switching
to UP code [ 0.072003] Freeing SMP alternatives: 24k freed [
0.072042] ACPI: Core revision 20110623 [ 0.076004] ftrace: allocating 26610 entries in 105 pages [ 0.088004] …TIMER:
vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1 [ 0.088004] CPU0: Intel
QEMU Virtual CPU version 1.5.3 stepping 03 [ 0.092004] APIC
calibration not consistent with PM-Timer: 269ms instead of 100ms [
0.092004] APIC delta adjusted to PM-Timer: 6249642 (16836955) [ 0.092235] Performance Events: Broken PMU hardware detected, using software events only. [ 0.096255] NMI watchdog disabled (cpu0):
hardware events not enabled [ 0.100035] Brought up 1 CPUs [
0.104008] Total of 1 processors activated (3600.00 BogoMIPS). [ 0.113042] devtmpfs: initialized [ 0.116386] EVM: security.selinux [ 0.120008] EVM: security.SMACK64 [ 0.124010] EVM: security.capability [ 0.128598] print_constraints: dummy: [
0.132270] RTC time: 2:25:59, date: 06/16/20 [ 0.136063] NET: Registered protocol family 16 [ 0.140269] ACPI: bus type pci
registered [ 0.144299] PCI: Using configuration type 1 for base
access [ 0.152630] bio: create slab at 0 [ 0.156187]
ACPI: Added _OSI(Module Device) [ 0.160012] ACPI: Added
_OSI(Processor Device) [ 0.164012] ACPI: Added _OSI(3.0 _SCP Extensions) [ 0.168015] ACPI: Added _OSI(Processor Aggregator
Device) [ 0.178180] ACPI: Interpreter enabled [ 0.180013] ACPI:
(supports S0 S5) [ 0.185923] ACPI: Using IOAPIC for interrupt
routing [ 0.194507] ACPI: No dock devices found. [ 0.196016]
HEST: Table not found. [ 0.200016] PCI: Using host bridge windows
from ACPI; if necessary, use “pci=nocrs” and report a bug [
0.204081] ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-ff]) [ 0.212109] pci_root PNP0A03:00: host bridge window [io 0x0000-0x0cf7] [ 0.216023] pci_root PNP0A03:00: host bridge window [io
0x0d00-0xffff] [ 0.224018] pci_root PNP0A03:00: host bridge window
[mem 0x000a0000-0x000bffff] [ 0.228020] pci_root PNP0A03:00: host
bridge window [mem 0x40000000-0xfebfffff] [ 0.244222] pci
0000:00:01.3: quirk: [io 0x0600-0x063f] claimed by PIIX4 ACPI [
0.248058] pci 0000:00:01.3: quirk: [io 0x0700-0x070f] claimed by PIIX4 SMB [ 0.293239] pci0000:00: Unable to request _OSC control
(_OSC support mask: 0x1e) [ 0.298010] ACPI: PCI Interrupt Link
[LNKA] (IRQs 5 *10 11) [ 0.304205] ACPI: PCI Interrupt Link [LNKB]
(IRQs 5 *10 11) [ 0.312200] ACPI: PCI Interrupt Link [LNKC] (IRQs 5
10 *11) [ 0.319075] ACPI: PCI Interrupt Link [LNKD] (IRQs 5 10 *11)
[ 0.326860] ACPI: PCI Interrupt Link [LNKS] (IRQs *9) [
0.332840] vgaarb: device added: PCI:0000:00:02.0,decodes=io+mem,owns=io+mem,locks=none [ 0.336028]
vgaarb: loaded [ 0.340023] vgaarb: bridge control possible
0000:00:02.0 [ 0.344318] i2c-core: driver [aat2870] using legacy
suspend method [ 0.348025] i2c-core: driver [aat2870] using legacy
resume method [ 0.352327] SCSI subsystem initialized [ 0.356718]
usbcore: registered new interface driver usbfs [ 0.360062] usbcore:
registered new interface driver hub [ 0.364146] usbcore: registered
new device driver usb [ 0.372061] PCI: Using ACPI for IRQ routing [
0.376916] NetLabel: Initializing [ 0.380039] NetLabel: domain hash size = 128 [ 0.384027] NetLabel: protocols = UNLABELED CIPSOv4 [
0.388105] NetLabel: unlabeled traffic allowed by default [ 0.392155] Switching to clocksource kvm-clock [ 0.408274] AppArmor: AppArmor Filesystem Enabled [ 0.413339] pnp: PnP ACPI init [
0.416712] ACPI: bus type pnp registered [ 0.422055] pnp: PnP ACPI: found 6 devices [ 0.426024] ACPI: ACPI bus type pnp unregistered [
0.437564] NET: Registered protocol family 2 [ 0.443305] IP route cache hash table entries: 32768 (order: 6, 262144 bytes) [
0.450809] TCP established hash table entries: 131072 (order: 9, 2097152 bytes) [ 0.461222] TCP bind hash table entries: 65536
(order: 8, 1048576 bytes) [ 0.469552] TCP: Hash tables configured
(established 131072 bind 65536) [ 0.475249] TCP reno registered [
0.478732] UDP hash table entries: 512 (order: 2, 16384 bytes) [ 0.483619] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes) [ 0.488724] NET: Registered protocol family 1 [ 0.492749] pci 0000:00:00.0: Limiting direct PCI/PCI transfers [ 0.498193] pci
0000:00:01.0: PIIX3: Enabling Passive Release [ 0.502955] pci
0000:00:01.0: Activating ISA DMA hang workarounds [ 0.508939]
audit: initializing netlink socket (disabled) [ 0.514107] type=2000
audit(1592274358.512:1): initialized [ 0.535974] Trying to unpack
rootfs image as initramfs… [ 0.572324] HugeTLB registered 2 MB
page size, pre-allocated 0 pages [ 0.584597] VFS: Disk quotas
dquot_6.5.2 [ 0.588238] Dquot-cache hash table entries: 512 (order
0, 4096 bytes) [ 0.600162] fuse init (API version 7.17) [
0.657173] msgmni has been set to 1977 [ 0.664903] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 253) [ 0.673578] io
scheduler noop registered [ 0.677427] io scheduler deadline
registered (default) [ 0.682134] io scheduler cfq registered [
0.685814] pci_hotplug: PCI Hot Plug PCI Core version: 0.5 [ 0.691156] pciehp: PCI Express Hot Plug Controller Driver version: 0.4 [ 0.697587] input: Power Button as
/devices/LNXSYSTM:00/LNXPWRBN:00/input/input0 [ 0.705179] ACPI:
Power Button [PWRF] [ 0.709410] ERST: Table is not found! [
0.713414] GHES: HEST is not enabled! [ 0.717354] ACPI: PCI Interrupt Link [LNKC] enabled at IRQ 11 [ 0.722132] virtio-pci
0000:00:03.0: PCI INT A -> Link[LNKC] -> GSI 11 (level, high) -> IRQ
11 [ 0.730998] ACPI: PCI Interrupt Link [LNKD] enabled at IRQ 10 [
0.738501] virtio-pci 0000:00:04.0: PCI INT A -> Link[LNKD] -> GSI 10 (level, high) -> IRQ 10 [ 0.787572] Serial: 8250/16550 driver, 32
ports, IRQ sharing enabled [ 0.819403] serial8250: ttyS0 at I/O
0x3f8 (irq = 4) is a 16550A [ 0.834332] Freeing initrd memory:
3448k freed [ 0.865640] 00:05: ttyS0 at I/O 0x3f8 (irq = 4) is a
16550A [ 0.870385] Linux agpgart interface v0.103 [ 0.875339]
brd: module loaded [ 0.880398] loop: module loaded [ 0.888421]
vda: vda1 [ 0.894439] scsi0 : ata_piix [ 0.897987] scsi1 :
ata_piix [ 0.901798] ata1: PATA max MWDMA2 cmd 0x1f0 ctl 0x3f6
bmdma 0xc060 irq 14 [ 0.907756] ata2: PATA max MWDMA2 cmd 0x170 ctl
0x376 bmdma 0xc068 irq 15 [ 0.913837] Fixed MDIO Bus: probed [
0.917158] tun: Universal TUN/TAP device driver, 1.6 [ 0.922010] tun: © 1999-2004 Max Krasnyansky maxk@qualcomm.com [ 0.931024]
PPP generic driver version 2.4.2 [ 0.935157] ehci_hcd: USB 2.0
‘Enhanced’ Host Controller (EHCI) Driver [ 0.940100] ohci_hcd: USB
1.1 ‘Open’ Host Controller (OHCI) Driver [ 0.945340] uhci_hcd: USB Universal Host Controller Interface driver [ 0.950471] usbcore:
registered new interface driver libusual [ 0.955512] i8042: PNP:
PS/2 Controller [PNP0303:KBD,PNP0f13:MOU] at 0x60,0x64 irq 1,12 [
0.965694] serio: i8042 KBD port at 0x60,0x64 irq 1 [ 0.969928] serio: i8042 AUX port at 0x60,0x64 irq 12 [ 0.974848] mousedev:
PS/2 mouse device common for all mice [ 0.980986] input: AT
Translated Set 2 keyboard as
/devices/platform/i8042/serio0/input/input1 [ 0.988834] rtc_cmos
00:01: RTC can wake from S4 [ 0.993703] rtc_cmos 00:01: rtc core:
registered rtc_cmos as rtc0 [ 1.000550] rtc0: alarms up to one day,
114 bytes nvram [ 1.005182] device-mapper: uevent: version 1.0.3 [
1.010124] device-mapper: ioctl: 4.22.0-ioctl (2011-10-19) initialised: dm-devel@redhat.com [ 1.018778] cpuidle: using governor ladder [
1.022624] cpuidle: using governor menu [ 1.026310] EFI Variables Facility v0.08 2004-May-17 [ 1.032627] TCP cubic registered [
1.036289] NET: Registered protocol family 10 [ 1.041201] NET: Registered protocol family 17 [ 1.046163] Registering the
dns_resolver key type [ 1.050657] registered taskstats version 1 [
1.057110] Magic number: 8:784:409 [ 1.061846] rtc_cmos 00:01: setting system clock to 2020-06-16 02:26:00 UTC (1592274360) [
1.069665] BIOS EDD facility v0.16 2004-Jun-25, 0 devices found [ 1.074947] EDD information not available. [ 1.086487] ata2.00: ATAPI: QEMU DVD-ROM, 1.5.3, max UDMA/100 [ 1.092422] ata2.00:
configured for MWDMA2 [ 1.098147] scsi 1:0:0:0: CD-ROM
QEMU QEMU DVD-ROM 1.5. PQ: 0 ANSI: 5 [ 1.108072] sr0:
scsi3-mmc drive: 4x/4x cd/rw xa/form2 tray [ 1.114047] cdrom:
Uniform CD-ROM driver Revision: 3.20 [ 1.119462] sr 1:0:0:0:
Attached scsi generic sg0 type 5 [ 1.124979] Freeing unused kernel
memory: 928k freed [ 1.130614] Write protecting the kernel
read-only data: 12288k [ 1.138536] Freeing unused kernel memory:
1596k freed [ 1.146507] Freeing unused kernel memory: 1184k freed
info: initramfs: up at 1.15 NOCHANGE: partition 1 is size 64260. it
cannot be grown info: initramfs loading root from /dev/vda1 info:
/etc/init.d/rc.sysinit: up at 1.22 info: container: none Starting
logging: OK modprobe: module virtio_blk not found in modules.dep
modprobe: module virtio_net not found in modules.dep WARN:
/etc/rc3.d/S10-load-modules failed Initializing random number
generator… done. Starting acpid: OK cirros-ds ‘local’ up at 1.31 no
results found for mode=local. up 1.35. searched: nocloud configdrive
ec2 Starting network… udhcpc (v1.20.1) started Sending discover…
Sending discover… Sending discover… Usage: /sbin/cirros-dhcpc
<up|down> No lease, failing WARN: /etc/rc3.d/S40-network failed
cirros-ds ‘net’ up at 181.56 checking
http://169.254.169.254/2009-04-04/instance-id failed 1/20: up 181.57.
request failed failed 2/20: up 183.61. request failed failed 3/20: up
185.62. request failed failed 4/20: up 187.63. request failed failed 5/20: up 189.63. request failed failed 6/20: up 191.64. request failed
failed 7/20: up 193.65. request failed failed 8/20: up 195.67. request
failed failed 9/20: up 197.68. request failed failed 10/20: up 199.68.
request failed failed 11/20: up 201.69. request failed failed 12/20:
up 203.71. request failed failed 13/20: up 205.72. request failed
failed 14/20: up 207.74. request failed failed 15/20: up 209.74.
request failed failed 16/20: up 211.75. request failed failed 17/20:
up 213.76. request failed failed 18/20: up 215.78. request failed
failed 19/20: up 217.80. request failed failed 20/20: up 219.81.
request failed failed to read iid from metadata. tried 20 no results
found for mode=net. up 221.82. searched: nocloud configdrive ec2
failed to get instance-id of datasource Starting dropbear sshd:
generating rsa key… generating dsa key… OK
=== system information === Platform: Red Hat KVM Container: none Arch: x86_64 CPU(s): 1 @ 1800.001 MHz Cores/Sockets/Threads: 1/1/1
Virt-type: RAM Size: 995MB Disks: NAME MAJ:MIN SIZE LABEL
MOUNTPOINT vda 253:0 41126400 vda1 253:1 32901120
cirros-rootfs / sr0 11:0 1073741312
=== sshd host keys ===
-----BEGIN SSH HOST KEY KEYS----- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgwCAmCNRw5vgevBzR67TIl8jq4ArzLo7as+190iRxNC/3uO5FayVLgO2Jg4MvYGfSibHpVWIF7lmqp3PJ4Sy8S7KQBe0i0Am5ctZMvfqGP948eerD25EQCWwrSqLNlTGGTU0BQGp6//B0c9Cx8OaedmaS4ZDC12gjpPZpdfZ45xanjpV
root@cirros ssh-dss
AAAAB3NzaC1kc3MAAACBALKd93nY0voUVtH5Q8jJW0iqJvva6v7LublJT+bPcI7cmZHo6GTRY8w0M1WPyA/b4hL/J1sBaXGR3FqUfK2tHyg3O1T2MwiweLRQyeYi5c/Xq1cgLDoRsrQlULaI8VeEiZ8a2yK7qltPzmit3u6RyG5S4Q0m+Tpl1nOiM4FPgjETAAAAFQCtMQTC/k6/BV0ltldxaPRogEFFfQAAAIEAh+eMVGriCk54lqjJln+olirNvCD6x3OKG6GCb4Yq8YI9EPR6ib1rpAMAARni0vq3Duiu/1hRJr6G5Od6giZQNtE6en2rVwybTDU6Ed75dInsUBvnFz+A29N5ZfdkNzWLlEJfiwHE6Z2wkPoLW8kpCHVW/COtz97+FsrA0y+Owt4AAACAOsPLF3NvDCfpZcB8voPFJBaxc0mCmjSgObG3etmnWPNKp3Vqqqt9wXjNBW1OEyqk2Ua4r/yULcCZ2PTWeOP0mAC26WXfEmWUUGR7kMq05GMG/nVlTsCOV56qy4jxtMWLbpwq/dJ9PWQHyeaMy5Qxq5CiiUeN2hW1kTMN6t4UDOU=
root@cirros
-----END SSH HOST KEY KEYS-----
=== network info === if-info: lo,up,127.0.0.1,8,::1 if-info: eth0,up,8,fe80::5054:ff:fe12:3456
=== datasource: None None ===
=== cirros: current=0.3.4 uptime=222.04 === route: fscanf
=== pinging gateway failed, debugging connection ===
############ debug start ##############
/etc/init.d/sshd start Starting dropbear sshd: OK route: fscanf
ifconfig -a eth0 Link encap:Ethernet HWaddr 52:54:00:12:34:56
inet6 addr: fe80::5054:ff:fe12:3456/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:8 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:1132 (1.1 KiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface route: fscanf
cat /etc/resolv.conf cat: can’t open ‘/etc/resolv.conf’: No such file or directory
gateway not found /sbin/cirros-status: line 1: can’t open /etc/resolv.conf: no such file
pinging nameservers
uname -a Linux cirros 3.2.0-80-virtual #116-Ubuntu SMP Mon Mar 23 17:28:52 UTC 2015 x86_64 GNU/Linux
lsmod Module Size Used by Not tainted nls_iso8859_1 12713 0 nls_cp437 16991 0 vfat
17585 0 fat 61512 1 vfat isofs
40259 0 ip_tables 27473 0 x_tables 29891
1 ip_tables pcnet32 42119 0 8139cp
27360 0 ne2k_pci 13691 0 8390 18856
1 ne2k_pci e1000 108589 0 acpiphp
24231 0
dmesg | tail [ 1.260111] acpiphp: Slot [29] registered [ 1.260118] acpiphp: Slot [30] registered [ 1.260126] acpiphp: Slot [31]registered [ 1.267385] e1000: Intel® PRO/1000 Network Driver
version 7.3.21-k8-NAPI [ 1.267386] e1000: Copyright © 1999-2006 Intel Corporation. [ 1.271543] ne2k-pci.c:v1.03 9/22/2003 D.
Becker/P. Gortmaker [ 1.274420] 8139cp: 8139cp: 10/100 PCI Ethernet
driver v1.3 (Mar 22, 2004) [ 1.277502] pcnet32: pcnet32.c:v1.35
21.Apr.2008 tsbogend@alpha.franken.de [ 1.284242] ip_tables: © 2000-2006 Netfilter Core Team [ 11.960551] eth0: no IPv6 routers
present
tail -n 25 /var/log/messages Jun 16 03:26:00 cirros kern.info kernel: [ 0.000000] KERNEL supported cpus: Jun 16 03:26:00 cirros
kern.info kernel: [ 0.000000] Intel GenuineIntel Jun 16 03:26:00
cirros kern.info kernel: [ 0.000000] AMD AuthenticAMD Jun 16
03:26:00 cirros kern.info kernel: [ 0.000000] Centaur
CentaurHauls Jun 16 03:26:00 cirros kern.info kernel: [ 0.000000]
BIOS-provided physical RAM map: Jun 16 03:26:00 cirros kern.info
kernel: [ 0.000000] BIOS-e820: 0000000000000000 - 000000000009fc00
(usable) Jun 16 03:26:00 cirros kern.info kernel: [ 1.259776]
acpiphp: ACPI Hot Plug PCI Controller Driver version: 0.5 Jun 16
03:26:00 cirros kern.info kernel: [ 1.259861] acpiphp: Slot [3]
registered Jun 16 03:26:00 cirros kern.info kernel: [ 1.259870]
acpiphp: Slot [4] registered Jun 16 03:26:00 cirros kern.info kernel:
[ 1.259891] acpiphp: Slot [5] registered Jun 16 03:26:00 cirros
kern.info kernel: [ 1.259917] acpiphp: Slot [6] registered Jun 16
03:26:00 cirros kern.info kernel: [ 1.259925] acpiphp: Slot [7]
registered Jun 16 03:26:00 cirros kern.info kernel: [ 1.259932]
acpiphp: Slot [8] registered Jun 16 03:26:00 cirros kern.info kernel:
[ 1.259940] acpiphp: Slot [9] registered Jun 16 03:26:00 cirros
kern.info kernel: [ 1.259948] acpiphp: Slot [10] registered Jun 16
03:26:00 cirros kern.info kernel: [ 1.259969] acpiphp: Slot [11]
registered Jun 16 03:26:00 cirros kern.info kernel: [ 1.259992]
acpiphp: Slot [12] registered Jun 16 03:26:00 cirros kern.info kernel:
[ 1.267385] e1000: Intel® PRO/1000 Network Driver - version
7.3.21-k8-NAPI Jun 16 03:26:00 cirros kern.info kernel: [ 1.267386] e1000: Copyright © 1999-2006 Intel Corporation. Jun 16 03:26:00
cirros kern.info kernel: [ 1.271543] ne2k-pci.c:v1.03 9/22/2003 D.
Becker/P. Gortmaker Jun 16 03:26:00 cirros kern.info kernel: [
1.274420] 8139cp: 8139cp: 10/100 PCI Ethernet driver v1.3 (Mar 22, 2004) Jun 16 03:26:00 cirros kern.info kernel: [ 1.277502] pcnet32:
pcnet32.c:v1.35 21.Apr.2008 tsbogend@alpha.franken.de Jun 16 03:26:00
cirros kern.info kernel: [ 1.284242] ip_tables: © 2000-2006
Netfilter Core Team Jun 16 03:26:11 cirros kern.debug kernel: [
11.960551] eth0: no IPv6 routers present Jun 16 03:29:41 cirros authpriv.info dropbear[299]: Running in background
############ debug end ############## ____ ____ ____ / / __ ____ ____ / __ / / / / / // // // /_/ /\ \ _///// // _/_/ http://cirros-cloud.net
login as ‘cirros’ user. default password: ‘cubswin:)’. use ‘sudo’ for
root.
cirros login: cirros
Password:
$ ip addr list
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
inet6 fe80::5054:ff:fe12:3456/64 scope link
valid_lft forever preferred_lft forever
创建虚拟机完成,使用cirros用户登录虚拟机,输入用户名cirros,密码cubswin:)。然后师叔ip addr list命令 查看IP地址,最后输入route -n明林查询路由表。命令如下。