linux下网络基本配置

 
本文摘自: http://blog.csdn.net/sky7034/article/details/6624769
常用参数

格式:ifconfig

显示当前激活的网络接口信息。
If no arguments are given, ifconfig displays the status of the currently active interfaces. 

 

格式:ifconfig {INTERFACE}

显示指定网络接口的信息。比如:eth0, eth1。

If a single interface  argument  is given, it displays the status of the given interface only;

 

格式:ifconfig -a

显示所有网络接口的信息,无论是否激活。

if a single -a argument is given, it displays the status of all interfaces, even those that are down. 

Display info on all network interfaces on server, active or inactive.

 

其他格式,用来配置网络接口。

Otherwise, it configures an interface.

 

格式:ifconfig {INTERFACE} up

格式:ifup {INTERFACE}

激活指定网络接口。比如:eth0, eth1。

This  flag  causes the interface to be activated.  It is implicitly specified if an address is assigned to the interface.

 

格式:ifconfig {INTERFACE} down

格式:ifdown {INTERFACE}

关闭指定网络接口。

This flag causes the driver for this interface to be shut  down.

格式:ifconfig {INTERFACE} {IP}

格式:ifconfig {INTERFACE} {IP} netmask {NETMASK}

为指定网络接口设置IP地址和掩码,并自动激活。比如:eth0, eth0:0, eth0:1,后两个为虚拟网卡。

 

格式:ifconfig {INTERFACE} add {IP}

格式:ifconfig {INTERFACE}:0 {IP}

为指定网络接口添加IP地址。

 

格式:ifconfig {INTERFACE} del {IP}

为指定网络接口删除IP地址。

 

使用示例

示例一 通过ifconfig命令查看当前网络接口及状态

ifconfig不带参数,只打印处于激活状态的网络接口。

[root@jfht ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:1B:78:40:8C:20 
          inet addr:211.103.28.xx  Bcast:211.103.28.31  Mask:255.255.255.224
          inet6 addr: fe80::21b:78ff:fe40:8c20/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:134856806 errors:0 dropped:0 overruns:0 frame:0
          TX packets:140723373 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1680519599 (1.5 GiB)  TX bytes:2804853589 (2.6 GiB)
          Interrupt:114 Memory:fa000000-fa012800

 

现在解释一下输出信息的含义:

eth0:网络接口
link encap:网络类型
HWaddr:网卡物理地址
Inet addr :IP地址
Bcast:广播地址
Mask:子网掩码
UP:正在使用的网络接口
RX packets,TX packets接收和传输的数据包个数
RX byte,TX byte表示接搜和传输的具体数目
Interrupt:终端信息
Base address:内存地址


eth1      Link encap:Ethernet  HWaddr 00:1B:78:40:8C:22 
          inet addr:192.168.1.191  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::21b:78ff:fe40:8c22/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:29821173 errors:0 dropped:0 overruns:0 frame:0
          TX packets:28680326 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:4264958692 (3.9 GiB)  TX bytes:427504706 (407.7 MiB)
          Interrupt:122 Memory:f8000000-f8012800

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:30263265 errors:0 dropped:0 overruns:0 frame:0
          TX packets:30263265 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:63016162 (60.0 MiB)  TX bytes:63016162 (60.0 MiB)

 

ifconfig命令跟上-a参数,打印所有配置的网络接口,不论其是否激活。
[root@jfht ~]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:1B:78:40:8C:20 
          inet addr:211.103.28.xx  Bcast:211.103.28.31  Mask:255.255.255.224
          inet6 addr: fe80::21b:78ff:fe40:8c20/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:134856877 errors:0 dropped:0 overruns:0 frame:0
          TX packets:140723396 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1680524793 (1.5 GiB)  TX bytes:2804859207 (2.6 GiB)
          Interrupt:114 Memory:fa000000-fa012800

eth1      Link encap:Ethernet  HWaddr 00:1B:78:40:8C:22 
          inet addr:192.168.1.191  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::21b:78ff:fe40:8c22/64 Scope:Link货运专家
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:29821183 errors:0 dropped:0 overruns:0 frame:0
          TX packets:28680336 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:4264959332 (3.9 GiB)  TX bytes:427505346 (407.7 MiB)
          Interrupt:122 Memory:f8000000-f8012800

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:30263271 errors:0 dropped:0 overruns:0 frame:0
          TX packets:30263271 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:63016642 (60.0 MiB)  TX bytes:63016642 (60.0 MiB)

sit0      Link encap:IPv6-in-IPv4 
          NOARP  MTU:1480  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0女装品牌排行榜
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

 

ifconfig命令跟上指定网络接口名称,就可以查看具体的网卡信息了。
[root@jfht ~]# ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 00:1B:78:40:8C:22 
          inet addr:192.168.1.191  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::21b:78ff:fe40:8c22/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:29821190 errors:0 dropped:0 overruns:0 frame:0
          TX packets:28680343 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:4264959780 (3.9 GiB)  TX bytes:427505794 (407.7 MiB)
          Interrupt:122 Memory:f8000000-f8012800

[root@jfht ~]#

 


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值