修改主機(jī)名
vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=server1.itcast.cn
修改ip地址
vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes #是否開(kāi)機(jī)啟用
BOOTPROTO=static #ip地址設(shè)置為靜態(tài)
IPADDR=192.168.0.101
NETMASK=255.255.255.0
service network restart
配置網(wǎng)關(guān)
修改ipaddr的配置文件
vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 #描述網(wǎng)卡對(duì)應(yīng)的設(shè)備別名,例如ifcfg-eth0的文件中它為eth0
HWADDR=00:0C:29:8D:1A:5A #對(duì)應(yīng)的網(wǎng)卡物理地址
TYPE=Ethernet
UUID=a1a50709-b2e1-4c0b-ae44-01da84863386 #通用唯一識(shí)別碼 (Universally Unique Identifier)
ONBOOT=yes #系統(tǒng)啟動(dòng)時(shí)是否設(shè)置此網(wǎng)絡(luò)接口,設(shè)置為yes時(shí),系統(tǒng)啟動(dòng)時(shí)激活此設(shè)備
NM_CONTROLLED=yes #network manger的參數(shù),實(shí)時(shí)生效,修改后無(wú)需要重啟網(wǎng)卡立即生效。
BOOTPROTO=static #設(shè)置網(wǎng)卡獲得ip地址的方式,可能的選項(xiàng)為static,dhcp或bootp,分別對(duì)應(yīng)靜態(tài)指定的 ip地址,通過(guò)dhcp協(xié)議獲得的ip地址,通過(guò)bootp協(xié)議獲得的ip地址
NETMASK=255.255.255.0 #網(wǎng)卡對(duì)應(yīng)的網(wǎng)絡(luò)掩碼
IPADDR=192.168.199.93
GATEWAY=192.168.199.1
修改網(wǎng)關(guān)
vim /etc/sysconfig/network
NETWORKING=yes #表示系統(tǒng)是否使用網(wǎng)絡(luò),一般設(shè)置為yes。如果設(shè)為no,則不能使用網(wǎng)絡(luò),而且很多系統(tǒng)服務(wù)程序?qū)o(wú)法啟動(dòng)
HOSTNAME=Centos-shaocongshuai #設(shè)置本機(jī)的主機(jī)名,這里設(shè)置的主機(jī)名要和/etc/hosts中設(shè)置的主機(jī)名對(duì)應(yīng)
GATEWAY=192.168.199.1
修改dns
- vim /etc/resolv.conf
# Generated by NetworkManager
# No nameservers found; try putting DNS servers into your
# ifcfg files in /etc/sysconfig/network-scripts like so:
#
# DNS1=xxx.xxx.xxx.xxx
# DNS2=xxx.xxx.xxx.xxx
# DOMAIN=lab.foo.com bar.foo.com
nameserver 4.2.2.2 #微軟的dns
nameserver 8.8.8.8 #谷歌的dns
- 微軟DNS 4.2.2.1 4.2.2.2
- comodoDNS 156.154.70.25 156.154.71.25
- 谷歌DNS 8.8.8.8 8.8.4.4
- openDNS 208.67.220.220 208.67.222.220
重新啟動(dòng)網(wǎng)絡(luò)配置
-
service network restart
或 /etc/init.d/network restart
注意:
- 當(dāng)出現(xiàn)下面問(wèn)題
http://mirror.vodien.com/centos/6.8/os/x86_64/Packages/tree-1.5.3-3.el6.x86_64.rpm: [Errno 14] PYCURL ERROR 6 - "Couldn't resolve host 'mirror.vodien.com'"
Trying other mirror.
Error Downloading Packages:
tree-1.5.3-3.el6.x86_64: failure: Packages/tree-1.5.3-3.el6.x86_64.rpm from base: [Errno 256] No more mirrors to try.
- 則查看dns的配置文件
(網(wǎng)關(guān)的配置文件改變之后,dns 的配置文件就會(huì)變化)
修改ip地址和主機(jī)名的映射關(guān)系
vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4
localhost4.localdomain4
::1 localhost localhost.localdomain localhost6
關(guān)閉iptables并設(shè)置其開(kāi)機(jī)啟動(dòng)/不啟動(dòng)
service iptables stop
chkconfig iptables on
chkconfig iptables off
批量自動(dòng)刪除rpm包
rpm -qa | grep mysql | while read c; do rpm -e $c --nodeps; done