學(xué)習(xí)啦 > 學(xué)習(xí)電腦 > 操作系統(tǒng) > Linux教程 > linux的ifconfig命令輸出結(jié)果

linux的ifconfig命令輸出結(jié)果

時(shí)間: 佳洲1085 分享

linux的ifconfig命令輸出結(jié)果

  Linux下ifconfig命令是查看網(wǎng)卡的信息,輸出結(jié)果要怎么看呢?下面由學(xué)習(xí)啦小編為大家整理了linux下ipconfig命令輸出結(jié)果,希望對(duì)大家有幫助!

  ipconfig命令輸出結(jié)果分析

  1、linux下ifconfig命令查看網(wǎng)卡的信息結(jié)果分析

  ifconfig [Interface]

  Interface是可選項(xiàng),如果不加此項(xiàng),則顯示系統(tǒng)中所有網(wǎng)卡的信息。如果添加此選項(xiàng)則顯示所指定的網(wǎng)卡信息

  例如:ifconfig eth0

  [plain] view plain copyeth0 Link encap:Ethernet

  HWaddr 00:0C:29:F3:3B:F2

  inet addr:192.168.0.10 Bcast:192.168.0.255 Mask:255.255.255.0

  UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

  RX packets:78 errors:0 dropped:0 overruns:0 frame:0

  TX packets:104 errors:0 dropped:0 overruns:0 carrier:0

  collisions:0 txqueuelen:100

  RX bytes:11679 (11.4 Kb)

  TX bytes:14077 (13.7 Kb)

  Interrupt:10 Base address:0x1080

  我們可以看到

  第一行:連接類型:Ethernet(以太網(wǎng))HWaddr(硬件mac地址)

  第二行:網(wǎng)卡的IP地址、子網(wǎng)、掩碼

  第三行:UP(代表網(wǎng)卡開(kāi)啟狀態(tài))RUNNING(代表網(wǎng)卡的網(wǎng)線被接上)MULTICAST(支持組播)MTU:1500(最大傳輸單元):1500字節(jié)

  第四、五行:接收、發(fā)送數(shù)據(jù)包情況統(tǒng)計(jì)

  第七行:接收、發(fā)送數(shù)據(jù)字節(jié)數(shù)統(tǒng)計(jì)信息。

  2、ifconfig命令配置網(wǎng)卡結(jié)果

  配置網(wǎng)卡的IP地址

  ifconfig eth0 192.168.0.1 netmask 255.255.255.0

  在eth0上配置上192.168.0.1 的IP地址及24位掩碼。若想再在eth0上在配置一個(gè)192.168.1.1/24 的IP地址怎么辦?用下面的命令

  ifconfig eth0:0 192.168.1.1 netmask 255.255.255.0

  這時(shí)再用ifconifg命令查看,就可以看到兩個(gè)網(wǎng)卡的信息了,分別為:eth0和eth0:0。若還想再增加IP,那網(wǎng)卡的命名就接著是:eth0:1、eth0:2...想要幾個(gè)就填幾個(gè)。ok!

  配置網(wǎng)卡的硬件地址

  ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx

  就將網(wǎng)卡的硬件地址更改了,此時(shí)你就可以騙過(guò)局域網(wǎng)內(nèi)的IP地址邦定了。

  將網(wǎng)卡禁用

  ifconfig eth0 down

  將網(wǎng)卡啟用

  ifconfig eth0 up

  ifconfig 命令的功能很強(qiáng)大,還可以設(shè)置網(wǎng)卡的MTU,混雜模式等。就不一一介紹了,用時(shí)間可以自己研究一下。

  注意:用ifconfig命令配置的網(wǎng)卡信息,在網(wǎng)卡重啟后機(jī)器重啟后,配置就不存在。要想將上述的配置信息永遠(yuǎn)的存的電腦里,那就要修改網(wǎng)卡的配置文件了。

  網(wǎng)絡(luò)接口配置文件

  [root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0

  # Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)

  TYPE=Ethernet #網(wǎng)卡類型

  DEVICE=eth0 #網(wǎng)卡接口名稱

  ONBOOT=yes #系統(tǒng)啟動(dòng)時(shí)是否自動(dòng)加載

  BOOTPROTO=static #啟用地址協(xié)議 --static:靜態(tài)協(xié)議 --bootp協(xié)議 --dhcp協(xié)議

  IPADDR=192.168.1.11 #網(wǎng)卡IP地址

  NETMASK=255.255.255.0 #網(wǎng)卡網(wǎng)絡(luò)地址

  GATEWAY=192.168.1.1 #網(wǎng)卡網(wǎng)關(guān)地址

  DNS1=10.203.104.41 #網(wǎng)卡DNS地址

  HWADDR=00:0C:29:13:5D:74 #網(wǎng)卡設(shè)備MAC地址

  BROADCAST=192.168.1.255 #網(wǎng)卡廣播地址

  重新導(dǎo)入ifcfg-eth0網(wǎng)絡(luò)配置文件

  [root@localhost ~]# /etc/init.d/network reload

  Shutting down interface eth0: [ OK ]

  Shutting down loopback interface: [ OK ]

  Bringing up loopback interface: [ OK ]

  Bringing up interface eth0: [ OK ]

  網(wǎng)卡接口關(guān)閉與激活

  [root@localhost ~]# ifdown eth0 #關(guān)閉網(wǎng)絡(luò)

  [root@localhost ~]# ifup eth0 #啟動(dòng)網(wǎng)絡(luò)

  網(wǎng)絡(luò)服務(wù)啟動(dòng)與關(guān)閉

  方法一:

  [root@localhost ~]# service network stop #關(guān)閉網(wǎng)絡(luò)服務(wù)

  [root@localhost ~]# service network start #啟動(dòng)網(wǎng)絡(luò)服務(wù)

  [root@localhost ~]# service network restart #重啟網(wǎng)絡(luò)服務(wù)

  方法二:

  [root@localhost ~]# /etc/init.d/network stop

  [root@localhost ~]# /etc/init.d/network start

  [root@localhost ~]# /etc/init.d/network restart

  網(wǎng)卡狀態(tài)查詢

  [root@localhost ~]# service network status

  Configured devices:

  lo eth0

  Currently active devices:

  lo eth0

  臨時(shí)配置網(wǎng)卡信息,無(wú)需重啟。

  [root@localhost ~]# ifconfig eth0 10.1.1.10 netmask 255.0.0.0

  查看網(wǎng)卡接口信息,默認(rèn)列出所有接口

  [root@localhost ~]# ifconfig

  eth0 Link encap:Ethernet HWaddr 00:0C:29:13:5D:74

  inet addr:192.168.1.11 Bcast:192.168.1.255 Mask:255.255.255.0

  inet6 addr: fe80::20c:29ff:fe13:5d74/64 Scope:Link

  UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

  RX packets:413 errors:0 dropped:0 overruns:0 frame:0

  TX packets:572 errors:0 dropped:0 overruns:0 carrier:0

  collisions:0 txqueuelen:1000

  RX bytes:47701 (46.5 KiB) TX bytes:64842 (63.3 KiB)

  Base address:0x2000 Memory:d8920000-d8940000

  lo Link encap:Local Loopback

  inet addr:127.0.0.1 Mask:255.0.0.0

  inet6 addr: ::1/128 Scope:Host

  UP LOOPBACK RUNNING MTU:16436 Metric:1

  RX packets:407 errors:0 dropped:0 overruns:0 frame:0

  TX packets:407 errors:0 dropped:0 overruns:0 carrier:0

  collisions:0 txqueuelen:0

  RX bytes:70759 (69.1 KiB) TX bytes:70759 (69.1 KiB)

  查看當(dāng)前路由及網(wǎng)關(guān)信息

  [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 192.168.1.1 0.0.0.0 UG 0 0 0 eth0

  DNS:

  主機(jī)名:CentOS

  主DNS:202.106.46.151

  第二DNS:202.106.0.20

  第三DNS:8.8.8.8

3629847