我正在按照本书的步骤Linux Basics for Hackers (No Starch Press, 2018)
使用 Kali Linux (2019.1a) 和 VirtualBox,当我更改网络信息(第 3 章)时,我无法再访问互联网。
这是我所做的:
$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
inet6 fe80::a00:27ff:fe77:94b prefixlen 64 scopeid 0x20<link>
ether 08:00:27:77:09:4b txqueuelen 1000 (Ethernet)
RX packets 15771 bytes 18253966 (17.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4016 bytes 243513 (237.8 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 1000 (Local Loopback)
RX packets 20 bytes 1116 (1.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 20 bytes 1116 (1.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
$ ping google.com
PING google.com (172.217.25.142) 56(84) bytes of data.
64 bytes from syd15s03-in-f14.1e100.net (172.217.25.142): icmp_seq=1 ttl=63 time=23.10 ms
64 bytes from syd15s03-in-f14.1e100.net (172.217.25.142): icmp_seq=2 ttl=63 time=23.4 ms
^C
--- google.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1ms
rtt min/avg/max/mdev = 23.351/23.655/23.959/0.304 ms
$ # Change IP from 10.0.2.15 to 10.0.2.21
$ ifconfig eth0 10.0.2.21 netmask 255.255.255.0 broadcast 10.0.2.255
$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.2.21 netmask 255.255.255.0 broadcast 10.0.2.255
inet6 fe80::a00:27ff:fe77:94b prefixlen 64 scopeid 0x20<link>
ether 08:00:27:77:09:4b txqueuelen 1000 (Ethernet)
RX packets 230432 bytes 263807948 (251.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 58741 bytes 3535449 (3.3 MiB)
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 1000 (Local Loopback)
RX packets 20 bytes 1116 (1.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 20 bytes 1116 (1.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
$ ping google.com
ping: google.com: Name or service not known
我再次检查了书中的命令,我所做的一切似乎都符合。
我如何才能更改我的网络信息而不中断我的网络/互联网访问?
答案1
不要在远程会话中尝试此操作!!!
当更改 eth0 的 IP 地址(也是您的接口)时default route
,您也必须更改它。
像这样:
# ifconfig eth0 down
# route del default
# ifconfig eth0 10.0.2.21 netmask 255.255.255.0 broadcast 10.0.2.255
# route add default eth0
这是根据记忆写的,所以你可能需要查阅手册页