Dta*_*vpp 3 networking internet static-ip
因此,如上所述,我可以远程访问我的服务器,并使用 SSH 在本地访问,但是我无法访问“互联网”。我的意思是我无法访问网页。
dtipp@mc-server:~$ ping www.google.com
ping: unknown host www.google.com
Run Code Online (Sandbox Code Playgroud)
这就是我尝试 ping google 时得到的结果。
dtipp@mc-server:~$ curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//'
Run Code Online (Sandbox Code Playgroud)
不会像以前那样产生 ip 地址。我所有的问题都是在尝试设置静态 IP 地址后开始的。我终于设法让我的文件看起来像我认为应该的那样,但只是现在问题才开始。
dtipp@mc-server:~$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:19:b9:d3:b1:fa
inet addr:192.168.1.120 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::219:b9ff:fed3:b1fa/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:21401 errors:0 dropped:0 overruns:0 frame:0
TX packets:20888 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3207899 (3.2 MB) TX bytes:4381547 (4.3 MB)
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:4102 errors:0 dropped:0 overruns:0 frame:0
TX packets:4102 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:353932 (353.9 KB) TX bytes:353932 (353.9 KB)
dtipp@mc-server:~$ sudo nano /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 192.168.1.120
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
dtipp@mc-server:~$ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# nameserver 192.168.1.120
dtipp@mc-server:~$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=58 time=29.1 ms
^C
--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 28.564/28.827/29.108/0.329 ms
Run Code Online (Sandbox Code Playgroud)
这是安装文件,以及其他一些 ping 操作的结果。我做错了什么还是我需要做一些额外的事情?
设置静态IP地址时,还必须设置DNS名称服务器。建议您修改/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 192.168.1.120
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1 8.8.8.8
Run Code Online (Sandbox Code Playgroud)
重启界面:
sudo ifdown eth0 && sudo ifup -v eth0
Run Code Online (Sandbox Code Playgroud)
测试:
ping -c3 www.ubuntu.com
Run Code Online (Sandbox Code Playgroud)
您的 /etc/resolv.conf 也不正确。请修改:
nameserver 127.0.1.1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9827 次 |
| 最近记录: |