天天看点

Debian系统学习笔记(2):网卡配置信息

2、网卡配置信息

(1)静态IP内容如下

# vim/etc/network/interfaces

# This file describes the network interfacesavailable on your system

# and how to activate them. For more information, seeinterfaces(5).

# The loopback network interface

auto lo

iface lo inet loopback

# The primary network interface

allow-hotplug eth0         //即插即用

auto eth0                  //网卡自启动

iface eth0 inet static

         address192.168.0.42

         netmask255.255.255.0

         gateway192.168.0.1     //内网的无网关是可以不填写

(2)dhcp自动获取

Allow-hotplug eth0

iface eth0 inet dhcp     //dhcp获取IP地址

auto eth0

#/etc/init.d/ networking restart  //重启网卡

#ifconfig eth0 down\up //关闭和开启eth0网卡 或者 #ifdown eth0 && ifup eth0

# /etc/init.d/networking stop && /etc/init.d/networkingstart  //Debian6需要这样重启网卡

#vim /etc/hostname  //修改计算机名

#vim /etc/hosts   //修改hosts解析

#vim /etc/resolv.conf   //配置DNS  例如:nameserver 202.106.0.20

(3)一块网卡编辑多个地址  

 auto   eth0:1 

 iface  eth0:1 inet  static

 adderss X.X.X.X

 netmask X.X.X.X.

(4)编辑:resolv.conf文件

nameserver  #定义DNS服务器的IP地址

domain      #定义本地域名,可不写

search      #定义域名的搜索列表,可不写

sortlist    #对返回的域名进行排序,可不写

#cat /etc/resolv.conf的一个示例:

nameserver 202.96.128.86

nameserver 202.96.128.166

(5)修改网卡MAC地址

hwaddress ether 00:00:39:9E:58:3C     //对应的网卡配置文件中加入新MAC地址

临时地修改也可以这样

ifconfig eth0 down

ifconfig eth0 hw ether XX:XX:XX:XX:XX:XX

ifconfig eth0 up