天天看點

第十一章網絡ip,dns gateway,dhcp的配置

           第十一章網絡ip,dns gateway,dhcp的配置

vim /etc/sysconfig/network-scripts/ifcfg-br0 /*br0就是?????

host www.baidu.com /*找域名所對應的ip位址

vim /etc/sysconfig/network /* 全劇設定網絡

route -n /*檢視網關

strace 常用來跟蹤程序執行時的系統調用和所接收的信号

traceroute 172.25.254.250 /*我們可以知道資訊從你的計算機到網際網路另一端的主機是走的什麼路徑

1.路由器

主要功能是用來作nat的

dnat 目的地位址轉換

snat 源位址轉換

2.網關

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

3.設定網關

systemctl stop NetworkManager    /*停止網絡管理服務    

vim /etc/sysconfig/network-scripts/ifcfg-網卡配置檔案/*網卡接口網關

GATEWAY=網關ip

systemctl restart network     /*重新開機服務

route -n            /*檢視wang網關

kernel IP routing table

systemctl status NetworkManager.service/*檢視網絡管理服務的狀态

systemctl stop NetworkManager.service /*停止網絡管理服務

> /etc/resolv.conf          /*清空dns使用者

ping westos.example.com

4.dns

1)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

第十一章網絡ip,dns gateway,dhcp的配置

 38 hosts:    db files nisplus nis dns

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

5.dhcp配置

cd /etc/sysconfig/network-scripts/  /*ip,dns,gateway配置路徑

ls

第十一章網絡ip,dns gateway,dhcp的配置

vim ifcfg-lo                /*電腦自己回環路徑

yum install dhcp -y        /*下載下傳dhcp檔案

cd /etc/dhcp            /*檢視是否有DHCP檔案

less /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example 

cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf/*将dhcp檔案複制到dhcp配置檔案

第十一章網絡ip,dns gateway,dhcp的配置
第十一章網絡ip,dns gateway,dhcp的配置

cd /etc/dhcp/

systemctl   start     dhcpd   開啟dhcp檔案

systemctl   enable    dhcpd 

如果dhcp配置出現錯誤,需要檢視報錯的日志

> /var/log/messages       /*清空日志

systemctl restart dhcpd    /*重新開機dhcpd服務

轉載于:https://blog.51cto.com/12126441/1862877

繼續閱讀