Linux 网络配置文件Interfaces模板

来源:互联网 发布:js获取json长度 编辑:程序博客网 时间:2024/05/22 02:23

前言

经常会对Linux的网络进行设置,但是经常忘记interfaces那几个单词的拼写。以下是模板。

设置 静态IP

auto eth0iface eth0 inet staticaddress 192.168.1.5netmask 255.255.255.0gateway 192.168.1.254dns-nameserver 114.114.114.114

设置动态IP

auto eth0iface eth0 inet dhcp

使修改生效:

  1. 使用 /etc/init.d/network restart 重启
  2. reboot
  3. Linux 高版本的Service不支持从 /etc/init.d/network 重启服务,需要使用ifdown 网卡名来关闭,ifup 网卡名来开启。如:ifdown eth0 && ifup eth0 先关闭再重启eth0网卡
0 0