Centos 7 Installation Settings IP address, DNS, hostname, firewall, port, SELinux (measured + notes)

Source: Internet
Author: User
Tags nameserver

Environment:

System hardware: VMware vsphere (cpu:2*4 core, memory 2G, dual NIC)

System version: Centos-7.0-1406-x86_64-dvd.iso

Installation steps:

1. Virtual system Installation

1.1 Use the VMware virtual machine to read the ISO for installation. Install the interface after startup

1.2 Select the Install CentOS7 for language selection

1.3 Select Simplified Chinese and go to the information summary

1.4 Click "Install Location", select the hard disk that the system needs to install, click "Finish".

1.5 Click "Network and hostname", make network settings, set "On", then click "Finish".

1.6 In the "Installation Information Summary" screen, click "Start Installation".

1.7 "After package installation is complete", set the root password

1.8 After setting the root password, in the "Configuration" screen, wait for the installation package to complete the installation (total 297), click "End Configuration" after completion.

1.9 When prompted, click "Restart" to restart the computer

2. System environment

2.1 Updating the system

[Root@centos ~]# Yum update-y

Restart

[Root@centos ~]# Shutdown-r now

2.2 Viewing the Environment

[Root@centos ~]# Cat/etc/redhat-release

CentOS Linux release 7.0.1406 (Core)

[Root@centos ~]# Uname-a

Linux localhost.localdomain 3.10.0-123.4.2.el7.x86_64 #1 SMP Mon June 16:09:14 UTC x86_64 x86_64 x86_64 gnu/linux

2.3 Installing a common package

[Root@centos ~]# yum-y install vim wget lsof gcc gcc-c++ net-tools bind-utils bzip2

3. System settings

3.1 Time settings

Current Time View

[Root@centos ~]# Date

Time setting

[Root@centos ~]# date-s "2014-7-11 12:00"

3.2 Host name settings

Current host name View

[Root@centos ~]# hostname

Host name Settings

[Root@centos ~]# Vim/etc/sysconfig/network

Add the following to the open file

Hostname TCENTOS7

: Wq Save Exit

[Root@centos ~]# Service Network restart

[Root@centos ~]# hostname

TCentos7

3.3 IP Settings

Current IP view (ifconfig not installed by default, need to install Net-tools package)

[Root@centos ~]# Ifconfig

The following content shows that there are currently "ens192" and "ens224" two network cards

Ens192:flags=4163<up,broadcast,running,multicast> MTU 1500
inet 192.168.1.30 netmask 255.255.255.0 broadcast 192.168.1.255
Inet6 fe80::250:56ff:fe94:631b Prefixlen ScopeID 0x20<link>
Ether 00:50:56:94:63:1b Txqueuelen (Ethernet)
RX Packets 158 Bytes 15474 (15.1 KiB)
RX Errors 0 dropped 7 overruns 0 frame 0
TX Packets 104 Bytes 14836 (14.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Ens224:flags=4163<up,broadcast,running,multicast> MTU 1500
Ether 00:50:56:94:74:3f Txqueuelen (Ethernet)
RX Packets Bytes 7309 (7.1 KiB)
RX Errors 0 dropped 6 overruns 0 frame 0
TX Packets 0 Bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

Lo:flags=73<up,loopback,running> MTU 65536
inet 127.0.0.1 netmask 255.0.0.0
Inet6:: 1 prefixlen ScopeID 0x10Loop Txqueuelen 0 (Local Loopback)
RX Packets 0 Bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX Packets 0 Bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

[Root@centos ~]# vim/etc/sysconfig/network-scripts/ifcfg-ens192

Check if HWADDR is on MAC address, modify the following bootproto, add Ipaddr,netmask,gateway

Hwaddr= "00:50:56:94:63:1B"
Type= "Ethernet"
bootproto= "Static"
Defroute= "Yes"
Peerdns= "Yes"
Peerroutes= "Yes"
Ipv4_failure_fatal= "No"
ipv6init= "Yes"
ipv6_autoconf= "Yes"
Ipv6_defroute= "Yes"
Ipv6_peerdns= "Yes"
Ipv6_peerroutes= "Yes"
Ipv6_failure_fatal= "No"
Name= "ens192"
Uuid= "2d92dacb-4277-4846-ad83-c6d2a9b27e35"
onboot= "Yes"
Ipaddr= "192.168.1.30"
netmask= "255.255.255.0"
Gateway= "192.168.1.1"

: Wq Save Exit

[Root@centos ~]# Service Network restart

[Root@centos ~] #ifconfig

See if the modified IP address is in effect

3.4 Modifying DNS settings

Current host name View

[Root@centos ~]# vim/etc/resolv.conf

Add the following to the open file 8.8.8.8 for googledns,61.144.56.100 local DNS (different places)

NameServer 8.8.8.8
NameServer 61.144.56.100

: Wq Save Exit

3.5 Turn off SELinux

[Root@centos ~]# Vim/etc/selinux/config

Modify the following content

#SELINUX =enforcing #注释掉

#SELINUXTYPE =targeted #注释掉

Selinux=disabled #增加

: Wq #保存退出

3.6 Modify the firewall to open the specified port

3.6.1 Installation Iptables

[Root@centos ~]# Yum Install iptables-services

Set firewall rules (add 80 ports)

[Root@centos ~]# Vim/etc/sysconfig/iptables

Open file, add 80 port that line

*filter
: INPUT ACCEPT [0:0]
: FORWARD ACCEPT [0:0]
: OUTPUT ACCEPT [0:0]
-A input-m state--state related,established-j ACCEPT
-A input-p icmp-j ACCEPT
-A input-i lo-j ACCEPT
-A input-p tcp-m state--state new-m TCP--dport 22-j ACCEPT
-A input-p tcp-m state--state new-m TCP--dport 80-j ACCEPT
-A input-j REJECT--reject-with icmp-host-prohibited
-A forward-j REJECT--reject-with icmp-host-prohibited
COMMIT

: Wq #保存退出

3.6.2 Default firewall as a firewall setting

#禁止firewall开机启动

[Root@centos ~]# systemctl Disable Firewalld.service

#设置防火墙开机启动

[Root@centos ~]# Systemctl Enable Iptables.service

#停止firewall

[Root@centos ~]# Systemctl Stop Firewalld.service

#重启防火墙使配置生效

[Root@centos ~]# systemctl Restart Iptables.service

3.6.3 viewing the ports that are currently open on the system

[Root@centos ~]# NETSTAT-LNTP

Active Internet connections (only servers)
Proto recv-q send-q Local address Foreign address State Pid/program Name
TCP 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2157/master
TCP 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1292/sshd
TCP6 0 0:: 1:25:::* LISTEN 2157/master
TCP6 0 0::: $:::* LISTEN 1292/sshd

3.6.4 Viewing and setting SELinux

View

[Root@centos ~]# Getenforce

[Root@centos ~]# Setenforce 0 temporarily closed

[Root@centos ~]# setenforce 1 temporary Open

[Root@centos ~]# Vim/etc/selinux/config

Block the following:

#SELINUX =enforcing

#SELINUXTYPE =targeted

Add the following content

Selinux=disabled

Save, exit

[Root@centos ~]# Shutdown-r now

Centos 7 Installation Settings IP address, DNS, hostname, firewall, port, SELinux (measured + notes)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.