linux網路設定命令

2021-07-04 01:11:22 字數 2286 閱讀 9773

ifconfig命令可已檢視和設定網路介面的屬性

route命令可檢視和維護系統路由表資訊,可檢視和設定預設閘道器的位址

ping命令用於測試當前主機與目標主機之間的網路連線

traceroute命令用於測試當前主機與目標主機間的所有網路節點的連線狀態

hostname命令用於顯示和設定主機名稱

nslookup命令用於查詢網域名稱解析

ifconfig命令用於檢視網路介面資訊

檢視所有活動網路介面的資訊

$ /sbin/ifconfig

檢視所有網路介面(包括非活動網路介面)的資訊

$ /sbin/ifconfig -a

檢視指定網路介面資訊

$ /sbin/ifconfig eth0

route命令可檢視主機的路由資訊

$ /sbin/route

kernel ip routing table

destination    gateway        genmask      flags  metric  ref   use   iface

192.168.152.0    *         255.255.255.0     u       0     0     0     eth0

169.254.0.0      *         255.255.0.0       u       0     0     0     eth0

default      192.168.152.2    0.0.0.0        ug      0     0     0     eth0

traceroute命令測試當前主機到目的主機之間經過的所有網路節點

$ traceroute 192.168.1.1 

traceroute to 192.168.1.1 (192.168.1.1), 30 hops max, 38 byte packets

1  192.168.152.2 (192.168.152.2)  2.293 ms  1.300 ms  0.994 ms

2  192.168.1.1 (192.168.1.1)  4.821 ms  3.518 ms  5.539 ms

hostname命令可顯示當前主機的名稱

$ hostname

localhost.localdomain 

nslookup命令可進行網域名稱的查詢 

使用nslookup命令的互動模式進行網域名稱查詢

$ nslookup

> www.sina.com.cn

使用nslookup直接查詢網域名稱

$ nslookup www.sina.com.cn 

server:         192.168.152.2

address:        192.168.152.2#53

non-authoritative answer:

www.sina.com.cn canonical name = jupiter.sina.com.cn.

jupiter.sina.com.cn     canonical name = libra.sina.com.cn.

name:   libra.sina.com.cn

address: 202.108.33.32

ifconfig命令可以設定網路介面的ip位址

# ifconfig eth0 192.168.152.133 \

> netmask 255.255.255.0

route命令可以維護系統路由表資訊

刪除預設閘道器

# route del default gw 192.168.152.2

新增預設閘道器

# route add default gw 192.168.152.2

hostname命令可以對當前主機的名稱進行設定

hostname命令設定的主機名稱是即時生效的

系統重新啟動後將會恢復為系統原有的主機名稱

# hostname yaohuaserver 

使用nslookup命令的互動模式可以顯示和設定當前命令使用的dns伺服器

顯示使用的dns伺服器位址

# nslookup

> server

default server: 192.168.152.2

address: 192.168.152.2#53

設定nslookup命令使用的dns伺服器位址

> server 202.106.0.20

default server: 202.106.0.20

address: 202.106.0.20#53

Linux 網路設定命令(二)

ip address add ip address delete ip address show ip address flush dev name scope scope val global 全域性有效 host 主機內部 to prefix 列出和prefix匹配的位址 label patte...

Linux 常用網路設定命令

root localhost ifconfig ens33 ens33 flags 4163mtu 1500 inet 192.168.50.133 netmask 255.255.255.0 broadcast 192.168.50.255 inet6 fe80 bb4e 7fd1 be18 39...

linux網路設定

size large linux ip 設定 修改ip位址 即時生效 ifconfig eth0 192.168.1.102 netmask 255.255.255.0 啟動生效 修改 etc sysconfig network scripts ifcfg eth0 加入ipaddr 192.168...