OpenWrt Forum Archive

Topic: WAN aliases, multiple IPs for an interface

The content of this topic has been archived on 28 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I'm trying to assign 3 public IP addresses to my WAN interface (eth0.1). What I'm trying to do is route traffic to a OpenWrt for VPN, a web server, and an SFTP server using Port Forwards. I have my Port Forwards set up and if I change the IP of my WAN interface to match the Port Forward, traffic is forwarded to the server with the corresponding private IP address. So, I know my forwards work.

I have tried numerous methods as listed below.

Round 1: (this one works until I reload networking or reboot, then only the first IP address is recognized)

config interface 'wan'
        option ifname 'eth0.2'
        option proto 'static'
        option netmask '255.255.255.248'
        option gateway '50.243.171.110'
        option dns '8.8.8.8 8.8.4.4'
        list ipaddr '50.243.171.109'
        list ipaddr '50.243.171.107'
        list ipaddr '50.243.171.105'

Round 2: (total failure)

config interface 'wan'
        option ifname 'eth0.2'
        option proto 'static'
        option netmask '255.255.255.248'
        option gateway '50.243.171.110'
        option dns '8.8.8.8 8.8.4.4'
        option ipaddr '50.243.171.109'

config interface 'wan1'
        option ifname 'eth0.2'
        option proto 'static'
        option ipaddr '50.243.171.107'

config interface 'wan2'
        option ifname 'eth0.2'
        option proto 'static'
        option ipaddr '50.243.171.105'

Round 3: (yet another total failure)

config interface 'wan'
        option ifname 'eth0.2'
        option proto 'static'
        option type 'bridge'
        option netmask '255.255.255.248'
        option gateway '50.243.171.110'
        option dns '8.8.8.8 8.8.4.4'
        option ipaddr '50.243.171.109'

config interface 'wan1'
        option ifname 'eth0.2:1'
        option proto 'static'
        option ipaddr '50.243.171.107'

config interface 'wan2'
        option ifname 'eth0.2:2'
        option proto 'static'
        option ipaddr '50.243.171.105'

Not sure if I'm missing something. Do I need any additional packages installed to achieve this? Or am I just doing it completely wrong.

Thanks in advance!!

you need to install kmod-macvlan and ip package and add new interfaces binded to that wan interface you had

here's what Ive done

ip link add link eth0.1 eth20 type macvlan

eth0.1 is my wan interface and eth20 is a virtual interface binded to eth0.1

after that, go to Interface page on luci and add a new interface with the corresponding new interface you created.

take note: make sure to add those on your startup since this configuration doesnt survive at reboot.

(Last edited by remlei on 4 Jun 2016, 08:46)

thank you for your response.

i had to re-make my image to include kmod-macvlan as it wouldn't install with a kernel dependency error. since my wan interface is on eth0.2 this is what i ran:

ip link add link eth0.2 eth20 type macvlan

i then added a new interface using eth20 with a public IP and netmask, but i'm still unable to connect to server from the internet. is there a way to troubleshoot this? I did not receive any errors during the build.

^make sure to change the mac address also on that virtual interface or it will be just a mac address that is full of zeroes., just google for a site that can generate a mac address for you.

and also adjust your firewall setting, just for a test you can temporarily assign it on your wan firewall.

(Last edited by remlei on 5 Jun 2016, 12:46)

The discussion might have continued from here.