0

In the server machine i wanted to redirect all request come to 80 to 9000 port. so i have enabled the port and added port forwarding rule.

firewall-cmd --permanent --add-forward-port=port=80:proto=tcp:toport=9000

firewall-cmd --add-masquerade

firewall-cmd --permanent --add-port=9000/tcp firewall-cmd --permanent --add-port=80/tcp

All rule was added to default zone(trusted) as below.

  trusted (active)
  target: ACCEPT
  icmp-block-inversion: no
  interfaces: eth0
  sources: 
  services: 
  ports: 9000/tcp 9001/tcp 8080/tcp 80/tcp
  protocols: 
  masquerade: yes
  forward-ports: port=80:proto=tcp:toport=9000:toaddr=
    port=8080:proto=tcp:toport=9001:toaddr=
  source-ports: 
  icmp-blocks: 
  rich rules:

But port forwarding not working. I have tested with as below.

telnet < ip_address > 80

Response is Connection refused.

1 Answer 1

2

You have set the permanent firewalld configuration, but you did not change the actual running configuration.

You should not use --permanent in any firewall-cmd commands, because you may lock yourself out of the system if you make a mistake. Instead, you should execute the same command without --permanent, which causes it to take effect immediately but not persist, and then when you are sure the rules work properly, you can save them with firewall-cmd --runtime-to-permanent.

2
  • Thanks for the response Michael. Once i have apply the port forwarding rule, i have run the firewall-cmd --reload. So all changes got applied when list the rules. Oct 23, 2018 at 6:21
  • May know to which zone, out side request comes? is it default zone? Oct 23, 2018 at 6:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .