A
A
Arthur2015-06-08 16:45:58
ubuntu
Arthur, 2015-06-08 16:45:58

How to enable two external addresses on the server?

Hello.
There is a server with Ubuntu Server 14.04. There are 4 interfaces on the server. One interface for the internal network, two for external addresses.
All three addresses need to be pinged. The problem is that when I register a route for one external, the ping to another one drops :(.
There are no problems with the local address - it pings perfectly.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Softer, 2015-06-08
@deleted-fromStark

I did something like this: (at the beginning, tables T1 and T2 are written in /etc/iproute2/rt_tables)
Variables -
LOCAL=local network
LOCAL_GW=IP in the local network
LOCAL_ETH=Local interface
I1_ETH/I1_GW/I1_IP - interface, gateway and IP on the interface
Similarly for the 2nd.
I tore it out of the working script (table 4 now;) ) - maybe I missed something. :)

ip route flush table T1   #обнуляем первую таблицу маршрутов
ip route flush table T2   #обнуляем вторую таблицу маршрутов
ip rule delete table T1   #удаляем наши таблицы, если они присутствуют в текущей конфигурации (вдруг мы просто перезапускаем скрипт?)
ip rule delete table T2   #аналогично для второй.

ip rule add from $I1_IP table T1
ip route add $LOCAL            src $LOCAL_GW       dev $LOCAL_ETH      table T1
ip route add default           via $I1_GW                              table T1    metric 1000
ip route add default           via $I2_GW                              table T1    metric 1200
ip rule  add fwmark 1          table T1   #все пакеты, которые имеют метку 1 маршрутизировать по таблице T1

ip rule add from $I2_IP table T2
ip route add $LOCAL             src $LOCAL_GW      dev $LOCAL_ETH      table T2
ip route add default           via $I2_GW                              table T2    metric 1000
ip route add default           via $I1_GW                              table T2    metric 1200
ip rule  add fwmark 2          table T2   #все пакеты, которые имеют метку 2 маршрутизировать по таблицу T2

iptables -t mangle -N I2_RULE
iptables -t mangle -A I2_RULE -i $I1_ETH -j CONNMARK --set-mark 1
iptables -t mangle -A I2_RULE -i $I2_ETH -j CONNMARK --set-mark 2
iptables -t mangle -A FORWARD -m state --state NEW -j I2_RULE
iptables -t mangle -A PREROUTING -m state --state ESTABLISHED -j CONNMARK --restore-mark

V
Vlad Zhivotnev, 2015-06-10
@inkvizitor68sl

habrahabr.ru/post/54748 here (and in the comments to the article) there is most of the necessary information.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question