1、網絡接口配置文件
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0 # 網卡接口名稱
BOOTPROTO=none # 啓用地址協議 --static:靜態協議 --bootp協議 --dhcp協議 --none手工指定
HWADDR=00:0C:29:2F:04:7E # 網卡設備MAC地址
IPADDR=192.168.1.26 # 網卡IP地址
IPV6INIT=yes # 是否支持IPv6【非必須】
IPV6_AUTOCONF=yes # IPv6是否自動配置【非必須】
NETMASK=255.255.255.0 # 子網掩碼
BROADCAST=192.168.1.255 # 廣播地址【非必須】
GATEWAY=192.168.1.1 # 網關地址
DNS1=192.168.1.1 # DNS1地址【非必須】
ONBOOT=yes # 系統啓動時是否自動加載
TYPE=Ethernet # 網絡類型【非必須】
PEERDNS=yes
USERCTL=nohtml
2、網關配置文件(重啓生效)
[root@localhost ~]# vi /etc/sysconfig/network
NETWORKING=yes # 設置Linux是否運行網絡,取值爲:yes/no
NETWORKING_IPV6=yes # 設置Linux是否支持IPv6
HOSTNAME=localhost.localdomain # 設置計算機的主機名linux
3、DNS配置文件(重啓生效)
[root@localhost ~]# vi /etc/resolv.conf
nameserver 202.109.14.5 # 主DNS
nameserver 219.141.136.10 # 次DNS
search localdomain # DNS搜索路徑,當解析不完整名稱時默認的附加域名後綴網絡
4、主機名配置文件(至關於Windows下的 C:\Windows\System32\drivers\etc\hosts 文件)
[root@localhost ~]# vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6dom
5、網絡操做相關命令
1.查看網卡接口信息(默認列出全部接口)
[root@localhost ~]# ifconfigui
2.臨時配置eth0網絡接口信息(無需重啓)
[root@localhost ~]# ifconfig eth0 192.168.1.26
[root@localhost ~]# ifconfig eth0 192.168.1.26 netmask 255.255.255.0.net
3.查看當前路由及網關信息
[root@localhost ~]# netstat -r
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
169.254.0.0 * 255.255.0.0 U 0 0 0 eth0
default localhost 0.0.0.0 UG 0 0 0 eth0rest
4.網絡服務相關命令
[root@localhost ~]# service network stop # 關閉網絡服務
[root@localhost ~]# service network start # 啓動網絡服務
[root@localhost ~]# service network restart # 重啓網絡服務
[root@localhost ~]# service network reload # 從新載入 ifcfg-eth0 網絡配置文件
[root@localhost ~]# service network status # 查看網卡狀態查詢
或
[root@localhost ~]# /etc/init.d/network stop
[root@localhost ~]# /etc/init.d/network start
[root@localhost ~]# /etc/init.d/network restart
[root@localhost ~]# /etc/init.d/network reload
[root@localhost ~]# /etc/init.d/network statusserver
5.網卡接口關閉與激活
[root@localhost ~]# ifdown eth0 # 關閉eth0網卡
[root@localhost ~]# ifup eth0 # 激活eth0網卡htm
參考文檔
http://linux.sheup.com/linuxs/list_12_1.htm
http://my.oschina.net/adamboy/blog/35109
http://hi.baidu.com/duangonghua/item/54e84b1fa9e143f686ad4e24
http://www.cnblogs.com/huangfox/archive/2012/03/31/2426268.htmlblog