Ubuntu的网络参数保存在文件 /etc/network/interfaces中,默认设置使用dhcp,内容如下:

# The primary network interface
auto eth0
iface eth0 inet dhcp
也有可能是其它的网络接口如:eth1,eth2,根据具体的情况决定。

设置静态ip的方法如下:
1) 编辑 /etc/network/interfaces
1.1)将dhcp 一行屏蔽
# The primary network interface
auto eth0
#iface eth0 inet dhcp

1.2)添加和静态ip有关的参数
# The primary network interface
iface eth0 inet static
address 192.168.0.10
netmask 255.255.255.0
gateway 192.168.0.1

2)编辑 /etc/resolv.conf,设置dns
nameserver 202.96.134.133
nameserver 202.106.0.20

Ubuntu Server 12.04 配置DNS时不能直接编辑/etc/resolv.conf,重启后会覆盖。因此,手工配置DNS需:

$sudo vim  /etc/resolvconf/resolv.conf.d/tail

添加:

nameserver 192.168.0.1

然后重启resolvconf服务即可。


3)执行下面两个命令,启用新设置
$sudo ifdown eth0
$sudo ifup eth0

相关文章:

  • 2021-12-25
  • 2021-08-04
  • 2022-02-07
  • 2022-12-23
  • 2022-12-23
  • 2021-07-11
  • 2021-10-21
  • 2021-06-18
猜你喜欢
  • 2021-12-25
  • 2021-06-12
  • 2021-09-15
  • 2021-05-29
  • 2021-11-10
  • 2022-12-23
相关资源
相似解决方案