天天看點

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