0

been fighting on this configuration for too long.

Let say a public IP : 1xx.24.184.yy/32 Let say a private network : 10.184.yy.0/28 gw 10.184.yy.3

Now I would like my public IP routed via the gateway

What is the good configuration ? ip addr and ip route

10
  • You'll need to provide a bit more detail as to what you are trying to do here. I think you want to be able to access your public IP from your LAN, but I'm not certain that's what you're asking. In any case, what device do you have firewalling your public IP? Many firewalls will prevent you from accessing the outside IP from the inside network. May 23, 2019 at 13:51
  • 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever
    – Gilles
    May 24, 2019 at 9:25
  • 2: enp0s31f6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether e0:d5:5e:xx:xx:xx brd ff:ff:ff:ff:ff:ff inet 10.185.114.zz/28 brd 10.185.114.15 scope global enp0s31f6 valid_lft forever preferred_lft forever
    – Gilles
    May 24, 2019 at 9:25
  • 3: dummy0: <BROADCAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000 link/ether 42:60:50:xx:xx:xx brd ff:ff:ff:ff:ff:ff inet 1xx.24.184.yy/24 brd 1xx.24.184.255 scope global dummy0 valid_lft forever preferred_lft forever
    – Gilles
    May 24, 2019 at 9:25
  • gilles@dev:/opt/xxxx2$ ip route 10.185.114.0/28 dev enp0s31f6 proto kernel scope link src 10.185.114.zz 169.254.0.0/16 dev enp0s31f6 scope link metric 1000 1xx.24.184.0/24 dev dummy0 proto kernel scope link src 1xx.24.184.xx
    – Gilles
    May 24, 2019 at 9:26

1 Answer 1

0

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
  • Enable the interface
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
1
  • See my comments above after applying your configuration. I probably missed something. Thanks
    – Gilles
    May 24, 2019 at 9:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .