Answer the question
In order to leave comments, you need to log in
How to route outgoing requests through a second IP on the server?
Good day.
There is a server on ubuntu, the server has two external IPs (1.1.1.1 and 2.2.2.2)
in /etc/network/interfaces like this:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 1.1.1.1
netmask 255.255.255.0
network 1.1.1.0
broadcast 1.1.1.255
gateway 1.1.1.254
post-up /sbin/ifconfig eth0:1 2.2.2.2 netmask 255.255.255.0 broadcast 2.2.2.2
post-down /sbin/ifconfig eth0:1 down
Answer the question
In order to leave comments, you need to log in
You need to add the appropriate route:
askubuntu.com/a/252699 It is
better to configure the second address not through post-up, but with a separate rule:
auto eth0
iface eth0 inet static
address 1.1.1.1
netmask 255.255.255.0
gateway 1.1.1.254
auto eth0:1
iface eth0:1 inet static
address 2.2.2.2
netmask 255.255.255.0
up ip route add 3.3.3.3 dev eth0 src 2.2.2.2 via 2.2.2.254 || true
down ip route del 3.3.3.3 || true
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question