본문 바로가기
OS/Linux

centos / port forwarding / 80 , 8080

by 하하IT 2020. 4. 19.

80 port 8080 port  port forwarding

 

 

cent OS 7

 

포트 포워딩 sample

firewall-cmd --zone=public --add-forward-port=port=80:proto=tcp:toport=8080 --permanent

firewall-cmd --reload

 

 

 

firewall-cmd --permanent --zone=internal --add-masquerade

firewall-cmd --reload 

 

 

[root@WAS live]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens192
  sources:
  services: dhcpv6-client ssh
  ports: 5050/tcp 80/tcp 8080/tcp 8443/tcp
  protocols:
  masquerade: no
  forward-ports: port=80:proto=tcp:toport=8080:toaddr=
  source-ports:
  icmp-blocks:
  rich rules:

[root@WAS live]#

 

 

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

 

cent OS 6

 

[root@localhost bin]# ---확인

[root@localhost bin]# iptables -t nat -L

Chain PREROUTING (policy ACCEPT)

target     prot opt source               destination

 

Chain POSTROUTING (policy ACCEPT)

target     prot opt source               destination

 

Chain OUTPUT (policy ACCEPT)

target     prot opt source               destination

[root@localhost bin]#

[root@localhost bin]#

[root@localhost bin]#

[root@localhost bin]#

[root@localhost bin]# --포트포워딩 추가

[root@localhost bin]# iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

[root@localhost bin]# --서비스 재시작

[root@localhost bin]# service iptables restart

iptables: Setting chains to policy ACCEPT: nat filter      [  OK  ]

iptables: Flushing firewall rules:                         [  OK  ]

iptables: Unloading modules:                               [  OK  ]

iptables: Applying firewall rules:                         [  OK  ]

[root@localhost bin]#

[root@localhost bin]# ---확인

[root@localhost bin]# iptables -t nat -L

Chain PREROUTING (policy ACCEPT)

target     prot opt source               destination

REDIRECT   tcp  --  anywhere             anywhere            tcp dpt:http redir ports 8080

 

Chain POSTROUTING (policy ACCEPT)

target     prot opt source               destination

 

Chain OUTPUT (policy ACCEPT)

target     prot opt source               destination

[root@localhost bin]#

[root@localhost bin]#

[root@localhost bin]#  --포트포워딩 삭제

[root@localhost bin]# iptables -t nat -D PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

[root@localhost bin]#

[root@localhost bin]# --서비스 재시작

[root@localhost bin]# service iptables restart

iptables: Setting chains to policy ACCEPT: nat filter      [  OK  ]

iptables: Flushing firewall rules:                         [  OK  ]

iptables: Unloading modules:                               [  OK  ]

iptables: Applying firewall rules:                         [  OK  ]

[root@localhost bin]#

[root@localhost bin]# ---확인

[root@localhost bin]# iptables -t nat -L

Chain PREROUTING (policy ACCEPT)

target     prot opt source               destination

 

Chain POSTROUTING (policy ACCEPT)

target     prot opt source               destination

 

Chain OUTPUT (policy ACCEPT)

target     prot opt source               destination

[root@localhost bin]#

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

 

'OS > Linux' 카테고리의 다른 글

centos / ntp  (0) 2020.04.21
linux / scp / 원격지 <-> 로컬 파일 복사  (0) 2020.04.20
centos / openjdk  (0) 2020.04.19
linux / centos7 / hostname  (0) 2020.04.19
crontab / crond  (0) 2020.04.17