You can assign your public ip address to lo
interface, or better create dummy
interface for this address. Also, your setup requires the routing configuration on the gateway and on further path for usage of the public ip.
Dummy interface configuration:
- Load the kernel module, but don't create default dummy interfaces. You can write the kernel module options into
/etc/modprobe.d/dummy.conf
.
modprobe dummy numdummies=0
- Create the dummy interface
ip link add name dummy0 type dummy
- Assign the public ip address to the dummy interface
ip address add 1xx.24.184.yy/32 dev dummy0
ip link set dev dummy0 up
- Use the public ip as default source address. This step is optional. You can use the binding the application to the public ip to use it.
ip route replace default via 10.184.yy.3 src 1xx.24.184.yy
Read the docs for your linux distro to make the configuration permanent. Otherwise the settings will be lost after reboot.
- Debian persistent configuration (file
/etc/network/interfaces
):
auto dummy0
iface dummy0 inet static
pre-up modprobe dummy numdummies=0
pre-up ip link add name dummy0 type dummy
post-down ip link del dev dummy0
address 1xx.24.184.yy
netmask 255.255.255.255
Loopback interface configuration
- Assign the public ip as additional address on the loopback interface:
ip address add 1xx.24.184.yy/32 dev lo
- Setup the routing (completely like in the previous section)
ip route replace default via 10.184.yy.3 src 1xx.24.184.yy
- Debian persistent configuration (file
/etc/network/interfaces
):
auto lo
iface lo inet loopback
post-up ip address add 100.24.184.10/32 dev lo