Ubuntu设置静态IP

2018-07-19  本文已影响0人  RudyXiong

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

# The primary network interface
auto eth0
iface eth0 inet dhcp

设置静态ip的方法如下:

  1. 编辑 /etc/network/interfaces

    a. 将dhcp 一行屏蔽

    # The primary network interface
    auto eth0
    #iface eth0 inet dhcp

    b. 添加和静态ip有关的参数

    # The primary network interface
    iface eth0 inet static
    address 192.168.0.10
    netmask 255.255.255.0
    gateway 192.168.0.1

  1. 编辑 /etc/resolv.conf,设置dns

    nameserver 202.96.134.133
    nameserver 202.106.0.20

  2. 执行下面两个命令,启用新设置

    $ sudo ifdown eth0
    $ sudo ifup eth0
    
上一篇 下一篇

猜你喜欢

热点阅读