linux系統的網路的配置和管理

2021-08-04 14:09:15 字數 2866 閱讀 8883

一.網路位址基礎知識

1.ipv4

2進製32位寫成10進製是四位

172.25.0.10/255.255.255.0

255.255.255.0:子網掩碼

子網掩碼255位對應的ip位為網路位

子網掩碼0位置對應的ip位為主機位

二.配置ip

1.圖形介面

nm-connection-editor

2.文字化圖形

nmtui

—命令-

ifconfig 網絡卡 ip netmask    ****臨時設定

nmcli connection add type ethernet con-name westos ifname eth0 autoconnect yes

nmcli connection add type ethernet con-name westos ifname eth0 ip4 ip/24

nmcli connection delete westos 刪除以配置好的位址

nmcli connection show

nmcli connection down westos

nmcli connection up westos

nmcli connection modify "westos" ipv4.addresses newip/24

nmcli connection modify "westos" ipv4.method

nmcli device connect eth0

nmcli device disconnect eth0

nmcli device show

nmcli device status

——檔案--

dhcp                                 **動態獲取

vim /etc/sysconfig/network-scripts/ifcfg-eth0

device=eth0                 **介面使用裝置

bootproto=dhcp      **網絡卡工作模式

onboot=yes                 **網路服務開啟時自動啟用

name=eth0                     **網路介面名稱

:wqsystemctl restart network

static|none                               **靜態網路

vim /etc/sysconfig/network-scripts/ifcfg-eth0

device=eth0                          **裝置

bootproto=static|none    **裝置工作方式

onboot=yes                          **開啟網路服務啟用裝置

name=eth0                              **網路介面名稱

ipaddr=172.25.0.100           **ip

netmask=255.255.255.0 | prefix=24 **子網掩碼

三.gateway(閘道器)

1.路由器

主要功能是用來作nat的

dnat    目的地位址轉換

snat    源位址轉換

2.閘道器

路由器上和自己處在同乙個網段的那個ip

3.設定閘道器

systemctl stop     netwrokmanager

vim /etc/sysconfig/network                               ***全域性閘道器

gateway=閘道器ip

vim /etc/sysconfig/network-scripts/ifcfg-網絡卡配置檔案      ****網絡卡介面閘道器

gateway=閘道器ip

網絡卡藉口裡沒有閘道器的看全域性閘道器,有的話就用網絡卡藉口閘道器

systemctl restart netwrok

route -n                                     **查詢閘道器

kernel ip routing table

destination     gateway         genmask         flags metric ref    use iface

0.0.0.0   (閘道器)172.25.0.254    0.0.0.0         ug    0      0        0 eth0

172.25.0.0      0.0.0.0         255.255.255.0   u     0      0        0 eth0

四.dns

1.dns

dns是一台伺服器

這太伺服器提供了回答客戶主機名和ip對應關係的功能

2.設定dns

vim /etc/resolv.conf

nameserver dns伺服器ip

vim /etc/sysconfig/network-scripts/ifcfg-網絡卡配置檔案

dns1=dns伺服器ip

3.本地解析檔案

vim /etc/hosts

ip    主機名稱

4.本地解析檔案和dns讀取的優先順序調整

/etc/nsswitch.conf

38 #hosts:     db files nisplus nis dns

39 hosts:      files dns       files代表本地解析檔案,dns代表dns伺服器,那個在前面那個優先

5.dhcp服務的配置

yum install dhcp -y

linux系統的網路配置

1 ubuntu 的網路配置,設定靜態ip vi etc network inte ces 1 靜態ip位址 auto lo iface lo inet dhcp auto eth0 iface eth0 inet static 靜態ip address 192.168.0.5 ip位址 netma...

Linux 系統 網路配置

linux 系統 網路配置 配置linux系統網路的方法有幾種,這裡介紹本人常用的兩種。第一種 使用命令ifconfig配置,具體用法 ipconfig ethx x.x.x.x netmask x.x.x.x 效果如下圖 通常,此種配置法只是用來測試用,因為重啟機器後,該配置的內容將會失效。第二種...

linux系統網路配置

1 設定虛擬機器為橋接模式 虛擬機器 設定 硬體 網路介面卡 橋接模式 ifconfig 啟動網路服務 sudo ifconfig eth0 up 關閉網路服務 sudo ifconfig eth0 down ifconfig eth0 192.168.3.注意防止ip衝突 測試網路是否聯通 pin...