M
M
mrpetersonya2021-03-31 08:31:45
linux
mrpetersonya, 2021-03-31 08:31:45

How to connect to machines with one ip?

Good afternoon.
Please tell me how to solve the issue. There are two machines, one as a vpn server, the second with connected vpn. They get the same ip. How it is possible to be connected on new ip to these machines from outside?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Alexey Dmitriev, 2021-03-31
@SignFinder

If everything is configured correctly, then no - it does not work that they have the same ip.

C
CityCat4, 2021-03-31
@CityCat4

They get the same ip

They can't have the same IP - it just won't work.

S
Sanes, 2021-03-31
@Sanes

Via VPN and connect.

S
S-trace, 2021-03-31
@S-trace

If you have a VPN server with a white IP, and a VPN client behind it with a gray IP (for example, 212.213.214.215 (eth0) is the server, 10.8.0.1 (tun0) is the server behind the VPN, 10.8.0.2 (tun0) is the client ) - you will need to forward the port through iptables on the server in order to connect from the Internet to the computer for VPN.
For example like this:

iptables -t nat -A PREROUTING -d 212.213.214.215/32 -p tcp -m tcp --dport 62000 -j DNAT --to-destination 10.8.0.2:62000
iptables -t nat -A PREROUTING -d 212.213.214.215/32 -p udp -m udp --dport 62000 -j DNAT --to-destination 10.8.0.2:62000
iptables -t nat -A POSTROUTING -d 10.8.0.2/32 -p tcp -m tcp --sport 62000 -j SNAT --to-source 212.213.214.215:62000
iptables -t nat -A POSTROUTING -d 10.8.0.2/32 -p udp -m udp --sport 62000 -j SNAT --to-source 212.213.214.215:62000

And turn off rp_filter on your computer:
for i in /proc/sys/net/ipv4/conf/*/rp_filter ; do echo 0 > $i ; done
sed -i 's/net.ipv4.conf.default.rp_filter=2/net.ipv4.conf.default.rp_filter=0/g' /etc/sysctl.d/10-network-security.conf
sed -i 's/net.ipv4.conf.all.rp_filter=2/net.ipv4.conf.all.rp_filter=0/g' /etc/sysctl.d/10-network-security.conf

After all this, if everything is done correctly - connecting to 212.213.214.215:62000 from the Internet, the request will be forwarded to 10.8.0.2:62000 and if someone listens to this IP and port on the VPN client, he will accept this request and be able to answer.

F
Fenrir89, 2021-04-01
@Fenrir89

I also connect to vpn and get an internal network address

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question