Linux學習 Unit 11

來源:互聯網
上載者:User

標籤:ip地址   linux   基礎知識   網路   網卡   

Unit11.管理網路


1.ip基礎知識

1.ipv4

2進位32位-----10進位

 

172.25.0.10/255.255.255.0

172.25.0.10:ip地址

255.255.255.0:子網路遮罩

子網路遮罩255位對應的ip位為網路位

子網路遮罩0對應的ip位為主機位

 

2.配置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 <auto|manual>

nmcli device connect eth0

nmcli device disconnect eth0

nmcli device show

nmcli device status

 

 650) this.width=650;" src="https://s4.51cto.com/wyfs02/M00/90/1B/wKiom1jvL9zBfFtEAAAsHnXukkc884.jpg" title="36020170413155740637.jpg" alt="wKiom1jvL9zBfFtEAAAsHnXukkc884.jpg" />

 

<<檔案>>

dhcp                                     ##動態擷取

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

DEVICE=eth0                              ##介面使用裝置

BOOTPROTO=dhcp                           ##網卡工作模式

ONBOOT=yes                               ##網路服務開啟時自動啟用

NAME=eth0                                ##網路介面名稱

:wq

systemctl 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        ##子網路遮罩

 

 650) this.width=650;" src="https://s4.51cto.com/wyfs02/M00/90/1A/wKioL1jvL9HSTwheAAAyxDROwC4501.jpg" title="36020170413155752310.jpg" alt="wKioL1jvL9HSTwheAAAyxDROwC4501.jpg" />

 

3.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

 

 650) this.width=650;" src="https://s1.51cto.com/wyfs02/M01/90/1B/wKiom1jvL-rBsr_bAAAaPdhG5h0986.jpg" title="36020170413155824055.jpg" alt="wKiom1jvL-rBsr_bAAAaPdhG5h0986.jpg" />

 

5.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服務的配置


Linux學習 Unit 11

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.