2

I have 2 machines

A 192.168.0.40 (CentOS)
B 192.168.0.41 (Debian)

Gateway 192.168.0.2

Now I did set a port forwarding using firewallD, from

A port 2245 
to 
B port 22

Connection established from client 192.168.0.1 to Machine B trough Machine A

Running netstat on machine A

# netstat -tulpane

output:

# netstat -tulpane
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       User       Inode      PID/Program name
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      0          16330      1/systemd
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      0          20510      1273/sshd
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      0          21452      1841/master
tcp        0      0 192.168.0.40:22         192.168.0.1:64870       ESTABLISHED 0          142436     4598/sshd: root@
tcp        0      0 192.168.0.40:22         192.168.0.1:59846       ESTABLISHED 0          22169      2480/sshd: root
tcp        0     64 192.168.0.40:22         192.168.0.1:65139       ESTABLISHED 0          146378     4782/sshd: root@
tcp        0      0 192.168.0.40:22         192.168.0.1:65095       ESTABLISHED 0          145904     4756/sshd: root@
tcp        0      0 192.168.0.40:22         192.168.0.1:65024       ESTABLISHED 0          145298     4704/sshd: root@
tcp6       0      0 :::111                  :::*                    LISTEN      0          16329      1/systemd
tcp6       0      0 :::22                   :::*                    LISTEN      0          20519      1273/sshd
tcp6       0      0 ::1:25                  :::*                    LISTEN      0          21453      1841/master
udp        0      0 127.0.0.1:323           0.0.0.0:*                           997        16978      782/chronyd
udp        0      0 0.0.0.0:922             0.0.0.0:*                           0          41344      2868/rpcbind
udp        0      0 0.0.0.0:111             0.0.0.0:*                           0          41343      2868/rpcbind
udp6       0      0 ::1:323                 :::*                                997        16979      782/chronyd
udp6       0      0 :::922                  :::*                                0          41346      2868/rpcbind
udp6       0      0 :::111                  :::*                                0          41345      2868/rpcbind

Question: Why I can't see the Machine B in connections ? and what shall I do to see it ?

  • What are you using to route the traffic from machine A to B? If you are using iptables to route the traffic, have a look at masuqerade. This masquerade rule has to be configured on machine B. – Valentin Bajrami Jul 16 '17 at 12:02
  • I'm using firewallD as stated in description, its interface on top of the iptables, masquerade is enabled, but how exactly shall I have to look in it and why exactly netstat can't see it , when there is clearly an established connection? – Zaza Jul 16 '17 at 12:05
  • As a side note, netstat is deprecated by ss so I would start using ss (socket statisticks). On machine A you seen only incoming connections. iptables have conntracking tools to show that. Use tcpdump or anything more sophisticated to do so. – Valentin Bajrami Jul 16 '17 at 12:18
6

Why I can't see the Machine B in connections?

because it's acting as a router, not an endpoint of the connection.

and what shall I do to see it?

To show connections tracked by the stateful firewall, run conntrack.

http://conntrack-tools.netfilter.org/manual.html#conntrack

If you did not have a stateful firewall, you would have to simply capture and interpret packets. wireshark works well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.