一、通过命令查看,也就是在上一篇文章中介绍的一个命令:ifconfig
示例一:
[root@desktop40 ~]# ifconfig
br0 Link encap:Ethernet HWaddr 00:0C:29:4E:5B:F2
inet addr:192.168.1.131 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe4e:5bf2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3790 errors:0 dropped:0 overruns:0 frame:0
TX packets:386 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:504418 (492.5 KiB) TX bytes:36497 (35.6 KiB)
eth0 Link encap:Ethernet HWaddr 00:0C:29:4E:5B:F2
inet6 addr: fe80::20c:29ff:fe4e:5bf2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4402 errors:0 dropped:0 overruns:0 frame:0
TX packets:479 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:621826 (607.2 KiB) TX bytes:46191 (45.1 KiB)
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:20 errors:0 dropped:0 overruns:0 frame:0
TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1168 (1.1 KiB) TX bytes:1168 (1.1 KiB)
virbr0 Link encap:Ethernet HWaddr 52:54:00:95:B7:E0
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:77 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:8195 (8.0 KiB)
vnet0 Link encap:Ethernet HWaddr FE:54:00:00:00:40
inet6 addr: fe80::fc54:ff:fe00:40/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:75 errors:0 dropped:0 overruns:0 frame:0
TX packets:3737 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:7098 (6.9 KiB) TX bytes:527403 (515.0 KiB)
[root@desktop40 ~]#
通过ifconfig,可以查看到主机的所有的网络信息。同时我们可以在ifconfig命令后加网卡名字,得出相应的信息。
示例二:
[root@desktop40 ~]# ifconfig br0
br0 Link encap:Ethernet HWaddr 00:0C:29:4E:5B:F2
inet addr:192.168.1.131 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe4e:5bf2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3946 errors:0 dropped:0 overruns:0 frame:0
TX packets:402 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:532753 (520.2 KiB) TX bytes:37642 (36.7 KiB)
[root@desktop40 ~]#
二、通过配置文件查看网络信息
想要通过查看参数文件得到网络配置的相关信息,我们就要知道这些参数文件在哪个目录下。那么他们放在哪里呢?我们知道关于配置文件一般都放在/etc目录下,二网络配置又属于系统配置所以可以定位它放置在/etc/sysconfig下,那么是关于网络的,所以文件名中肯定包含network,从而可以知道,配置文件放置在:/etc/sysconfig/network-scripts下。
下面我们看一看这么目录下都有哪些文件:
示例三:
[root@instructor network-scripts]# ls
glsorig-ifcfg-eth0 ifcfg-lo ifdown-ippp ifdown-ppp ifup ifup-ippp ifup-plusb ifup-sit net.hotplug
ifcfg-br0 ifdown ifdown-ipv6 ifdown-routes ifup-aliases ifup-ipv6 ifup-post ifup-tunnel network-functions
ifcfg-br0:0 ifdown-bnep ifdown-isdn ifdown-sit ifup-bnep ifup-isdn ifup-ppp ifup-wireless network-functions-ipv6
ifcfg-eth0 ifdown-eth ifdown-post ifdown-tunnel ifup-eth ifup-plip ifup-routes init.ipv6-global
可以看到在这个目录下有:ifcfg-br0 、ifcfg-eth0 都是关于网络配置的参数文件,一个是关于桥接网卡一个是物理网卡。
我们来看一看这两个示例文件的内容:
示例四:[root@desktop40 network-scripts]# cat ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="dhcp"
HWADDR="00:0C:29:4E:5B:F2"
IPV6INIT="yes"
MTU="1500"
NM_CONTROLLED="yes"
ONBOOT="yes"
TYPE="Ethernet"
UUID="a6c176f0-6f6c-4629-92b5-f13c577d37cd"
DEVICE=eth0
BOOTPROTO=none
BRIDGE=br0
ONBOOT=yes
[root@desktop40 network-scripts]# cat ifcfg-br0
# Bridge Networking Interface
DEVICE=br0
ONBOOT=yes
BOOTPROTO=dhcp
TYPE=Bridge
USERCTL=yes
NM_CONTROLLED=no
IPV6INIT=no
PEERNTP=no
DELAY=0
NAME="Bridge eth0"
[root@desktop40 network-scripts]#
原文:http://blog.csdn.net/siyanyanyanyai/article/details/25507429