尝试将 /28 绑定到我的 Ubuntu 14.04 专用服务器。一切看起来都很好,但我无法从我的服务器 ping 除其自己的 .82 之外的任何 IP。我感到很困惑。
我的 resolv.conf 设置为 Google 的 DNS(我甚至首先有了主 IP,但两者都不起作用)。
我的/etc/network/interfaces
:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet static
address xxx.xxx.42.82
netmask 255.255.255.240
gateway xxx.xxx.42.81
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers xxx.xxx.42.82
user@ubuntu:~$ ip addr show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:25:90:3a:c2:36 brd ff:ff:ff:ff:ff:ff
inet xxx.xxx.42.82/28 brd xxx.xxx.42.95 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::225:90ff:fe3a:c236/64 scope link
valid_lft forever preferred_lft forever
user@ubuntu:~$ ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:25:90:3a:c2:36
inet addr:xxx.xxx.42.82 Bcast:xxx.xxx.42.95 Mask:255.255.255.240
inet6 addr: fe80::225:90ff:fe3a:c236/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1988597 errors:0 dropped:1277940 overruns:0 frame:0
TX packets:562121 errors:198 dropped:0 overruns:0 carrier:198
collisions:16020 txqueuelen:1000
RX bytes:281303904 (281.3 MB) TX bytes:121464307 (121.4 MB)
Interrupt:16 Memory:fb5e0000-fb600000
还跑了/etc/init.d/networking restart
下面也试过了,除了 .82 主端口以外,仍然无法 ping 通任何东西。
# The primary network interface
auto eth0
iface eth0 inet static
address xxx.xxx.42.82
netmask 255.255.255.240
gateway xxx.xxx.42.81
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 8.8.8.8
eth0 Link encap:Ethernet HWaddr 00:25:90:3a:c2:36
inet addr:xxx.xxx.42.82 Bcast:xxx.xxx.42.95 Mask:255.255.255.240
inet6 addr: fe80::225:90ff:fe3a:c236/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:14425 errors:0 dropped:12092 overruns:0 frame:0
TX packets:911 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1118063 (1.1 MB) TX bytes:212166 (212.1 KB)
Interrupt:16 Memory:fb5e0000-fb600000
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:1210 errors:0 dropped:0 overruns:0 frame:0
TX packets:1210 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:66658 (66.6 KB) TX bytes:66658 (66.6 KB)
GUNTBERT 的最新消息
user@ubuntu:~$ sudo ip addr add xxx.xxx.42.80/28 dev eth0
user@ubuntu:~$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:25:90:3a:c2:36 brd ff:ff:ff:ff:ff:ff
inet xxx.xxx.42.82/28 brd xxx.xxx.42.95 scope global eth0
valid_lft forever preferred_lft forever
inet xxx.xxx.42.80/28 scope global secondary eth0
valid_lft forever preferred_lft forever
inet6 fe80::225:90ff:fe3a:c236/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 00:25:90:3a:c2:37 brd ff:ff:ff:ff:ff:ff
答案1
xxx.xxx.xxx.64 / 28
表示主机来自xxx.xxx.xxx.65
- xxx.xxx.xxx.79
。此范围内的一个地址必须位于路由器的 LAN 端口上。
例子
路由器 lan 端口配置
ip: xxx.xxx.xxx.65
nm: 255.255.255.240
主机配置
ip: xxx.xxx.xxx.66
nm: 255.255.255.240
gw: xxx.xxx.xxx.65