设置后静态IPvmware 机器上的地址,重新启动 centos,这是我收到此错误后的情况:
Destination Host Unreachable
- 我尝试将 NAT 更改为 Bridge,但没有任何变化,事实上,我无法使用 Putty 进行连接桥通过终端模式
nano ifcfg-ens33
TYPE=Ethernet BOOTPROTO=static IPADDR=192.168.52.128 BROADCAST=192.168.52.255 NETMASK=255.255.255.0 GATEWAY=192.168.160.1 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=ens33 UUID=(long) DEVICE=ens33 ONBOOT=yes DNS1=8.8.8.8 DNS2=8.8.4.4`
/etc/resolv.conf
#Generated by NetworkManager nameserver 8.8.8.8 nameserver 8.8.4.4`
lspci | egrep -i --color 'network|ethernet'
02:01.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)
我可以 ping 自己。
ping 127.0.0.1
返回数据包route
[root@localhost ~]# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface default gateway 0.0.0.0 UG 100 0 0 ens33 192.168.52.0 0.0.0.0 255.255.255.0 U 100 0 0 ens33 gateway 0.0.0.0 255.255.255.255 UH 100 0 0 ens33
ifconfig -a
[root@localhost ~]# ifconfig -a ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.52.128 netmask 255.255.255.0 broadcast 192.168.52.255 inet6 fe80::20c:29ff:fea1:d692 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:a1:d6:92 txqueuelen 1000 (Ethernet) RX packets 81 bytes 8444 (8.2 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 129 bytes 15447 (15.0 KiB) 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 126 bytes 11662 (11.3 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 126 bytes 11662 (11.3 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
网络处于活动状态
[root@localhost ~]# systemctl status NetworkManager NetworkManager.service - Network Manager Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled) Active: active (running) since sab 2017-06-10 14:29:39 CEST; 3min 36s ago Docs: man:NetworkManager(8) Main PID: 658 (NetworkManager) CGroup: /system.slice/NetworkManager.service └─658 /usr/sbin/NetworkManager --no-daemon giu 10 14:29:41 localhost.localdomain NetworkManager[658]: <info> [149709778...
我需要一个静态 IP,因为我设置了一个服务器游戏
答案1
您配置的网关位于您的子网之外。
IPADDR=192.168.52.128
NETMASK=255.255.255.0
GATEWAY=192.168.160.1
您可以访问范围内的地址192.168.52.1..192.168.52.254无需路由器/网关。
如果要访问此范围之外的地址,则需要路由器/网关。该路由器/网关必须位于可访问的 IP 地址范围内。
答案2
在 CentOS 上设置静态 IP
要查找正确的网关, 做:
nmtui
// select your ens18 or eth01 or your connection-name
Modify > IPV4 > select <Automatic>
进入终端并输入
ip route
// you'll get
// default via 172.16.0.22 <-- this is your gateway
要找到DNS 服务器, 做:
nslookup google.com
// you'll
// Server: 172.18.4.13 <-- this is your DNS
现在您可以按如下方式配置静态 IP:
nmtui > Modify connection
// select connection-name > Modify
select IPV4 Configuartion > Manual
// Addresses: enter your static IP address / 24; ex. 172.16.40.4/24
// Gateway: enter your gateway
// DNS server: enter your DNS server
Then you can tick "Connect automatically" > Save
nmcli con down connection-name // or deactivate/reactivate connection from nmtui gui
nmcli con up connection-name