Multiple public ip s on the same interface

So as the title says, i need a way to handle multiple ip addresses on one phisical interface

I found this wich dosent help: How to assign multiple IPs to the same interface?

Why i need to do this? I need it becuse my isp providers me with 5 public ip in my subscription
And i wanna use them my goal is to make 1 phisical conection to get multiple ip addresses, and to route them using firewall/ip tables

So lets say xxx.xxx.xxx.001 routers to server 1
And xxx.xxx.xxx.002 routers to server 2

In that mind these ip addresses are public
What i tried was to brige the wan port with 2vlans and i set them unmanaged, and the create 2 interfaces wich are the vlans trying to get ip from the dhcp

Without success if anyone has recomendetions Please help

sorry, not answering your question, but why ?

I Explain it in the post...

you explained what, not why.

have a look at https://openwrt.org/docs/guide-user/network/routing/pbr

1 Like
Why i need to do this? I need it becuse my isp providers me with 5 public ip in my subscription
And i wanna use them my goal is to make 1 phisical conection to get multiple ip addresses, and to route them using firewall/ip tables 

Are the IPs static? If yes you can simply use CIDR list notation:

config interface wan
  option proto static
  option ifname …
  option gateway a.b.c.1
  option dns 8.8.8.8
  list ipaddr a.b.c.d/24
  list ipaddr x.y.z.1/32
  list ipaddr x.y.z.2/32
  list ipaddr x.y.z.3/32
  list ipaddr x.y.z.4/32
  list ipaddr x.y.z.5/32

Or is your ISP handing out those additional IPs via DHCP? In this case install kmod-macvlan, configure five additional macvlan wan devices based off your original wan device and configure them as additional DHCP interfaces assigned to the wan zone.

In case the main wan IP is served via DHCP and the additional ones are statically allocated, then keep the original DHCP wan interface and configure a second wan interface with alias @wan and static CIDR list notation:

config interface wan
  option proto dhcp
  …

config interface wanextra 
  option proto static
  option device @wan
  list ipaddr x.y.z.1/32
  list ipaddr x.y.z.2/32
  list ipaddr x.y.z.3/32
  list ipaddr x.y.z.4/32
  list ipaddr x.y.z.5/32

They are all served using dhcp, with no mac filter
or anything like that

Is there a way to create virtual interface that make req to the isp dhcp and get their own public ip's

With the goal being evry virtual interface to have its own firewall zone so i can manage them using ip tables

Yes, as I wrote, declare MACVLAN devices. Configuration would look like this:

# the existing default wan interface
config interface wan
  option proto dhcp
  option device eth0  # this might differ
  ...

# declarations for MACVLAN devices
config device
  option type macvlan
  option ifname eth0     # set to the same value as wan
  option name wanalias1  # you can freely chose this

config device
  option type macvlan
  option ifname eth0     # set to the same value as wan
  option name wanalias2  # you can freely chose this

config device
  option type macvlan
  option ifname eth0     # set to the same value as wan
  option name wanalias3  # you can freely chose this

config device
  option type macvlan
  option ifname eth0     # set to the same value as wan
  option name wanalias4  # you can freely chose this

config device
  option type macvlan
  option ifname eth0     # set to the same value as wan
  option name wanalias5  # you can freely chose this

# declarations for additional wan interfaces using the MACVLAN devices
config interface wan1
  option proto dhcp
  option defaultroute 0    # we don't want to replace the main default route
  option peerdns 0         # we don't want DNS information
  option device wanalias1  # use first MACVLAN device

config interface wan2
  option proto dhcp
  option defaultroute 0
  option peerdns 0
  option device wanalias2

config interface wan3
  option proto dhcp
  option defaultroute 0
  option peerdns 0
  option device wanalias3

config interface wan4
  option proto dhcp
  option defaultroute 0
  option peerdns 0
  option device wanalias4

config interface wan5
  option proto dhcp
  option defaultroute 0
  option peerdns 0
  option device wanalias5
1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.