ifconfig : 设置网络参数的指令
ifup,ifdown : 启动与关闭某个网络适配卡
1 [work@al-bj-test-rc ~]$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.16.112.83 netmask 255.255.255.0 broadcast 172.16.112.255
ether 00:16:3e:0a:2c:00 txqueuelen 1000 (Ethernet)
RX packets 3880780587 bytes 923269929563 (859.8 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3187119360 bytes 798447548406 (743.6 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1 (Local Loopback)
RX packets 163690720 bytes 27313533983 (25.4 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 163690720 bytes 27313533983 (25.4 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
结果说明:
eth0 :为网卡的代号;
lo : 为内部循环 IP的网卡代号,请注意,这个内部的 interface 一定要存在!千万不要关掉他!
ether :是网卡的硬件地址,就是我们在网络基础提到的 MAC
inet :就是网卡的 IP;
broadcast :是广播( broadcast ) 的地址
Mask :就是子网掩码啦;
MTU :是 Maximum Trasmission Unit 最大传输单元(字节), 即此接口一次所能传输的最大封包, 这个数值并非越大越好,也非越小越好,不过,设置错误时,可能会让您的网络无法连接上某些网站呢!
RX :网络由启动到目前为止的接收情形;
TX :网络由启动到目前为止的传送情形;
collisions : 网络讯号碰撞的情况说明;
txqueuelen :是传输缓冲区长度大小意思;
Interrupt : 是 IRQ 中断地址;
Base address :是 I/O 地址。这个 IRQ 与 I/O 在网卡上面是可以设置的!设置的地方可以在 /etc/lilo.conf 里头来设置呢!如果您的主机上面有多张网卡的时候,就用的着他了!可以避开问题!
2 [work@al-bj-test-rc ~]$ ifconfig eth0 :查看eth0网卡参数
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.16.112.88 netmask 255.255.255.0 broadcast 172.16.112.255
ether 00:16:3e:30:69:b6 txqueuelen 1000 (Ethernet)
RX packets 41149414 bytes 4573231380 (4.2 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 18574475 bytes 3352941282 (3.1 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
3 [root@local root]# ifconfig interface [options]
参数说明:
interface : 网络适配卡代号,例如 eth0, eth1...
options : 主要有以下几个参数
network :网址
broadcast :广播网段
netmask :子网掩码
up|down :启动|关闭网络接口
ifconfig eth0 192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255
ifconfig eth0 network 192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255
将 eth0 这个网络接口的 IP 属性修改为 192.168.0.2 ,netmask 255.255.255.0为 广播地址192.168.0.255
4
[root@local root]# ifconfig eth0 down <==关闭 eth0 网卡
[root@local root]# ifconfig eth0 up <==启动 eth0 网卡!
5 ifup, ifdown 启动与关闭某个网络适配卡
语法:
[root@local root]# ifup [interface]
[root@local root]# ifdown [interface]
参数说明:
例:
[root@local root]# ifup eth0 <==启动 eth0 这块网卡
[root@local root]# ifdown eth0 <==关闭 eth0 这块网卡
说明:
手动修改网络参数使用 ifconfig ,但是档案设置的启动与关闭就得使用 ifup 与 ifdown 啰。这两个指令要比 ifconfig 简单的多!不过他却必须要有相关的档案存在才能启动!举个例子来说,上面我们要启动 eth0 这块网卡的时候,那么您的 Linux 系统当中就必须要存在 /etc/sysconfig/network-scripts/ifcfg-eth0 这个网络适配卡的设置档案才行!同理,如果要启动 eth1 ,除了存在 eth1 这个实体网络卡之外,还要存在 ifcfg-eth1 才行