ubuntu网络配置

一、dhcp自动获取IP

编辑/etc/network/interfaces

  1. auto lo                                       # 开机自动激lo接口
  2. iface lo inet loopback                        # 配置lo接口为环回口
  3. # The primary network interface (配置主网络接口)
  4. auto eth0                                     #开机自动激活eth0接口
  5. iface eth0 inet dhcp                          #配置eth0接口为DHCP自动获取

重启网络:

  1. sudo /etc/init.d/networking restart

二、配置静态IP

编辑/etc/network/interfaces

  1. # The loopback network interface(配置环回口)
  2.   auto lo                                       # 开机自动激lo接口
  3.   iface lo inet loopback                        # 配置lo接口为环回口
  4.   # The primary network interface (配置主网络接口)
  5.   auto eth0                                     #开机自动激活eth0接口
  6.   iface eth0 inet static                        #配置eth0接口为静态设置IP地址
  7.   address 10.16.3.99
  8.   netmask 255.255.255.0
  9.   gateway 10.16.3.1

重启网络:

  1. sudo /etc/init.d/networking restart
标签:Ubuntu 发布于:2019-11-22 20:21:31