Linux - firewalld - open ports

  1. Outline
    1. Young people to experience the first time firewalld
  2. background
    1. The first installation of apache
      1. Eight children of
    2. I had wanted to use curl got to see server
    3. The default port of 80 results page, there is a head, face html
      1. I suddenly look like a long-sawed page
      2. It was found that the browser does not open
    4. But can pass ping, ssh can pass
    5. So back to the old problem, the firewall and selinux
      1. It would have been when you plan an unhappy solution
      2. But think of the last thing, decided a little to see if there is no other solution
      3. Last casually off the firewall, resulting in a docker-cli and git do not always connect one end of the Internet ...
  3. surroundings
    1. VM OS
      1. CentOS 7
    2. Apache
      1. 2.4.6-90
    3. Network mode
      1. bridging

1. Problem

  1. problem
    1. http server in a virtual machine, the host can not be accessed
  2. verification
    1. virtual machine
      1. httpd start properly
      2. curl localhost There can be the correct result
      3. Verify whether to open firewalld
        1. I opened up this is the
        2. If not open, I really do not know how to do ...
    2. Host
      1. ping the virtual machine
      2. Browser can not access
  3. idea
    1. Ah, the port out of the question

2. retarded solution: turn off the firewall

  1. Outline
    1. The most brainless solution
    2. But for me the last time docker do so miserable, I believed
  2. operating

    # 1. 验证 防火墙 是否打开
    > systemctl status firewalld
    # 2. 关闭 防火墙
    > systemctl stop firewalld
    # 3. 验证 防火墙 是否打开
    > systemctl status firewalld
  3. result
    1. Firewall successfully closed
    2. Access the virtual machine host port 80 success

3. Conventional solution: Let firewalld open port 80

  1. Outline
    1. The normal solution
  2. step

    1. Verify whether to open firewalld

  3. Outline
    1. Be sure to open

2. Review the list of open ports of firewalld

  1. Outline
    1. View open ports
  2. command

    > firewall-cmd --list-posts
  3. result
    1. Sure enough, 80 / tcp and not therein

3. Add 80 / tcp open ports to the list

  1. Outline
    1. Adding open port
  2. command

    # 1. 添加端口
    # 参数意思, 我并不是很懂
    # 但是稍微有点基础的同学, 肯定能猜个 7788
    # 我打算等以后正式学习 firewalld 时, 再 详细说明
    > firewall-cmd --zone=public --add-port=80/tcp --permanent
    
    # 2. 重启 firewalld
    # 这步必须有
    > firewall-cmd --reload
    
    # 3. 查看是否生效
    # 80/tcp 加入了列表
    > firewall-cmd --list-posts

4. Verify the host

  1. Outline
    1. Verify the host browser
  2. result
    1. I passed here
      1. I will not elaborate on the specific

ps

  1. ref
    1. linux: centos7 open port 80 open external network access
  2. other
    1. firewalld free look
    2. wirewalld and iptables
      1. It in fact, is a thing

Guess you like

Origin www.cnblogs.com/xy14/p/12410407.html