ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 【Linux】Linux网络配置基础1 网络相关命令与网卡配置文件

【Linux】Linux网络配置基础1 网络相关命令与网卡配置文件

原创 Linux操作系统 作者:海星星hktk 时间:2016-01-18 10:41:32 0 删除 编辑
Linux网络配置基础1 
网络相关命令与网卡配置文件


OS:Red Hat Enterprise Linux 6.4

1 ifconfig 查看/设置网卡

ifconfig 查看所有活动网卡信息
ifconfig -a 查看所有网卡信息
ifconfig eth0 查看具体网卡信息
ifconfig eth0 up/down 激活/禁用网卡
ifup/ifdown eth0 激活/禁用网卡(重新读取配置文件)
[root@rhel64 ~]# ifconfig



查看具体网卡信息
[root@rhel64 ~]# ifconfig eth0




临时设置eth0网卡子接口ip,子网卡ip须使用静态配置。
[root@rhel64 ~]# ifconfig eth0:0 192.168.7.101
[root@rhel64 ~]# ifconfig


[root@rhel64 ~]# ifconfig eth0:0 down
[root@rhel64 ~]# ifconfig



2 ip、ethtool 查看网卡配置、属性

[root@rhel64 ~]# ip


查看网络接口配置情况
[root@rhel64 ~]# ip addr
[root@rhel64 ~]# ip addr show eth0


查看网络接口属性信息
[root@rhel64 ~]# ethtool eth0



3 ping 测试网络通信
[root@rhel64 ~]# ping 192.168.6.6 -c 4


4 route -n 查看路由信息
[root@rhel64 ~]# route -n
[root@rhel64 ~]# ip route

如果需手动指定具体路由,可编辑修改配置文件
/etc/sysconfig/network-scripts/route-eth0


5 traceroute 查看主机间路由

测试从当前主机到目标主机间经过的网络节点
[root@rhel64 ~]# traceroute 192.168.6.6

windows中对应命令tracert



6 hostname 查看主机名
[root@rhel64 ~]# hostname

hostname命令也可以用来临时设置主机名,当前有效,重启后恢复配置文件中值

7 netstat 查看网络连接状态
[root@rhel64 ~]# netstat --help


[root@rhel64 ~]# netstat -lntup


[root@rhel64 ~]# netstat -antup


8 /etc/sysconfig/network
全局配置文件
[root@rhel64 ~]# cat /etc/sysconfig/network

NETWORKING 全局网络开关
HOSTNAME 主机名
GATEWAY  全局网关配置,多个网卡时可在具体网卡配置文件指定


9 具体网卡配置文件

[root@rhel64 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE 网卡名称  要与配置文件名中一致
TYPE=Ethernet    以太网
ONBOOT=yes     重启操作系统后激活网卡
BOOTPROTO     none 或者static是静态设置ip;dhcp是自动获取
IPADDR          ip地址
GATEWAY        网关 默认路由
PREFIX          子网掩码,或使用NETMASK=255.255.255.0


10 本地主机名解析 /etc/hosts
保存主机名与IP地址的映射记录
[root@rhel64 ~]# cat /etc/hosts


[root@rhel64 ~]# vi /etc/hosts


[root@rhel64 ~]# ping rhel64 -c2


win7中也有对应文件



11 网络配置总结










吕星昊
2016.1.18

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29475508/viewspace-1978184/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
Oracle OCM 讲师。达梦认证讲师DM8-DCI。OceanBase认证讲师OBCI。拥有10g、12c OCM,OBCP等认证证书。曾任 Oracle WDP 注册OCM讲师,已培养Oracle OCP认证专家2000余人,培养Oracle OCM认证大师360余人。

注册时间:2014-02-08

  • 博文量
    128
  • 访问量
    2646282