当前位置:首页 > 经验

ubuntu系统菜鸟入门 ubuntu网络配置

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 * * *

声明:此文信息来源于网络,登载此文只为提供信息参考,并不用于任何商业目的。如有侵权,请及时联系我们:fendou3451@163.com
标签:

  • 关注微信

相关文章