某VPS装了centos7却被迫用iptables的爬坑记

某VPS服务商的19.9美元/年的VPS的折腾:

安装的centos7,内核居然2.6,正常centos7内核应该是3.0的。先来个2.6内核的如下图

root@viaucc ~]# hostnamectl 

   Static hostname: n/a

Transient hostname: viaucc

         Icon name: computer-container

           Chassis: container

        Machine ID: aa443232132382450753d294e

           Boot ID: festrewewt131313

    Virtualization: openvz

  Operating System: CentOS Linux 7 (Core)

       CPE OS Name: cpe:/o:centos:centos:7

            Kernel: Linux 2.6.32-042stab133.2

      Architecture: x86-64

再来一个正常的

[root@centos ~]# hostnamectl 

   Static hostname: centos

         Icon name: computer-vm

           Chassis: vm

        Machine ID: 1234567

           Boot ID: 1234567

    Virtualization: kvm

  Operating System: CentOS Linux 7 (Core)

       CPE OS Name: cpe:/o:centos:centos:7

            Kernel: Linux 3.10.0-862.14.4.el7.x86_64

      Architecture: x86-64

折腾的原因是,重装系统启用firewalld的时候,启用不了,百度一番启用倒是启用了,reboot之后就失联了,ssh不上,网站也无法访问。重装了四五次,都是不行,证明了一点

它的这个centos7并非正版原装centos7,而是自己修改过的。内核2.6,firewalld用不了,你要强行用重启之后就断网了。无奈只得用不熟悉的iptables,装系统选minimal的话iptables都不正常。最后使用iptables的命令网站才能正常访问。

[root@viaucc ~]# systemctl status firewalld

● firewalld.service - firewalld - dynamic firewall daemon

   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)

   Active: inactive (dead)

[root@viaucc ~]# systemctl status iptables 

● iptables.service - IPv4 firewall with iptables

   Loaded: loaded (/usr/lib/systemd/system/iptables.service; enabled; vendor preset: disabled)

   Active: active (exited) since Sat 2018-10-20 23:03:15 EDT; 3min 2s ago

  Process: 123 ExecStart=/usr/libexec/iptables/iptables.init start (code=exited, status=0/SUCCESS)

 Main PID: 123 (code=exited, status=0/SUCCESS)

   CGroup: /system.slice/iptables.service


Oct 20 23:03:14 viaucc systemd[1]: Starting IPv4 firewall with iptables...

Oct 20 23:03:14 viaucc iptables.init[123]: iptables: Applying firewall rules: [  OK  ]

Oct 20 23:03:15 viaucc systemd[1]: Started IPv4 firewall with iptables.

[root@viaucc ~]# iptables -L

Chain INPUT (policy ACCEPT)

target     prot opt source               destination         


Chain FORWARD (policy ACCEPT)

target     prot opt source               destination         


Chain OUTPUT (policy ACCEPT)

target     prot opt source               destination         

[root@viaucc ~]# iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT

[root@viaucc ~]# iptables -L

Chain INPUT (policy ACCEPT)

target     prot opt source               destination         

ACCEPT     all  --  localhost.localdomain  localhost.localdomain 


Chain FORWARD (policy ACCEPT)

target     prot opt source               destination         


Chain OUTPUT (policy ACCEPT)

target     prot opt source               destination         

[root@viaucc ~]# iptables -A OUTPUT -j ACCEPT

[root@viaucc ~]# iptables -A INPUT -p tcp --dport 26723 -j ACCEPT

[root@viaucc ~]# iptables -A INPUT -p tcp --dport 80 -j ACCEPT

[root@viaucc ~]# iptables -save

iptables v1.4.21: no command specified

Try `iptables -h' or 'iptables --help' for more information.

[root@viaucc ~]# iptables save

Bad argument `save'

Try `iptables -h' or 'iptables --help' for more information.

[root@viaucc ~]# iptables  

iptables          iptables-restore  iptables-save     iptables-xml      

[root@viaucc ~]# iptables-save

# Generated by iptables-save v1.4.21 on Sat Oct 20 23:10:53 2018

*raw

:PREROUTING ACCEPT [609:38557]

:OUTPUT ACCEPT [545:35008]

COMMIT

# Completed on Sat Oct 20 23:10:53 2018

# Generated by iptables-save v1.4.21 on Sat Oct 20 23:10:53 2018

*nat

:PREROUTING ACCEPT [363:18892]

:POSTROUTING ACCEPT [1:73]

:OUTPUT ACCEPT [1:73]

COMMIT

# Completed on Sat Oct 20 23:10:53 2018

# Generated by iptables-save v1.4.21 on Sat Oct 20 23:10:53 2018

*mangle

:PREROUTING ACCEPT [609:38557]

:INPUT ACCEPT [609:38557]

:FORWARD ACCEPT [0:0]

:OUTPUT ACCEPT [545:35008]

:POSTROUTING ACCEPT [545:35008]

COMMIT

# Completed on Sat Oct 20 23:10:53 2018

# Generated by iptables-save v1.4.21 on Sat Oct 20 23:10:53 2018

*filter

:INPUT ACCEPT [2:84]

:FORWARD ACCEPT [0:0]

:OUTPUT ACCEPT [0:0]

-A INPUT -s 127.0.0.1/32 -d 127.0.0.1/32 -j ACCEPT

-A INPUT -p tcp -m tcp --dport 26723 -j ACCEPT

-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT

-A OUTPUT -j ACCEPT

COMMIT

# Completed on Sat Oct 20 23:10:53 2018

[root@viaucc ~]# iptables -L

Chain INPUT (policy ACCEPT)

target     prot opt source               destination         

ACCEPT     all  --  localhost.localdomain  localhost.localdomain 

ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:26723

ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:http


Chain FORWARD (policy ACCEPT)

target     prot opt source               destination         


Chain OUTPUT (policy ACCEPT)

target     prot opt source               destination         

ACCEPT     all  --  anywhere             anywhere            

[root@viaucc ~]# yum install httpd php php-mysql -y

Loaded plugins: fastestmirror

base                                                                                                                                                 | 3.6 kB  00:00:00     

extras                                                                                                                                               | 3.4 kB  00:00:00     

updates                                                                                                                                              | 3.4 kB  00:00:00     

(1/4): base/7/x86_64/group_gz                                                                                                                        | 166 kB  00:00:00     

(2/4): extras/7/x86_64/primary_db                                                                                                                    | 204 kB  00:00:00     

(3/4): base/7/x86_64/primary_db                                                                                                                      | 5.9 MB  00:00:06     

(4/4): updates/7/x86_64/primary_db                                                                                                                   | 6.0 MB  00:00:21     

Determining fastest mirrors

 * base: repos.lax.quadranet.com

 * extras: repos.lax.quadranet.com

 * updates: repos.lax.quadranet.com

Resolving Dependencies

--> Running transaction check

---> Package httpd.x86_64 0:2.4.6-40.el7.centos.4 will be updated

---> Package httpd.x86_64 0:2.4.6-80.el7.centos.1 will be an update

--> Processing Dependency: httpd-tools = 2.4.6-80.el7.centos.1 for package: httpd-2.4.6-80.el7.centos.1.x86_64

---> Package php.x86_64 0:5.4.16-45.el7 will be installed

--> Processing Dependency: php-common(x86-64) = 5.4.16-45.el7 for package: php-5.4.16-45.el7.x86_64

--> Processing Dependency: php-cli(x86-64) = 5.4.16-45.el7 for package: php-5.4.16-45.el7.x86_64

--> Processing Dependency: libcrypto.so.10(OPENSSL_1.0.2)(64bit) for package: php-5.4.16-45.el7.x86_64

---> Package php-mysql.x86_64 0:5.4.16-45.el7 will be installed

--> Processing Dependency: php-pdo(x86-64) = 5.4.16-45.el7 for package: php-mysql-5.4.16-45.el7.x86_64

--> Running transaction check

---> Package httpd-tools.x86_64 0:2.4.6-40.el7.centos.4 will be updated

---> Package httpd-tools.x86_64 0:2.4.6-80.el7.centos.1 will be an update

---> Package openssl-libs.x86_64 1:1.0.1e-51.el7_2.7 will be updated

--> Processing Dependency: openssl-libs(x86-64) = 1:1.0.1e-51.el7_2.7 for package: 1:openssl-1.0.1e-51.el7_2.7.x86_64

---> Package openssl-libs.x86_64 1:1.0.2k-12.el7 will be an update

---> Package php-cli.x86_64 0:5.4.16-45.el7 will be installed

---> Package php-common.x86_64 0:5.4.16-45.el7 will be installed

--> Processing Dependency: libzip.so.2()(64bit) for package: php-common-5.4.16-45.el7.x86_64

---> Package php-pdo.x86_64 0:5.4.16-45.el7 will be installed

--> Running transaction check

---> Package libzip.x86_64 0:0.10.1-8.el7 will be installed

---> Package openssl.x86_64 1:1.0.1e-51.el7_2.7 will be updated

---> Package openssl.x86_64 1:1.0.2k-12.el7 will be an update

--> Finished Dependency Resolution


Dependencies Resolved


============================================================================================================================================================================

 Package                                  Arch                               Version                                              Repository                           Size

============================================================================================================================================================================

Installing:

 php                                      x86_64                             5.4.16-45.el7                                        base                                1.4 M

 php-mysql                                x86_64                             5.4.16-45.el7                                        base                                101 k

Updating:

 httpd                                    x86_64                             2.4.6-80.el7.centos.1                                updates                             2.7 M

Installing for dependencies:

 libzip                                   x86_64                             0.10.1-8.el7                                         base                                 48 k

 php-cli                                  x86_64                             5.4.16-45.el7                                        base                                2.7 M

 php-common                               x86_64                             5.4.16-45.el7                                        base                                565 k

 php-pdo                                  x86_64                             5.4.16-45.el7                                        base                                 99 k

Updating for dependencies:

 httpd-tools                              x86_64                             2.4.6-80.el7.centos.1                                updates                              90 k

 openssl                                  x86_64                             1:1.0.2k-12.el7                                      base                                492 k

 openssl-libs                             x86_64                             1:1.0.2k-12.el7                                      base                                1.2 M


Transaction Summary

============================================================================================================================================================================

Install  2 Packages (+4 Dependent packages)

Upgrade  1 Package  (+3 Dependent packages)


Total download size: 9.4 M

Downloading packages:

Delta RPMs disabled because /usr/bin/applydeltarpm not installed.

warning: /var/cache/yum/x86_64/7/updates/packages/httpd-tools-2.4.6-80.el7.centos.1.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY 1.7 MB  --:--:-- ETA 

Public key for httpd-tools-2.4.6-80.el7.centos.1.x86_64.rpm is not installed

(1/10): httpd-tools-2.4.6-80.el7.centos.1.x86_64.rpm                                                                                                 |  90 kB  00:00:00     

Public key for libzip-0.10.1-8.el7.x86_64.rpm is not installed

(2/10): libzip-0.10.1-8.el7.x86_64.rpm                                                                                                               |  48 kB  00:00:00     

(3/10): openssl-1.0.2k-12.el7.x86_64.rpm                                                                                                             | 492 kB  00:00:00     

(4/10): php-common-5.4.16-45.el7.x86_64.rpm                                                                                                          | 565 kB  00:00:00     

(5/10): php-mysql-5.4.16-45.el7.x86_64.rpm                                                                                                           | 101 kB  00:00:00     

(6/10): php-pdo-5.4.16-45.el7.x86_64.rpm                                                                                                             |  99 kB  00:00:00     

(7/10): php-5.4.16-45.el7.x86_64.rpm                                                                                                                 | 1.4 MB  00:00:00     

(8/10): httpd-2.4.6-80.el7.centos.1.x86_64.rpm                                                                                                       | 2.7 MB  00:00:01     

(9/10): php-cli-5.4.16-45.el7.x86_64.rpm                                                                                                             | 2.7 MB  00:00:01     

(10/10): openssl-libs-1.0.2k-12.el7.x86_64.rpm                                                                                                       | 1.2 MB  00:00:03     

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Total                                                                                                                                       2.6 MB/s | 9.4 MB  00:00:03     

Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

Importing GPG key 0xF4A80EB5:

 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"

 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5

 Package    : centos-release-7-2.1511.el7.centos.2.10.x86_64 (installed)

 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Updating   : 1:openssl-libs-1.0.2k-12.el7.x86_64                                                                                                                     1/14 

  Updating   : httpd-tools-2.4.6-80.el7.centos.1.x86_64                                                                                                                2/14 

  Updating   : httpd-2.4.6-80.el7.centos.1.x86_64                                                                                                                      3/14 

  Installing : libzip-0.10.1-8.el7.x86_64                                                                                                                              4/14 

  Installing : php-common-5.4.16-45.el7.x86_64                                                                                                                         5/14 

  Installing : php-cli-5.4.16-45.el7.x86_64                                                                                                                            6/14 

  Installing : php-pdo-5.4.16-45.el7.x86_64                                                                                                                            7/14 

  Installing : php-mysql-5.4.16-45.el7.x86_64                                                                                                                          8/14 

  Installing : php-5.4.16-45.el7.x86_64                                                                                                                                9/14 

  Updating   : 1:openssl-1.0.2k-12.el7.x86_64                                                                                                                         10/14 

  Cleanup    : httpd-2.4.6-40.el7.centos.4.x86_64                                                                                                                     11/14 

  Cleanup    : httpd-tools-2.4.6-40.el7.centos.4.x86_64                                                                                                               12/14 

  Cleanup    : 1:openssl-1.0.1e-51.el7_2.7.x86_64                                                                                                                     13/14 

  Cleanup    : 1:openssl-libs-1.0.1e-51.el7_2.7.x86_64                                                                                                                14/14 

  Verifying  : php-common-5.4.16-45.el7.x86_64                                                                                                                         1/14 

  Verifying  : php-5.4.16-45.el7.x86_64                                                                                                                                2/14 

  Verifying  : httpd-tools-2.4.6-80.el7.centos.1.x86_64                                                                                                                3/14 

  Verifying  : php-cli-5.4.16-45.el7.x86_64                                                                                                                            4/14 

  Verifying  : httpd-2.4.6-80.el7.centos.1.x86_64                                                                                                                      5/14 

  Verifying  : php-pdo-5.4.16-45.el7.x86_64                                                                                                                            6/14 

  Verifying  : php-mysql-5.4.16-45.el7.x86_64                                                                                                                          7/14 

  Verifying  : libzip-0.10.1-8.el7.x86_64                                                                                                                              8/14 

  Verifying  : 1:openssl-1.0.2k-12.el7.x86_64                                                                                                                          9/14 

  Verifying  : 1:openssl-libs-1.0.2k-12.el7.x86_64                                                                                                                    10/14 

  Verifying  : 1:openssl-libs-1.0.1e-51.el7_2.7.x86_64                                                                                                                11/14 

  Verifying  : 1:openssl-1.0.1e-51.el7_2.7.x86_64                                                                                                                     12/14 

  Verifying  : httpd-tools-2.4.6-40.el7.centos.4.x86_64                                                                                                               13/14 

  Verifying  : httpd-2.4.6-40.el7.centos.4.x86_64                                                                                                                     14/14 


Installed:

  php.x86_64 0:5.4.16-45.el7                                                        php-mysql.x86_64 0:5.4.16-45.el7                                                       


Dependency Installed:

  libzip.x86_64 0:0.10.1-8.el7            php-cli.x86_64 0:5.4.16-45.el7            php-common.x86_64 0:5.4.16-45.el7            php-pdo.x86_64 0:5.4.16-45.el7           


Updated:

  httpd.x86_64 0:2.4.6-80.el7.centos.1                                                                                                                                      


Dependency Updated:

  httpd-tools.x86_64 0:2.4.6-80.el7.centos.1                     openssl.x86_64 1:1.0.2k-12.el7                     openssl-libs.x86_64 1:1.0.2k-12.el7                    


Complete!

[root@viaucc ~]# systemctl start httpd

[root@viaucc ~]# systemctl enable httpd

Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.

[root@viaucc ~]# 

刷新页面,终于看到了apache的测试页面!

最后编辑于:2018/10/21作者: admin

相关推荐

发表评论