标签:linux命令基础
命令功能:用于配置和显示网卡信息
命令格式:ifconfig [选项]...
常用选项:
-a 与不带选项效果一样,显示所有网卡的配置信息
网卡名 显示此网卡的配置信息
举例:
查看当前主机所有网卡的配置信息
[root@localhost ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:9D:C5:64
inet addr:172.31.3.80 Bcast:172.31.3.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe9d:c564/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:291017 errors:0 dropped:0 overruns:0 frame:0
TX packets:18509 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:74373274 (70.9 MiB) TX bytes:3775587 (3.6 MiB)
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:80821 errors:0 dropped:0 overruns:0 frame:0
TX packets:80821 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:16887591 (16.1 MiB) TX bytes:16887591 (16.1 MiB)
当前只有一块网卡eth0;lo是环回地址,一般做测试用
只查看网卡eth0的配置信息
[root@localhost ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 08:00:27:9D:C5:64
inet addr:172.31.3.80 Bcast:172.31.3.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe9d:c564/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:292915 errors:0 dropped:0 overruns:0 frame:0
TX packets:18540 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:74510007 (71.0 MiB) TX bytes:3780589 (3.6 MiB)
修改网卡eth0的ip地址,然后查看配置信息
[root@localhost ~]# ifconfig eth0 192.168.1.31 netmask 255.255.255.0
[root@localhost ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 08:00:27:9D:C5:64
inet addr:192.168.1.31 Bcast:172.31.3.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe9d:c564/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:292915 errors:0 dropped:0 overruns:0 frame:0
TX packets:18540 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:74510007 (71.0 MiB) TX bytes:3780589 (3.6 MiB)
禁用网卡eth1,然后重新激活
[root@localhost ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:9D:C5:64
inet addr:172.31.3.80 Bcast:172.31.3.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe9d:c564/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:82155 errors:0 dropped:0 overruns:0 frame:0
TX packets:1329 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6290683 (5.9 MiB) TX bytes:221387 (216.1 KiB)
eth1 Link encap:Ethernet HWaddr 08:00:27:FB:1B:12
inet addr:172.31.3.82 Bcast:172.31.3.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fefb:1b12/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:75195 errors:0 dropped:0 overruns:0 frame:0
TX packets:649 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5634719 (5.3 MiB) TX bytes:217366 (212.2 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:606 errors:0 dropped:0 overruns:0 frame:0
TX packets:606 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:30540 (29.8 KiB) TX bytes:30540 (29.8 KiB)
[root@localhost ~]# ifconfig eth1 down
[root@localhost ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:9D:C5:64
inet addr:172.31.3.80 Bcast:172.31.3.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe9d:c564/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:82363 errors:0 dropped:0 overruns:0 frame:0
TX packets:1371 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6306403 (6.0 MiB) TX bytes:227311 (221.9 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:606 errors:0 dropped:0 overruns:0 frame:0
TX packets:606 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:30540 (29.8 KiB) TX bytes:30540 (29.8 KiB)
[root@localhost ~]# ifconfig eth1 up
[root@localhost ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 08:00:27:9D:C5:64
inet addr:172.31.3.80 Bcast:172.31.3.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe9d:c564/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:82646 errors:0 dropped:0 overruns:0 frame:0
TX packets:1434 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:6327429 (6.0 MiB) TX bytes:235061 (229.5 KiB)
eth1 Link encap:Ethernet HWaddr 08:00:27:FB:1B:12
inet addr:172.31.3.82 Bcast:172.31.3.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fefb:1b12/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:75554 errors:0 dropped:0 overruns:0 frame:0
TX packets:652 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:5659083 (5.3 MiB) TX bytes:217604 (212.5 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:606 errors:0 dropped:0 overruns:0 frame:0
TX packets:606 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:30540 (29.8 KiB) TX bytes:30540 (29.8 KiB)
标签:linux命令基础
原文地址:http://wszzdanm.blog.51cto.com/1841747/1712374