lin*_*sek 11 networking static-ip 16.04
我正在尝试在 Ubuntu 16.04 的接口上设置静态 IP。它用于没有 DHCP 服务器或 DNS 配置的本地连接。我已经尝试从 Edit Connections GUI 和 CLI 执行此操作,但运气不佳。
我四处搜索并发现了几个类似的问题(Set static IP Ubuntu 16.04等),但我自己似乎无法获得正确的设置。
这就是我所在的位置... 目前有三个设备连接到一个交换机。一个配置为 1.51,一个配置为 1.20,而这个 16.04 系统我正在尝试配置为 1.49。51 和 20 的沟通都很好。我已经更换了电缆并尝试了不同的端口……所以我知道这不是物理问题。而且,事实上,该交换机上的其他系统之一是 Ubuntu 14.04,其接口设置相同,但 IP 为 51。这里唯一的问题似乎是 Ubuntu 16.04 系统。
16.04 /etc/network/interfaces 文件:
# interfaces(5) file used by ifup(8) and ifdown(8)
# The loopback network interface
auto lo
iface lo inet loopback
# Primary network interface
auto enp4s0
#iface enp4s0 inet dhcp
iface enp4s0 inet static
address 192.168.1.49
netmask 255.255.255.0
gateway 192.168.1.1
$ ifconfig
enp4s0 Link encap:Ethernet HWaddr f4:8e:38:e7:39:31
inet addr:192.168.1.49 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::f68e:38ff:fee7:3931/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:258 errors:0 dropped:0 overruns:0 frame:0
TX packets:2123 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:28821 (28.8 KB) TX bytes:208448 (208.4 KB)
Run Code Online (Sandbox Code Playgroud)
一切看起来都很好。但 ping 失败。无法 ping 进或出。对我来说最有趣的是从 GUI 查看界面时的网络掩码。如果我从右上角的网络图标转到“编辑连接...”并编辑此界面,它会显示以下内容:
Address: 192.168.1.49
Netmask: 24
Gateway: 192.168.1.1
Run Code Online (Sandbox Code Playgroud)
“24”的网络掩码?这没有任何意义......但是从 CLI 的 ifconfig 看起来一切都很好。
我没有想法了。应该很简单吧……?
谢谢。
编辑 1:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 100 0 0 enp4s0
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 enp4s0
192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 enp4s0
Run Code Online (Sandbox Code Playgroud)
chi*_*555 10
您尚未声明 DNS 名称服务器。我建议你修改为:
# interfaces(5) file used by ifup(8) and ifdown(8)
# The loopback network interface
auto lo
iface lo inet loopback
# Primary network interface
auto enp4s0
#iface enp4s0 inet dhcp
iface enp4s0 inet static
address 192.168.1.49
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 192.168.1.1
Run Code Online (Sandbox Code Playgroud)
重启界面:
sudo ifdown enp4s0 && sudo ifup enp4s0
Run Code Online (Sandbox Code Playgroud)
平:
ping -c4 www.ubuntu.com
Run Code Online (Sandbox Code Playgroud)
如果您获得 ping 回报,则一切就绪。
归档时间: |
|
查看次数: |
38550 次 |
最近记录: |