我有一台 CentOS 主机和一台 CentOS 客户机(均为 6.5)。在我的客户机上,我安装并设置了 Samba,并为其指定了一个固定 IP 192.168.1.2
(我的主机是192.168.1.1
/ 我的路由器是192.168.1.254
)。从另一台 Windows 机器上,我可以192.168.1.2
成功 ping 通,但当我尝试 ping 时,198.168.1.1
我得到
Reply from 192.168.1.74: Destination host unreachable
让我困惑的是192.168.1.74
Windows 计算机的 IP。当我尝试访问时,\\192.168.1.2
我收到“Windows 无法访问 \192.168.1.2”
从我的主机,我无法 ping 路由器,客户机或 Windows 机器;错误始终是:
From 192.168.1.253 icmp_seq=2 Destination host unreachable
192.168.1.253
是我给 Host-only 网络分配的 IP(在执行以下这些说明)。
有用的(?)信息
ifconfig
在主机上运行:
eth0 Link encap:Ethernet HWaddr <mac address>
inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::219::dbff:fedd:85ff/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1579724 errors:0 dropped:0 overruns:0 frame:0
TX packets:799227 errors:2 dropped:0 overruns:0 carrier:2
collisions:26201 txqueuelen:1000
RX bytes:2280375441 (2.1 GiB) TX bytes:53645618 (51.1 MiB)
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:157 errors:0 dropped:0 overruns:0 frame:0
TX packets:157 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:25088 (14.7 KiB) TX bytes:15088 (14.7 KiB)
vboxnet0 Link encap:Ethernet <mac address>
inet addr:192.168.1.253 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::800::27ff:fe00:0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:158 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 KiB) TX bytes:30600 (29.8 KiB)
主持人的内容/etc/sysconfig/network-scripts/ifcdg-eth0
DEVICE=0
NM_CONTROLLED=yes
ONBOOT=yes
HWAddr <mac address>
TYPE=Ethernet
BOOTPROTO=static
IPADDR=192.168.1.1
NETMASK=255.255.255.0
ifconfig
在客户机上运行:
eth0 Link encap:Ethernet HWaddr <mac address>
inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe7e:c981/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:468 (468.0 b)
Interrupt:9 Base address:0xd240
eth1 Link encap:Ethernet HWaddr <mac address>
inet addr:192.168.1.103 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fed9:e691/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5614 errors:4 dropped:0 overruns:0 frame:0
TX packets:3055 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5885081 (5.6 MiB) TX bytes:498347 (486.6 KiB)
Interrupt:10 Base address:0xd020
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:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:480 (480.0 b) TX bytes:480 (480.0 b)
客人的内容/etc/sysconfig/network-scripts/ifcdg-eth0
DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
HWADDR=<mac address>
NETMASK=255.255.255.0
IPADDR=192.168.1.2
运行结果testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Processing section "[homes]"
Processing section "[printers]"
Processing section "[Share]"
Loaded services file OK.
Server role: ROLE_STANDALONE
Press enter to see a dump of your service definitions
[global]
workgroup = MyWG
log file = /var/log/samba/log.%m
max log size = 50
idmap config * : backend = tdb
cups options = raw
[homes]
comment = Home Directories
read only = No
browseable = No
[printers]
comment = All Printers
path = /var/spool/samba
printable = Yes
print ok = Yes
browseable = No
[Share]
path = /SharedFiles
valid users = Dev
read only = No
欢迎提供任何我可能做错的提示/或其他/更好的教程的链接!
答案1
您的问题是,在设置仅主机网络时,您使用了与您的 LAN 完全相同的网络,i.e.
192.168.1.0/24。这会造成混淆。
要纠正此问题,您只需纠正仅主机网络的子网:文件 -> 首选项 -> 网络 -> 仅主机网络 -> Screwdriver,然后更改 DHCP 和适配器中的 IP 地址。选择一些不常见的 IP 地址,例如 192.168.133.0/24,这样就没问题了。
答案2
据我了解,您使用的是仅主机网络。顾名思义,它只与主机通信。如果您需要从其他(真实)机器访问虚拟机,则应设置桥接网络,这样客户机就会表现得像您网络上的另一台机器一样。