S
S
SergeyShibka2016-08-25 14:08:52
linux
SergeyShibka, 2016-08-25 14:08:52

Port forwarding to the local network. What can interfere?

There is a machine acting as a router on CentOS 6. It has three network cards. Two for different providers eth1 and eth2, so that the Internet has a backup channel, and one eth0 to the local network.
It is necessary to forward the port so that when accessing the port for example 8083 from the Internet to the eth2 network card, they get to the computer with the address 192.168.190.2 and port 80 through the eh0 network card in the local network.
No matter how hard he fought, it didn't work. What can interfere?
tpcdump -n dst 192.168.190.2 and port 8083 sees the call, but there is silence in the logs on the machine in the LAN.
router network interfaces:
LAN: eth0 192.168.190.1
internet 1: eth1 192.168.1.210
internet 2: eth2 195.170.10.120
iptables rules in config:
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A FORWARD -i eth0 -j ACCEPT
-A FORWARD -o eth0 -j ACCEPT
-A FORWARD -i eth1 -j ACCEPT
-A FORWARD -o eth1 -j ACCEPT
-A FORWARD -i eth2 - j ACCEPT
-A FORWARD -o eth2 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
*nat
:PREROUTING ACCEPT [ 0:0]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A PREROUTING -d 195.170.10.120 -p tcp -m tcp --dport 8083 -j DNAT --to-destination 192.168.190.2:80
-A POSTROUTING -d 192.168.190.2 -p tcp -m tcp --dport 80 - j SNAT --to-source 195.170.10.120
COMMIT

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir, 2016-08-25
@rostel

change to nat (can be removed altogether if 192.168.190.2 has a default gateway of 192.168.190.1)
add to filter

-A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -d 192.168.190.2 -p tcp -m tcp --dport 80 -j ACCEPT

check if forwarding is allowed
cat /proc/sys/net/ipv4/ip_forward

S
SergeyShibka, 2016-08-26
@SergeyShibka

cat /proc/sys/net/ipv4/ip_forward

allowed, gives 1
the rest tried, does not help, does not reach the local machine, it has empty logs.
I run it on the gateway router:
I get:
06:59:00.215897 IP 85.140.7.81.27464 > 192.168.190.2.http: Flags [S], seq 1698534004, win 65535, options [mss 1420,sackOK,TS val 528538 ecr 0,nop,wscale 8], length 0

C
comper, 2016-08-26
@comper

Is the web server accessible from the LAN? Check firewall on webserver

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question