V
V
Vasiliy Adminko2015-11-14 13:18:33
iptables
Vasiliy Adminko, 2015-11-14 13:18:33

How to open port 80 for 2 providers?

Good afternoon.
We have a gateway on Ubuntu 10.04 OS.
2 providers are connected to it, for channel reservation.
There is a web server on the local network behind the gateway with the address 192.168.1.10 .
In the firewall 80 rules, the port for the web server is forwarded.
The web server is accessible to the world only via the IP of one of the providers.
Is it possible to simultaneously open access to the web server with the address 192.168.1.10 on two external IPs 176.xxx and 212.yyy using the gateway?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
alegzz, 2015-11-14
@alegzz

can

V
Vladimir, 2015-11-16
@rostel

let's say on interface vlan10 176.xxx, on vlan20 212.yyy, 192.168.1.10 is behind eth0
add to /etc/iproute2/rt_tables

101 prov1
102 prov2

execute
# ip rule add from all fwmark 0x1 lookup prov1
# ip rule add from all fwmark 0x2 lookup prov2

# iptables -t mangle -A PREROUTING -i vlan10 -m conntrack --ctstate NEW -j CONNMARK --set-mark 0x1
# iptables -t mangle -A PREROUTING -i vlan20 -m conntrack --ctstate NEW -j CONNMARK --set-mark 0x2
# iptables -t mangle -A PREROUTING -i eth0 -m conntrack --ctstate ESTABLISHED -j CONNMARK --restore-mark

# iptables -t nat -A PREROUTING -i vlan10 -p tcp -m tcp --dport 80 -j DNAT --to-destination 192.168.1.10:80
# iptables -t nat -A PREROUTING -i vlan20 -p tcp -m tcp --dport 80 -j DNAT --to-destination 192.168.1.10:80

# iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o vlan10 -j SNAT --to-source 176.x.x.x
# iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o vlan20 -j SNAT --to-source 212.y.y.y

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

V
Vladimir, 2015-11-14
@MechanID

You can:
1 simply add 1 more ip address to the web server with the address 192.168.1.10, add a virtual host to it and forward the 80th port to it from another provider. (this address should go to the Internet from a different provider)
2 Or you will have to delve into the problem: now you most likely have a simple NAT and routing on the gateway (a couple of tables in each default gateway) - and the rules for this network or IPs through the 1st provider and others through others, so even if packets come from a different provider on port 80, they still go through the 1st provider and nothing works, you can solve the problem by reading LARTC and the docks on iptables iproute2. but there are many things that are not obvious, fun adventures with tcpdump are guaranteed to you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question