当我尝试将 IP 地址从 DHCP 更改为静态时,我的互联网连接从 centos 断开。
Host os : MacOS High Sierra
VM : vmware fusion
Guest OS : CentOS Linux release 7.7.1908 (Core)
File : /etc/sysconfig/network-scripts/ifcfg-ens33
改变 :
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="none"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="189d7c44-fc61-4597-a9c1-ee3c22d4feed"
DEVICE="ens33"
ONBOOT="yes
IPADDR=192.168.1.20
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=8.8.4.4"`
`
更改后使用的命令:systemctl restart network
网络重新启动完成后,就不再有网络连接
我做错了什么吗
静态IP输出:
user1@localhost ~]$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
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: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:fb:3f:1b brd ff:ff:ff:ff:ff:ff
inet 192.168.1.20/24 brd 192.168.1.255 scope global noprefixroute ens33
valid_lft forever preferred_lft forever
inet6 fe80::8384:7399:f191:5b47/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:11:b8:79 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 group default qlen 1000
link/ether 52:54:00:11:b8:79 brd ff:ff:ff:ff:ff:ff
[user1@localhost ~]$
静态IP路由输出:
[user1@localhost ~]$ ip route
default via 192.168.1.1 dev ens33 proto static metric 100
192.168.1.0/24 dev ens33 proto kernel scope link src 192.168.1.20 metric 100
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1
DHCP IP 输出
[user1@localhost ~]$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
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: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:fb:3f:1b brd ff:ff:ff:ff:ff:ff
inet 172.16.111.178/24 brd 172.16.111.255 scope global noprefixroute dynamic ens33
valid_lft 1761sec preferred_lft 1761sec
inet6 fe80::8384:7399:f191:5b47/64 scope link noprefixroute
valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:11:b8:79 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 group default qlen 1000
link/ether 52:54:00:11:b8:79 brd ff:ff:ff:ff:ff:ff
[user1@localhost ~]$
DHCP ip 路由输出
[user1@localhost ~]$ ip route
default via 172.16.111.2 dev ens33 proto dhcp metric 100
172.16.111.0/24 dev ens33 proto kernel scope link src 172.16.111.178 metric 100
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1
[user1@localhost ~]$
答案1
您失去了互联网连接,因为您在错误的网络上配置了适配器。
当您使用 DHCP 时,DHCP 路由器/服务器会为您提供以下地址:
172.16.111.0/24
和默认网关172.16.111.2
。
当您静态配置它时,您已经选择了网络:
192.168.1.0/24
默认网关为192.168.1.1
.因此,虽然 192.168.1.1 可以从您配置的网络访问,但路由器/服务器不在那里。如果您想使用静态地址,则它需要与路由器位于同一网络上。根据 DHCP 配置,您应该能够选择任何没用过地址在172.16.111.0/24
.一般来说,这会172.16.111.1
通过172.16.111.255
,但看起来路由器正在使用172.16.111.2
.通常172.16.111.1
是路由器,因此可能还有其他东西。您可以获取 DHCP 地址,然后用于nmap
查看网络上使用的其他地址。
答案2
正如用户1794469 所描述的那样。您的网络访问是通过 172.16.111.x 网络 在 192.168.1.x 网络中配置的 virbr0 是您计算机内部的,它是 VirtualBridge0 它用于虚拟化,可能来自 VM 软件。