0

I have a server with 2 ethernet ports that I would like to configure with multiple gateways.

I want port 1 to be the default gateway and I want traffic coming from port 2 to go out on port 2.

I followed many guides on how to do this but I can't make it work.

Here's the script I'm using on my interfaces file.

# The primary network interface
allow-hotplug eno2
iface eno2 inet dhcp
    gateway 192.168.3.1
    post-up ip route add 192.168.3.0/24 dev eno2 table ethvpn
    post-up ip route add default via 192.168.3.1 dev eno2 table ethvpn
    post-up ip rule add from 192.168.3.101/102 table ethvpn
    post-up ip rule add to 192.168.3.101/102 table ethvpn

# Secondary network interface
allow-hotplug eno3
iface eno3 inet dhcp
    post-up ip route add 192.168.0.0/24 dev eno3 table ethwan
    post-up ip route add default via 192.168.0.1 dev eno3 table ethwan
    post-up ip rule add from 192.168.0.101/102 table ethwan
    post-up ip rule add to 192.168.0.101/102 table ethwan

If I enter : ip rule show , my tables (ethwan, ethvpn) don't show up. If I try to enter this command maunally: ip rule add from 192.168.3.101/102 table ethwan I get the error:

 Error: inet prefix is expected rather than "192.168.3.101/102".

Is it possibly to do this when going with DHCP with reserved IP? How can I make this work?

Machinegon
  • 121
  • 1
  • 6

1 Answers1

2

192.168.0.101/102 is not a valid Subnet. The number after / is the number of bits in the subnet mask. if you want the rule to cover 101 and 102 . Do 2 separate rules for 192.168.101/32 and 192.168.0.102/32

Nath
  • 1,322
  • 9
  • 10