Networking
為什麼我不能用靜態 IP 地址 ping Google?
我正在嘗試安裝vicibox,這是一個包含 Asterisk 的 OpenSUSE 發行版。精美的手冊說要設置一個靜態 IP 地址
yast lan
。有什麼區別:
││[ ] Change Hostname via DHCP ││ ││[x] Assign Hostname to Loopback IP
我設置了主機名:
YaST2 - lan @ arrakis Network Settings ┌Global Options──Overview──Hostname/DNS──Routing──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │┌Hostname and Domain Name───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐│ ││Hostname Domain Name ││ ││arrakis▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ bounceme.net▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ││ ││[ ] Change Hostname via DHCP ││ ││[x] Assign Hostname to Loopback IP ││ │└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘│ │Modify DNS configuration Custom Policy Rule │ │Use Default Policy▒▒▒▒▒↓ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒↓ │ │┌Name Servers and Domain Search List────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐│ ││Name Server 1 ┌Domain Search──────────────────────────────────────────────────────────────────────┐││ ││8.8.8.8▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │google.com │││ ││Name Server 2 │ │││ ││8.8.4.4▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │ │││ ││Name Server 3 │ │││ ││▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ └───────────────────────────────────────────────────────────────────────────────────┘││ │└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘│ │ │ │ │ │
具有良好的連接性:
arrakis:~ # arrakis:~ # uname -a Linux arrakis 3.11.10-21-default #1 SMP Mon Jul 21 15:28:46 UTC 2014 (9a9565d) x86_64 x86_64 x86_64 GNU/Linux arrakis:~ # arrakis:~ # cat /etc/hosts # # hosts This file describes a number of hostname-to-address # mappings for the TCP/IP subsystem. It is mostly # used at boot time, when no name servers are running. # On small systems, this file can be used instead of a # "named" name server. # Syntax: # # IP-Address Full-Qualified-Hostname Short-Hostname # 127.0.0.1 localhost # special IPv6 addresses ::1 localhost ipv6-localhost ipv6-loopback fe00::0 ipv6-localnet ff00::0 ipv6-mcastprefix ff02::1 ipv6-allnodes ff02::2 ipv6-allrouters ff02::3 ipv6-allhosts 127.0.0.2 arrakis.bounceme.net arrakis arrakis:~ # arrakis:~ # hostname arrakis arrakis:~ # arrakis:~ # ping arrakis.bounceme.net PING arrakis.bounceme.net (127.0.0.2) 56(84) bytes of data. 64 bytes from arrakis.bounceme.net (127.0.0.2): icmp_seq=1 ttl=64 time=0.040 ms 64 bytes from arrakis.bounceme.net (127.0.0.2): icmp_seq=2 ttl=64 time=0.050 ms 64 bytes from arrakis.bounceme.net (127.0.0.2): icmp_seq=3 ttl=64 time=0.049 ms ^C --- arrakis.bounceme.net ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 1998ms rtt min/avg/max/mdev = 0.040/0.046/0.050/0.007 ms arrakis:~ # arrakis:~ # arrakis:~ # ping arrakis PING arrakis.bounceme.net (127.0.0.2) 56(84) bytes of data. 64 bytes from arrakis.bounceme.net (127.0.0.2): icmp_seq=1 ttl=64 time=0.036 ms 64 bytes from arrakis.bounceme.net (127.0.0.2): icmp_seq=2 ttl=64 time=0.041 ms 64 bytes from arrakis.bounceme.net (127.0.0.2): icmp_seq=3 ttl=64 time=0.041 ms c64 bytes from arrakis.bounceme.net (127.0.0.2): icmp_seq=4 ttl=64 time=0.040 ms 64 bytes from arrakis.bounceme.net (127.0.0.2): icmp_seq=5 ttl=64 time=0.043 ms ^C --- arrakis.bounceme.net ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 3996ms rtt min/avg/max/mdev = 0.036/0.040/0.043/0.004 ms arrakis:~ # arrakis:~ # arrakis:~ # ifconfig enp5s0 Link encap:Ethernet HWaddr 50:E5:49:C2:C8:05 inet addr:192.168.0.21 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::52e5:49ff:fec2:c805/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2632 errors:0 dropped:0 overruns:0 frame:0 TX packets:278 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:173852 (169.7 Kb) TX bytes:38509 (37.6 Kb) 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:65536 Metric:1 RX packets:40 errors:0 dropped:0 overruns:0 frame:0 TX packets:40 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:3248 (3.1 Kb) TX bytes:3248 (3.1 Kb) arrakis:~ #
但想將 IP 地址設置為靜態:
YaST2 - lan @ arrakis Network Card Setup ┌General──Address──Hardware───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ │ Device Type Configuration Name │ │ Ethernet▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒↓ enp5s0▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │ │( ) No Link and IP Setup (Bonding Slaves) [ ] Use iBFT values │ │( ) Dynamic Address DHCP▒▒▒▒▒▒▒▒▒▒↓ DHCP both version 4 and 6▒↓ │ │(x) Statically assigned IP Address │ │IP Address Subnet Mask Hostname │ │192.168.0.21▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ 255.255.255.0▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ arrakis.bounceme.net▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │ │┌Additional Addresses───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐│ ││ ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐ ││ ││ │Alias Name│IP Address│Netmask │ ││ ││ │ │ ││ ││ │ │ ││ ││ │
然而,一旦我這樣做,我就會失去連接:
arrakis:~ # yast lan arrakis:~ # arrakis:~ # arrakis:~ # ifconfig enp5s0 Link encap:Ethernet HWaddr 50:E5:49:C2:C8:05 inet addr:192.168.0.21 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::52e5:49ff:fec2:c805/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:4027 errors:0 dropped:0 overruns:0 frame:0 TX packets:858 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:271734 (265.3 Kb) TX bytes:265009 (258.7 Kb) 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:65536 Metric:1 RX packets:40 errors:0 dropped:0 overruns:0 frame:0 TX packets:40 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:3248 (3.1 Kb) TX bytes:3248 (3.1 Kb) arrakis:~ # arrakis:~ # arrakis:~ # ping google.com ping: unknown host google.com arrakis:~ #
為什麼我無法 ping Google?
也可以看看:
http://www.vicidial.org/VICIDIALforum/viewtopic.php?f=4&t=34261
————————————————– - - - - - - - 更新
更改為靜態IP地址後。它與動態時的IP地址相同。
使用靜態IP:
arrakis:~ # arrakis:~ # ifconfig enp5s0 Link encap:Ethernet HWaddr 50:E5:49:C2:C8:05 inet addr:192.168.0.21 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::52e5:49ff:fec2:c805/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:10438 errors:0 dropped:0 overruns:0 frame:0 TX packets:1133 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:671095 (655.3 Kb) TX bytes:300227 (293.1 Kb) 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:65536 Metric:1 RX packets:40 errors:0 dropped:0 overruns:0 frame:0 TX packets:40 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:3248 (3.1 Kb) TX bytes:3248 (3.1 Kb) arrakis:~ # arrakis:~ # ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 brd 127.255.255.255 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp5s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 50:e5:49:c2:c8:05 brd ff:ff:ff:ff:ff:ff inet 192.168.0.21/24 brd 192.168.0.255 scope global enp5s0 valid_lft forever preferred_lft forever inet6 fe80::52e5:49ff:fec2:c805/64 scope link valid_lft forever preferred_lft forever arrakis:~ # arrakis:~ # ip route 127.0.0.0/8 dev lo scope link 192.168.0.0/24 dev enp5s0 proto kernel scope link src 192.168.0.21 arrakis:~ # arrakis:~ # ping www.google.com ping: unknown host www.google.com arrakis:~ # arrakis:~ # yast lan arrakis:~ #
然後,我認為切換回 DHCP 應該可以恢復 ping google 的能力:
arrakis:~ # arrakis:~ # ping www.google.com ping: unknown host www.google.com arrakis:~ # arrakis:~ # ip route 127.0.0.0/8 dev lo scope link 192.168.0.0/24 dev enp5s0 proto kernel scope link src 192.168.0.21 arrakis:~ # arrakis:~ # ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 brd 127.255.255.255 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: enp5s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 50:e5:49:c2:c8:05 brd ff:ff:ff:ff:ff:ff inet 192.168.0.21/24 brd 192.168.0.255 scope global enp5s0 valid_lft forever preferred_lft forever inet6 fe80::52e5:49ff:fec2:c805/64 scope link valid_lft forever preferred_lft forever arrakis:~ # arrakis:~ # ifconfig enp5s0 Link encap:Ethernet HWaddr 50:E5:49:C2:C8:05 inet addr:192.168.0.21 Bcast:192.168.0.255 Mask:255.255.255.0 inet6 addr: fe80::52e5:49ff:fec2:c805/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:11178 errors:0 dropped:0 overruns:0 frame:0 TX packets:1490 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:723997 (707.0 Kb) TX bytes:415085 (405.3 Kb) 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:65536 Metric:1 RX packets:40 errors:0 dropped:0 overruns:0 frame:0 TX packets:40 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:3248 (3.1 Kb) TX bytes:3248 (3.1 Kb) arrakis:~ #
顯然不是..
從您的輸出:
arrakis:~ # ip route 127.0.0.0/8 dev lo scope link 192.168.0.0/24 dev enp5s0 proto kernel scope link src 192.168.0.21 arrakis:~ #
您沒有預設路由。因此,您只能訪問
127.0.0.0/8
(本地主機)或192.168.0.0/24
(本地子網)上的內容。添加預設路線,您應該一切順利。