linux interfaces配置文件详解

配置文件基本格式

路径:/etc/network/interfaces

一个基本的配置大概是下面这个样子:

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
       address 192.168.137.2
       netmask 255.255.255.0
       gateway 192.168.137.255

上面的配置中,
  第1行跟第5行说明lo接口跟eth0接口会在系统启动时被自动配置;
  好像不同的接口之间配置部分必须留有一个空格,比如第3行的空格
  第2行将lo接口设置为一个本地回环(loopback)地址;
  第4行指出eth0接口具有一个静态的(static)IP配置;
  第5行-第7行分别设置eth0接口的ip、网络号、掩码、广播地址和网关。

自动获取IP地址

auto eth0
iface eth0 inet dhcp

猜你喜欢

转载自blog.csdn.net/zhangwen_x/article/details/100920506
今日推荐