linux怎么判断eth0
Ⅰ linux下如何区分eth0,eth1,eth2,eth3
ethtool -p eth0
回车后与eth0 相对应的网卡接口旁边的指示灯就会闪烁,这样你就能很快确定eth0 网口的位置(按下Ctrl+C 结束命令,停止闪烁)
同样确定eth1、eth2.。。。
Ⅱ linux下输入ifconfig命令,没有eth0,怎么解决
重新打开eth0就行了
第一步:打开terminal,输入cd /etc/sysconfig/network-scripts 进入目录,输入ifconfig -a命令,可以看到eth0和lo。
Ⅲ linux 查看当前的网络配置
linux 查看当前的网络配置
1、执行 ifconfig命令,结果如下可以查看到ip、mac地址等相关网络配置
配置说明
DEVICE=eth0网卡设备名,eth0表示第一张网卡
BOOTPROTO=none是否自动获取IP(none、static、dhcp),当值为dhcp时,只需配置上述例子中的那几项就可以联网
HWADDR=00:0C:29:11:30:39MAC地址
NM_CONTROLLED=yes是否可以由Network Manager图形管理工具托管
ONBOOT=yes是否随网络服务启动当前网卡生效(在CentOS 6 以上的版本中ONBOOT是默认关闭的。)
TYPE=Ethernet网络类型,这里为以太网
UUID=5ab36190-a5df-4bf1-94d8-6c126afd05f1唯一识别码
IPADDR=192.168.0.200IP地址
NETMASK=255.255.255.0子网掩码
GATEWAY=192.168.0.1网关
DNS1=202.106.0.20DNS
IPV6INIT=noIPv6是否启用,这里设置为不启用
USERCTL=no是否允许非root用户控制此网卡,这里为不允许
Ⅳ linux系统eth0网卡设置
1、首先,用 ifconfig 命令查询是否存在eth0网卡
2、vi /etc/sysconfig/network-scripts/ifcfg-eth0 编辑ifcfg-eth0文件,如图:
加上以下配置:
然后,wq 保存编辑。
3、service network restart 重启网卡
4、再用ifconfig命令查询,如图:
Ⅳ linux下怎么判断网卡异常网卡状态
ip link 命令 或者 通过mii-tool指令
[root@localhost
root]# mii-tool
eth0:
negotiated 100baseTx-FD, link ok
eth1:
no link
或
[root@localhost
root]# mii-tool -v
eth0:
negotiated 100baseTx-FD, link ok
proct
info: vendor 00:50:43, model 2 rev 3
basic
mode: autonegotiation
enabled
basic
status: autonegotiation complete, link ok
capabilities:
100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
advertising:
100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
link
partner: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
eth1:
no link
proct
info: vendor 00:50:43, model 2 rev 3
basic
mode: autonegotiation
enabled
basic
status: no link
capabilities:
100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
advertising:
100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
或
[root@localhost
root]# mii-tool -w
21:20:33
eth0: negotiated 100baseTx-FD, link ok
21:20:33
eth1: no link
//mii-tool主要是用于配置网卡工作模式的指令,同时也可以进行查询、监控等工作!
2)
[root@localhost /]# /etc/init.d/network status
Configured devices:
lo eth0 eth1
Currently active devices:
lo eth0
等同于
[root@localhost root]# service --status-all
............
............
Configured devices:
lo eth0 eth1
Currently active devices:
lo eth0
............
............
3)ifconfig -a
[root@localhost /]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:09:6B:09:08:FC
inet addr:192.168.10.1 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::209:6bff:fe09:8fc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:106732953 errors:0 dropped:0 overruns:0 frame:0
TX packets:104379788 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:2351331877 (2.1 GiB) TX bytes:391707945 (373.5 MiB)
Base address:0x2500 Memory:fbfe0000-fc000000
eth1 Link encap:Ethernet HWaddr 00:09:6B:09:08:FD
BROADCAST MULTICAST MTU:1500 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:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Base address:0x2540 Memory:fbfc0000-fbfe0000
4)ethtool
ethtool eth0
Settings for eth0:
Supported ports: [ MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: g
Wake-on: d
Current message level: 0x000000ff (255)
Link detected: yes
ethtool eth1
Settings for eth1:
Supported ports: [ MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Advertised auto-negotiation: Yes
Speed: Unknown! (0)
Duplex: Half
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: g
Wake-on: d
Current message level: 0x000000ff (255)
Link detected: no
从上面可以看出eth0 处于连接状态,eth1没有连接
二. 查看网卡的配置
一般在linux下查看网络配置可以使用ifconfig命令,可以显示当前网卡的基本配置信息。
终端输入ifconfig 会出现一下内容:
eth0
Link encap:Ethernet HWaddr 00:0C:29:0C:4B:0F
inet addr:192.168.37.128 Bcast:192.168.37.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:33 errors:0 dropped:0 overruns:0 frame:0
TX packets:17 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:2823 (2.7 Kb)
TX bytes:2722 (2.6 Kb)
Interrupt:10 Base address:0x1080
他们分别表示:
Eth0:网络接口
link encap:网络类型
HWaddr:网卡物理地址
Inet addr :IP地址
Bcast:广播地址
Mask:子网掩码
UP:正在使用的网络接口
RX packets,TX packets接收和传输的数据包个数
RX byte,TX byte表示接搜和传输的具体数目
Interrupt:终端信息
Base address:内存地址
三. 网卡配置文件
如果希望每次启动linux时,都能为你的网卡配置正确的网络地址,可以采用下列两种方法:
1. 每次开机后,使用ifconfig手动重新设置网卡的配置;
2. 在开机流程中,将网络配置的设置保存在某些RC Script中。
第一种方式麻烦,第二种方式涉及到在哪个RC Script中配置网卡是比较适当的?
Linux启动过程中会执行以下三个RC Script。
1. /etc/rc.d/init.d/rc.sysinit;
2. /etc/rc.d/init.d/rc;
3. /etc/rc.d/init.d/rc.local
为了维护Linux的稳定性,建议不要修改前两项。但是,用ifconfig配置第三个RC Script的话,导致严重的问题:由于最后执行这个程序,在其执行之前,可能已经执行了数十项网络服务。因此,会造成一堆网络服务因为网卡尚未启动而无法顺利的启动。
四、网卡配置文件
解决上述问题的方法:每一个网络介质都对应一个配置文件,超级用户可以通过这些配置文件来配置网卡。
网卡配置文件存放在 /etc/sysconfig/network-scripts/目录中;
/etc/sysconfig/network-scripts/ifcfg-interface-name
设置文件ifcfg-interface-name包含了初始化接口所需的大部分周详信息。其中interface-name将根据网卡的类型和排序而不
同,一般其名字为eth0、eth1、ppp0等,其中eth表示以太(eth0)类型网卡,0表示第一块网卡,1表示第二块网卡,而ppp0则表示第一 个point-to-poirt protocol网络接口。在ifcfg文件中定义的各项目取决于接口类型。
下面的值较问常见:
》DEVICE=name ,其中,name是物理设备名。
》IPADDR=addr,其中,addr是IP地址。
》NETMASK=mask,其中,mask是网络掩码值。
》NETWORK=addr,其中addr是网络地址。
》BROADCAST=addr,其中,addr是广播地址。
》GATEWAY=addr,其中addr是网关地址。
》ONBOOT=answer,其中,answer是yes(引导时激活设备)或no(引导时不激活设备)
》USERCTL=answer,其中,answer是yes(非root用户能控制该设备)或no
》BOOTPROTO=proto,其中,proto取下列值之一:none,引导时不使用协议;static静态分配地址;bootp,使用BOOTP协议,或dhcp,使用DHCP协议。
(2)根据上述各参数的意义,设定linpcl.lintec.e.cn机器的设置文件如下:
[root@linpcl root]#cat /etc/sysconfig/networking/devices/ifcfg-rth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.2
NETMASK=255.255.255.0
GATEWAY=192.168.0.1