linux 網路配置與管理

2022-08-27 19:15:16 字數 3018 閱讀 4082

物理層:底層資料傳輸硬體

<-->mac (arp/rarp)

傳輸層:從源主機程序到目標主機特定程序之間通訊,tcp/udp。

tcp:有連線協議,建立邏輯連線

·    syn, ack, fin, rst, psh, urg

三次握手:

syn=1, ack=0, fin=0

syn=1, ack=1, fin=0

syn=0, ack=1, fin=0

四次斷開:

應用層:包括 (會話層、表示層、應用層)

ps:網路傳輸協議1-4層:通訊,5-7層:資源

本地解析: /etc/hosts

dig -t a fqdn

dig -x ip:反解ip至fqdn

route-ifname: 

配置檔案的格式1:每行乙個路由條目

destination via netx_hop

配置檔案格式2: 每三行乙個路由條目

address#=destination

netmask#=mask

gateway#=gw

路由配置命令:

route:顯示路由資訊

-n: 數字格式的位址

route add

-host:目標為主機

-host host_ip gw next_hop [dev device]

-net:目標是網路

-net net_address gw next_hop [dev device]

-net 0.0.0.0: 表示目標為任意位址

route add default gw gw_add

route del

-host host_ip

-net net_address

命令配置:hostname hostname

配置檔案:/etc/sysconfig/network

hostname=主機名

配置檔案有兩類(/etc/sysconfig/network-scripts)

配置ip、掩碼和閘道器:

乙太網:ifcfg-ifname

ppp: ifcfg-pppx

ifcfg-ifname配置檔案的格式:

device=ifname: 此配置檔案所關聯到的裝置,裝置名稱要與本檔名ifcfg-後面保持一致;

bootproto=

hwaddr=00:11:22:33:44:55:66 :當前裝置的mac位址;

nm_controlled=: 是否接受networkmanager服務指令碼來配置此裝置;

onboot=: 是否在開機過程中,自動啟用此介面

type=: 網路介面型別

uuid=

ipaddr=

netmask=

gateway=

dns1=

dns2=

ipv6init=

userctl=: 是否允許普通用控制此介面

peerdns=: 不接受dhcp伺服器指派的dns伺服器位址

通過網路介面的別名來實現:ifname:#

ens33, ens33:0, ens33:1, ens33:2 eth0,eth0:0, eth0:1

命令配置:立即生效

ifconfig ifalias ip

配置檔案配置:別名不支援使用dhcp進行配置

ifcfg-ifalias

device=ifalias

bootproto=

ipaddr=

netmask=

onboot=

userctl=

ping [option]... ip

-c #: 報文的個數

-w timeout: 等待響應報文的超時時長;

traceroute host

netstat: (ss)

-t: tcp協議相關

-u: udp協議相關

-n: 顯示數字格式的位址

-l: listen,顯示處於監聽狀態的連線

-tunl

-a: 所有狀態的連線

-tan

-p: 顯示會話中的程序程式名及程序號

-r: routing,顯示路由表

-rn

ip link : 管理介面

show [ifname]

set ifname

multicast

網絡卡關閉與開啟:

ifconfig ifname

ifup ifname

ifdown ifname

ip addr: 管理協議位址

ip addr [dev device]

ip addr address dev device [label ifalias] [broadcast bcast_address]

fconfig ifname address broadcast bcast_address

ip route: 管理路由

ip route list

ip route flush

ip route add destination [via next_hop] [src source_address] [dev device]

ip route del destination

/etc/rc.d/init.d/與/etc/init.d/*

sysv風格的指令碼:多數指令碼都用於控制linux的後台程序,接受引數

/etc/init.d/network start

service network start

配置某服務是否開機自動執行:

chkconfig srvname on|off

檢視哪些服務開機自動執行:

chkconfig --list

linux網路管理 Linux網路配置

1.1 linux配置ip位址 1 ifconfig命令臨時配置ip位址 能不能自動獲取ip位址和dns位址,要看有沒有dhcp伺服器 win10上,輸入ipconfig all 會看到是否有dhcp伺服器 ifconfig命令 對此命令更加詳細的解說 傳送門 2 setup工具永久配置ip位址 r...

Linux 網路 配置管理

吳巨集東 記於2018年07月04日 部落格 從頂至底 應用層 表示層 會話層 傳輸層 網路層 資料鏈路層 物理層 dhcp dynamic host configuration protocol 動態主機配置協議 lan local area network 區域網 wan wide area n...

Linux基礎04 免密登入配置與網路管理

一 ssh免密登陸配置 1.ssh的相關概念 ssh 為 secure shell 安全外殼協議 的縮寫,ssh的具體實現是由客戶端和服務端的軟體組成的。2.認證機制 從客戶端來看,ssh提供兩種級別的安全驗證。第一種方式 基於口令的安全驗證 只要你知道自己帳號和口令,就可以登入到遠端主機。第二種方...