Install and set the IP address, DNS, host name, firewall, and port in centos 7 (test + note)

Source: Internet
Author: User
Tags nameserver

Environment:

System hardware: VMWare vsphere (CPU: 2*4 cores, 2 GB memory, 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 and read ISO for installation. Installation page after startup

1.2 select install centos7 for language selection

1.3 select Simplified Chinese to enter the information Abstract

 

 

1.4 click "installation location", select the hard disk to which the system is to be installed, and click "finish ".

1.5 click "network and host name" to set the network to "enable", and then click "finish ".

1.6 on the "installation information Summary" page, click "Start installation ".

1.7 "after the package is installed", set the root password

1.8 After setting the root password, wait for the installation package to complete installation (297 in total) on the "configuration" Page and click "End configuration ".

1.9 after the prompt is complete, click "restart" to restart the computer

 

2. System Environment

2.1 update the system

[Root @ centos ~] # Yum Update-y

Restart

[Root @ centos ~] # Shutdown-R now

 

2.2 view the environment

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

Centos Linux release 7.0.1406 (CORE)

[Root @ centos ~] # Uname-

Linux localhost. localdomain 3.10.0-123.4.2.el7.x86 _ 64 #1 SMP mon Jun 30 16:09:14 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

 

2.3 install common packages

[Root @ centos ~] # Yum-y install Vim wget lsof GCC gcc-C ++ net-tools bind-utils Bzip2

 

3. system settings

3.1 time setting

View Current Time

[Root @ centos ~] # Date

Time settings

[Root @ centos ~] # Date-s"

 

3.2 host name settings

View current host name

[Root @ centos ~] # Hostname

Host Name settings

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

Add the following content to the open file:

Hostname tcentos7

: WQ save and exit

 

[Root @ centos ~] # Service network restart

[Root @ centos ~] # Hostname

Tcentos7

 

3.3 IP settings

View the current IP address (ifconfig is not installed by default, and the net-tools package needs to be installed)

[Root @ centos ~] # Ifconfig

The following content indicates that there are two NICs: "ens192" and "ens224 ".

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 64 scopeid 0x20 <link>
Ether 00: 50: 56: 94: 63: 1B txqueuelen 1000 (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 1000 (Ethernet)
RX packets 86 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 128 scopeid 0x10 Loop 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 whether hwaddr is correct for the MAC address, modify the following content bootproto, and add ipaddr, netmask, Gateway

Hwaddr = "00: 50: 56: 94: 63: 1B"
Type = "Ethernet"
Bootproto = "static"
Defroute = "yes"
Peerdns = "yes"
Peerroutes = "yes"
20174_failure_fatal = "no"
Ipv6init = "yes"
Ipv6_autoconf = "yes"
20176_defroute = "yes"
Ipv6_peerdns = "yes"
20176_peerroutes = "yes"
20176_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 and exit

 

[Root @ centos ~] # Service network restart

[Root @ centos ~] # Ifconfig

Check whether the modified IP address takes effect

 

3.4 modify DNS settings

View current host name

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

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

Nameserver 8.8.8.8
Nameserver 61.144.56.100

 

: WQ save and exit

 

3.5 disable SELinux

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

Modify the following content

# SELinux = enforcing # comment out

# Selinuxtype = targeted # comment out

SELinux = disabled # Add

 

: WQ # Save and exit

 

3.6 modify the firewall and open the specified port

3.6.1 install iptables

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

Set firewall rules (add Port 80)

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

Open the file and add the port 80 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 # Save and exit

 

3.6.2 use firewall as the firewall setting by default

# Disable firewall startup

[Root @ centos ~] # Systemctl disable firewalld. Service

# Set firewall startup

[Root @ centos ~] # Systemctl enable iptables. Service

# Stop Firewall

[Root @ centos ~] # Systemctl stop firewalld. Service

# Restart the firewall to make the configuration take effect

[Root @ centos ~] # Systemctl restart iptables. Service

 

3.6.3 view the port opened by the current 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: 22: * Listen 1292/sshd

 

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.