1. 程式人生 > >linux雲自動化運維基礎知識11(ip網絡 )

linux雲自動化運維基礎知識11(ip網絡 )

linux

####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



<<文件>>
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 ##子網掩碼

技術分享


####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



####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服務的配置
利用防火墻策略和dhcp服務實現虛擬機上網

思路:1.ifconfig查看br0的ip和wls3的ip

2.開啟防火墻,編寫偽裝策略,重啟防火墻服務

3.安裝dhcp服務,並且編輯dhcp服務的配置文件,重新啟動dhcp服務

4.設置虛擬機的ip獲取方式為dhcp,重新啟動網絡服務

5.利用虛擬機測試看能否上網

操作:1.技術分享

技術分享

2.

技術分享

技術分享





3.技術分享

4技術分享



技術分享


技術分享





















本文出自 “13122425” 博客,請務必保留此出處http://13132425.blog.51cto.com/13122425/1952783

linux雲自動化運維基礎知識11(ip網絡 )