- CentOS 6
Turn off the firewall
Check the firewall is turned on
service iptables status
Stop firewall
service iptables stop
Prohibiting boot from the start Firewall
chkconfig iptables off
Set a static IP address
First on the windows cmd interface, check the current IP address of the machine, such as the author is 192.168.0.107, recorded
Then execute the following command on centos, view the current card is what is called, for example, the author is eth0
ifconfig
Continue to open the configuration file / ECT / sysconfig / Network-scripts / ifcfg- eth0
Modify key parameters
= BOOTPROTO " static " # set to a static IP address IPV6INIT = " NO " # IPV6 setting is off ONBOOT = " yes " # boot network settings IPADDR = 192.168 . Static IP address setting 0.110 # NETMASK = 255.255 . 255.0 # subnet mask code, keeping windows and the GATEWAY = 192.168 . 0.1 # NM, windows and consistent the DNS1 = 114.114 . 114.114 #DNS provided, external networks ensure DNS2 =114.114 . 115.115 #DNS settings, ensure the external network
Reboot or restart the machine to a network, a network restart command is as follows
service network restart
Off, On graphical interface
Temporary closure graphical interface
init 3
Temporary re-open the graphical interface
init 5
If you want to boot no longer start the graphical interface, you can modify / etc / inittab
id:5:initdefault: 改成 id:3:initdefault:
- CentOS 7
Set a static IP address
First check the card with the name ifconfig command, such as the author's information is as follows, the name of the card is ens33
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.189.131 netmask 255.255.255.0 broadcast 192.168.189.255 inet6 fe80::2cfb:9046:ac4a:1859 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:0d:ca:bc txqueuelen 1000 (Ethernet) RX packets 2445 bytes 412507 (402.8 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 319 bytes 41460 (40.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Open the configuration file for this card
vi /etc/sysconfig/network-scripts/ifcfg-ens33
Modify and add parameters
ONBOOT=yes BOOTPROTO=static IPV6INIT=no IPADDR=192.168.189.131 GATEWAY=192.168.189.2 NETMASK=255.255.255.0 DNS1=223.5.5.5 DNS2=223.6.6.6
note:
ONBOOT parameters, after installing centos 7, the default is no, means no boot from the start card function, proposed changes to yes
GATEWAY parameter, if you do not know what they are, you can get the following command
[root@sdb1 ~]# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.189.2 0.0.0.0 UG 100 0 0 ens33 192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0 192.168.189.0 0.0.0.0 255.255.255.0 U 100 0 0 Ens33
DNS1 and DNS2 is normal to be able to connect to external networks, if there are other better DNS, readers can modify.
After restarting the network configuration to take effect
service network restart
Turn off the firewall
Check the firewall is turned on
firewall-cmd --state
或者
systemctl status firewalld.service
或者
systemctl list-unit-files|grep firewalld.service
Stop firewall
systemctl stop firewalld.service
Prohibiting boot from the start Firewall
systemctl disable firewalld.service
Close selinux
Check whether to open selinux
getenforce
或者
/ usr / sbin / sestatus -v
Temporary closure command selinux
## is provided SELinux become permissive mode ## the setenforce . 1 disposed SELinux enforcing mode becomes the setenforce 0
Selinux permanently closed
Open the / etc / selinux / config file
You need to restart to take effect after the SELINUX = enforcing changed SELINUX = disabled, set
Note, do not set SELINUXTYPE = disabled, this will cause linux system will not boot
Off, On graphical interface
Power to the command mode is activated, execute:
systemctl set-default multi-user.target
Power to start the graphical interface, execute:
systemctl set-default graphical.target