日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux 命令修改网络,linux网络命令学习

發布時間:2023/12/1 linux 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux 命令修改网络,linux网络命令学习 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

用命令修改的均為臨時生效,重啟后失效,要想永久生效需更改配置文件

設置主機名

vi etc/sysconfig/network

查看主機名

hostname

設置IP地址

ifconfig 網卡名 IP地址 netmask 子網掩碼

ifconfig etho 10.0.0.1 netmask 255.0.0.0

查看某快網卡的狀況

ifconfig 網卡名

ifconfig eth0

多IP設置

ifconfig 網卡名:虛擬網卡ID IP地址 netmask 子網掩碼

ifconfig eth0:0 10.1.1.1 netmask 255.0.0.0

禁用和啟用網卡

ifconfig 網卡名稱 down 或 ifdown eth0

ifconfig 網卡名稱 up?? 或 ifup?? eth0

臨時修改MAC,重啟后失效

ifdowm eth0

ifconfig eht0 hw ether 00:37:a6:c4:68:e3

ifup eth0

添加/刪除默認網關

route add/del default gw IP地址

查看網管及路由

route

[root@localhost sysconfig]# route

Kernel IP routing table

Destination???? Gateway???????? Genmask???????? Flags Metric Ref??? Use Iface

192.168.16.0??? *?????????????? 255.255.255.0?? U???? 1????? 0??????? 0 eth0

default???????? 192.168.16.1??? 0.0.0.0???????? UG??? 0????? 0??????? 0 eth0

U表示該條路由條目為活躍的,G表示該條路由條目要涉及到網關

網卡配置文件

cd /etc/sysconfig/network-scripts/

ls ifcfg-*

vi ifcfg-eth0

設置DNS

etc/resolv.conf

ping

-c ping的次數

-s 數據包的大小

icmp_seq 數據包的序號從1開始

ttl 生存周期

time 響應時間

netstat -ant

[root@localhost etc]# netstat -ant

Active Internet connections (servers and established)

Proto Recv-Q Send-Q Local Address?????????????? Foreign Address???????????? State

tcp??????? 0????? 0 0.0.0.0:40102?????????????? 0.0.0.0:*?????????????????? LISTEN

tcp??????? 0????? 0 0.0.0.0:111???????????????? 0.0.0.0:*?????????????????? LISTEN

tcp??????? 0????? 0 0.0.0.0:22????????????????? 0.0.0.0:*?????????????????? LISTEN

tcp??????? 0????? 0 127.0.0.1:631?????????????? 0.0.0.0:*?????????????????? LISTEN

tcp??????? 0????? 0 127.0.0.1:25??????????????? 0.0.0.0:*?????????????????? LISTEN

tcp??????? 0????? 0 192.168.16.36:53755???????? 63.146.70.75:80???????????? ESTABLISHED

tcp??????? 0????? 0 :::43139??????????????????? :::*??????????????????????? LISTEN

tcp??????? 0????? 0 :::111????????????????????? :::*??????????????????????? LISTEN

tcp??????? 0????? 0 :::22?????????????????????? :::*??????????????????????? LISTEN

tcp??????? 0????? 0 ::1:631???????????????????? :::*??????????????????????? LISTEN

tcp??????? 0????? 0 ::1:25????????????????????? :::*??????????????????????? LISTEN

-a 顯示所有鏈接 -t顯示TCP協議 -u可顯示UDP協議 默認則都顯示

state鏈接狀態

LISTEN表示監聽狀態,等待接收入站的請求

ESTABLISHED表示本機已經與其他主機建立好鏈接

TIME_WAIT等待足夠的時間以確保遠程TCP接受到鏈接中斷請求的確認

netstat -r 查看當前主機的路由表信息

netstat -i 監控主機網絡接口的統計信息,顯示數據包發送和接收情況

[root@localhost etc]# netstat -i

Kernel Interface table

Iface?????? MTU Met??? RX-OK RX-ERR RX-DRP RX-OVR??? TX-OK TX-ERR TX-DRP TX-OVR Flg

eth0?????? 1500?? 0??? 40966????? 0????? 0????? 0???? 4833????? 0????? 0????? 0 BMRU

lo??????? 16436?? 0?????? 16????? 0????? 0????? 0?????? 16????? 0????? 0????? 0 LRU

MTU表示最大傳輸單元,即網絡接口傳輸數據包的最大值。Met為度量值,越小優先級越高。RX-OK/TX-OK分別表示接收、發送數據包的數量,RX-ERR/TX-ERR分別表示接收、發送錯誤數據包的數量,RX-DRP/TX-DRP為丟棄的數量,RX-OVR/TX-OVR表示丟失數據包數量。

nslookup

非交互模式僅僅可以查詢主機和域名信息。

查詢www.baidu.com對應的DNS信息

[root@localhost etc]# nslookup www.baidu.com

Server:??? ??? 202.102.134.68

Address:??? 202.102.134.68#53

Non-authoritative answer:

Name:??? www.baidu.com

Address: 61.135.169.125

Name:??? www.baidu.com

Address: 61.135.169.105

將IP解析為主機名

[root@localhost etc]# nslookup 219.141.136.10

Server:??? ??? 202.102.134.68

Address:??? 202.102.134.68#53

Non-authoritative answer:

10.136.141.219.in-addr.arpa??? name = xd-cache-1.bjtelecom.net.

Authoritative answers can be found from:

136.141.219.in-addr.arpa??? nameserver = xd-dns.bjtelecom.net.

xd-dns.bjtelecom.net??? internet address = 219.141.148.19

交互模式

[root@localhost etc]# nslookup

> ^C[root@localhost etc]#

[root@localhost etc]# nslookup

> www.redhat.com

Server:??? ??? 202.102.134.68

Address:??? 202.102.134.68#53

Non-authoritative answer:

Name:??? www.redhat.com

Address: 218.58.101.214

> 61.135.169.105

Server:??? ??? 202.102.134.68

Address:??? 202.102.134.68#53

總結

以上是生活随笔為你收集整理的linux 命令修改网络,linux网络命令学习的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。