~ # ping 192.168.0.199
PING 192.168.0.199 (192.168.0.199): 56 data bytes
ping: sendto: Network is unreachable
用route命令測試,全是空的
~ # route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
原來是文件系統問題
手動命令
~ # ifconfig eth0 up
nuc970-emac0 nuc970-emac0: eth0 is OPENED
~ # ifconfig eth0 192.168.0.4 netmask 255.255.255.0
~ # route add default gw 192.168.0.1
~ # route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
192.168.0.0 * 255.255.255.0 U 0 0 0 eth0
~ # ping 192.168.0.199
PING 192.168.0.199 (192.168.0.199): 56 data bytes
64 bytes from 192.168.0.199: seq=0 ttl=64 time=2.266 ms
64 bytes from 192.168.0.199: seq=1 ttl=64 time=1.584 ms
64 bytes from 192.168.0.199: seq=2 ttl=64 time=1.517 ms
^C
--- 192.168.0.199 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 1.517/1.789/2.266 ms
~ #
~ #
~ #
~ # ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:00:01:92
inet addr:192.168.0.4 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1041 errors:0 dropped:86 overruns:0 frame:0
TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:105308 (102.8 KiB) TX bytes:126 (126.0 B)
也可以直接用
~ # ifconfig eth0 192.168.0.4 up
nuc970-emac0 nuc970-emac0: eth0 is OPENED
~ # ping 192.168.0.199
PING 192.168.0.199 (192.168.0.199): 56 data bytes
64 bytes from 192.168.0.199: seq=0 ttl=64 time=2.342 ms
64 bytes from 192.168.0.199: seq=1 ttl=64 time=1.092 ms
^C
--- 192.168.0.199 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
參考:https://blog.csdn.net/argon_ghost/article/details/104419600