检查网络配置信息
一个、通过命令,这是在以前的文章中所描述的命令: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]#
版权声明:本文博客原创文章。博客,未经同意,不得转载。