我对 Linux 还不太熟悉。我正在设置 Web 服务器,并在 vSphere ESXi 5.5 主机上安装了 Ubuntu Server 14.04。使用 DHCP 时,我可以完美地连接到互联网,但当我应用静态设置时,我就无法连接到网站了。
奇怪的是,我可以 Ping google.com,但如果我尝试 wget gooogl.com,它会挂在连接到 google.com (google.com):173.194.43.32:80 处,并且出现“失败:连接被拒绝”
但如果我设置为 DHCP,连接就能完美解决。谢谢
# 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 dhcp
iface eth0 inet static
address 10.1.2.25
gateway 10.1.2.2
netmask 255.255.255.0
search tsig.com
dns-nameservers 10.1.2.13 10.1.2.30
答案1
打开网络配置文件
$ sudo vi /etc/network/interfaces
或$ sudo nano /etc/network/interfaces
查找并删除 dhcp 条目:iface eth0 inet dhcp
附加新的网络设置:
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.254
保存并关闭文件。重启网络:
$ sudo /etc/init.d/networking restart