Home > OS >  SSH forward question!!!!! Urgent!!!!!!!!!!
SSH forward question!!!!! Urgent!!!!!!!!!!

Time:10-09

Currently has a Linux system forward machine do SSH forward, meet some special cases,
Suppose this forward Linux machine to machine A, one machine need to machine A, B to visit the machine C and D, and must use the same port to port 9000,
If I am in A machine set up two network CARDS, network CARDS 2 1 and the network card, can do B machines through port 9000 to access card 1 C, through the network card 2 D 9000 port access machines,


Originally need two forwarding machine, but current conditions is limited, there is only so a machine as a repeater, so want to consult, this method can not able to achieve, can be achieved, need to how to achieve it?

CodePudding user response:

Don't know much about the port forwarding, two card can set routing, network card 1 C routing to machine, card 2 D routing to the machine,

CodePudding user response:

reference 1st floor weixin_39333736 response:
don't know much about the port forwarding, two nics can set routing, network card 1 C routing to machine, card 2 D routing to the machine,

It is this forward SSH
SSH - TNfaq - L 158.120.30.25:9000:150.120.60.155:9000 [email protected]
Is the need to the port 9000, access to the machine C and D respectively, can realize the network card 1 port 9000, access to the machine C, 9000 port access card 2 D machine

CodePudding user response:

Use nginx (or haproxy) agent SSH can feel

` ` `
The stream {
Server {
Listen 158.120.30.25:9000;
Proxy_pass ssh1;
}

Server {
Listen 150.120.60.155:9000;
Proxy_pass an ssh2;
}

Upstream ssh1 {
Server ssh1:22;
}
Upstream an ssh2 {
The server an ssh2:22;
}
}
` ` `

CodePudding user response:

Firewalls are needed to do, to specify different segments with different network card, it is ok to should

CodePudding user response:

2, through the script file defines the port forwarding
Script: by accessing 52.82. 7.0.x.x port 4000 to access 172.31 7.0.x.x port 22
52.82. 7.0.x.x for public IP 172.31. 7.0.x.x for private IP

Iptables -t NAT - A PREROUTING -p TCP -m TCP -- dport 4000 - j DNAT - to - destination 172.31 7.0.x.x: 22

Iptables -t NAT - A POSTROUTING -p TCP -m TCP -- dport 22 - j SNAT - to - source 52.82 7.0.x.x

Empty net table
The iptables -f -t NAT

Check already configured port list
The iptables -t NAT - the list
  • Related