Ubuntu 16.04查看IP、網關、DNS等信息
root@ubuntu:~# cat /proc/version #查看發行版本
Linux version 4.9.40-eve-ng-ukms-2+ (root@ubuntu) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) ) #4 SMP Fri Sep 15 02:07:02 CEST 2017
root@ubuntu:~#
查看IP地址:
root@ubuntu:~# ifconfig
root@ubuntu:~# ip add show
查看路由、網關(gateway)
root@ubuntu:~# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 192.168.246.2 0.0.0.0 UG 0 0 0 pnet0
root@ubuntu:~# route -n #-n 表示不解析名字
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.246.2 0.0.0.0 UG 0 0 0 pnet0
10.163.1.0 0.0.0.0 255.255.255.0 U 0 0 0 pnet1
Flags,如果是U代表活動的路由,出現G代表這個網絡接口連接的是網關,H代表是一個主機
root@ubuntu:~# netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.246.2 0.0.0.0 UG 0 0 0 pnet0
10.163.1.0 0.0.0.0 255.255.255.0 U 0 0 0 pnet1
查看DNS
root@ubuntu:~# cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND — YOUR CHANGES WILL BE OVERWRITTEN
nameserver 192.168.246.2
root@ubuntu:~#
查看網絡服務狀態
root@ubuntu:~# systemctl status networking
重啟網絡服務
root@ubuntu:~# systemctl restart networking
或
root@ubuntu:~# service networking restart
ping命令
root@ubuntu:~# ping -c 3 192.168.246.2 #向網關ping 3個包
PING 192.168.246.2 (192.168.246.2) 56(84) bytes of data.
64 bytes from 192.168.246.2: icmp_seq=1 ttl=128 time=0.251 ms
64 bytes from 192.168.246.2: icmp_seq=2 ttl=128 time=0.300 ms
64 bytes from 192.168.246.2: icmp_seq=3 ttl=128 time=0.280 ms
— 192.168.246.2 ping statistics —
3 packets transmitted, 3 received, 0% packet loss, time 2039ms
rtt min/avg/max/mdev = 0.251/0.277/0.300/0.020 ms
查看網絡接口配置文件
root@ubuntu:~# cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
iface eth0 inet manual
auto pnet0
iface pnet0 inet static
address 192.168.246.177
netmask 255.255.255.0
gateway 192.168.246.2
dns-nameservers 192.168.246.2
bridge_ports eth0
bridge_stp off
關閉接口
root@ubuntu:~# ifdown pnet3
啟用接口
root@ubuntu:~# ifup pnet3
root@ubuntu:~# ifdown eth0 #想關閉eth0來着,但是系統提示沒有配置,估計是eth0沒有配置IP地址的原因
ifdown: interface eth0 not configured
root@ubuntu:~#
查看路由跟蹤信息
root@ubuntu:~# traceroute www.toutiao.com
traceroute to www.toutiao.com (36.156.179.242), 30 hops max, 60 byte packets
1 192.168.246.2 (192.168.246.2) 0.125 ms 0.059 ms 0.084 ms
2 * * *
原創文章,作者:投稿專員,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/230051.html
微信掃一掃
支付寶掃一掃