linux 查看网络配置文件和路由信息
【摘要】 ECS信息规格:2vCPUs | 4GiB | kc1.large.2镜像:openEuler 20.03 64bit with ARM | 公共镜像 linux 查看网络配置文件和路由信息 ifconfig 查看正在工作的网卡设备名称IP信息已隐藏获取网卡设备名称:eth0# ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAS...
ECS信息
- 规格:2vCPUs | 4GiB | kc1.large.2
- 镜像:openEuler 20.03 64bit with ARM | 公共镜像
linux 查看网络配置文件和路由信息
ifconfig 查看正在工作的网卡设备名称
IP信息已隐藏
获取网卡设备名称:eth0
# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.XXX netmask 255.255.255.0 broadcast 192.168.0.XXX
inet6 XXXX::XXXX:XXXX:XXXX:XXXX prefixlen 64 scopeid 0x20<link>
ether XX:XX:XX:XX:XX:XX txqueuelen 1000 (Ethernet)
RX packets 4703 bytes 459830 (449.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3504 bytes 457059 (446.3 KiB)
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
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
查看eth0网卡的配置文件
- ifcfg-eth0文件可以实现永久配置静态IP等功能
# cd /etc/sysconfig/network-scripts/
# ll
total 20K
-rw-------. 1 root root 86 May 18 2020 ifcfg-eth0
-rw-------. 1 root root 86 May 18 2020 ifcfg-eth1
-rw-------. 1 root root 86 May 18 2020 ifcfg-eth2
-rw-------. 1 root root 86 May 18 2020 ifcfg-eth3
-rw-------. 1 root root 86 May 18 2020 ifcfg-eth4
# cat ifcfg-eth0
DEVICE="eth0"
BOOTPROTO="dhcp"
ONBOOT="yes"
TYPE="Ethernet"
PERSISTENT_DHCLIENT="yes"
route 查看路由信息
# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default _gateway 0.0.0.0 UG 100 0 0 eth0
169.254.169.254 192.168.0.254 255.255.255.255 UGH 100 0 0 eth0
192.168.0.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.0.1 0.0.0.0 UG 100 0 0 eth0
169.254.169.254 192.168.0.254 255.255.255.255 UGH 100 0 0 eth0
192.168.0.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
- ping 3次路由,看看网络状况
# ping -c 3 192.168.0.1
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=64 time=0.175 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=64 time=0.193 ms
64 bytes from 192.168.0.1: icmp_seq=3 ttl=64 time=0.176 ms
--- 192.168.0.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2053ms
rtt min/avg/max/mdev = 0.175/0.181/0.193/0.008 ms
学习资料
欢迎各位同学一起来交流学习心得^_^
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)