OpenWrt Forum Archive

Topic: [SOLVED]2 external IP by one cable

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

Hello, the provider provides me with two dedicated IP addresses. I wanted to configure two gateways on different Ip, but it did not work. I ask for your help.

Firmware version: OpenWrt Chaos Calmer 15.05
Router: D-Link dir300 B5

(Last edited by Oleg2339798 on 20 Mar 2017, 15:24)

I don't understand, does your router works fine with both settings on the same physical cable?

No, it does not work. The problem is that I can not configure it in any way. With one IP, everything works perfectly.

I mean, does it work with SINGLE IP for two cases? You have two sets of IP,GW,MASK. Does it work fine with any set configured on the same physical cable?

For normal configuration two subnets with different IPs should be separated by VLAN. After that you can use mwan3.

(Last edited by ulmwind on 16 Mar 2017, 23:24)

ulmwind wrote:

I mean, does it work with SINGLE IP for two cases? You have two sets of IP,GW,MASK. Does it work fine with any set configured on the same physical cable?

Yes, it works separately with any set.

ulmwind wrote:

For normal configuration two subnets with different IPs should be separated by VLAN. After that you can use mwan3.

I tried to install mwan3, but I do not have enough memory. Can you write how to properly configure the vlan? I tried to do it, but I'm not sure that did it right.

Did you make a second wan network (e.g. 'wan2') and firewall zone?  Then you would make a second lan network (and second lan firewall zone) that forwards to the second wan.  So, logically it is like two routers in one box, with completely separate data flowing on each.

As I understand it you do not want to balance traffic between the two, which is what mwan3 does.

(Last edited by mk24 on 16 Mar 2017, 23:46)

mk24, the issue is how to create two interfaces. Does it allow to create two untagged VLANs in one physical interface?

No, you cannot have two untagged VLANs on the same cable.  You would not do the WAN combining with VLANs.  Just put the same physical, (e.g. eth0) in multiple interfaces (like the wan and wan6 are in a default configuration).

I've expected so.
So in this case we should configure like https://wiki.openwrt.org/doc/uci/networ … _addresses:

config interface wan1
    option ifname eth0
    option proto static ...
config interface wan2
    option ifname eth0
    option proto static...

?

(Last edited by ulmwind on 17 Mar 2017, 00:02)

I'm trying to understand this issue. What's the purpose with the two IP addresses ? Load balancing ? Running two servers ?

Are they on the same subnet ? Do they need to forward to two different gateways to reach the internet ?

AndreL wrote:

Are they on the same subnet ? Do they need to forward to two different gateways to reach the internet ?

Yes. Yes.

I need a different external ip address for the server and my local network

And the server should ideally be in the local network as like now, because It hosts servers for local use also

(Last edited by Oleg2339798 on 17 Mar 2017, 00:23)

config 'interface' 'wan'
        option 'proto'     'static'
        option 'ifname'    'eth0'
        list 'ipaddr'    '192.0.2.101/24'
        list 'ipaddr'    '192.0.2.102/24'

config 'route'
        option 'interface' 'wan'
        option 'target'    '0.0.0.0'
        option 'netmask'   '0.0.0.0'
        option 'gateway'   '192.0.2.1'
        option 'source'    '192.0.2.101'

config 'route'
        option 'interface' 'wan'
        option 'target'    '0.0.0.0'
        option 'netmask'   '0.0.0.0'
        option 'gateway'   '192.0.2.2'
        option 'source'    '192.0.2.102'

AndreL wrote:

config 'interface' 'wan'
        option 'proto'     'static'
        option 'ifname'    'eth0'
        list 'ipaddr'    '192.0.2.101/24'
        list 'ipaddr'    '192.0.2.102/24'

config 'route'
        option 'interface' 'wan'
        option 'target'    '0.0.0.0'
        option 'netmask'   '0.0.0.0'
        option 'gateway'   '192.0.2.1'
        option 'source'    '192.0.2.101'

config 'route'
        option 'interface' 'wan'
        option 'target'    '0.0.0.0'
        option 'netmask'   '0.0.0.0'
        option 'gateway'   '192.0.2.2'
        option 'source'    '192.0.2.102'

Tried these settings, but nothing happened

What about example from manual above?

ulmwind wrote:

What about example from manual above?

the same

Bring sections from config for wan1 and wan2.

If it's one modem with a subscription that provides two public IP addresses, they would both come from the same MAC.

remlei wrote:

use ip macvlan.

here's how: http://www.flexjunk.com/2010/01/06/util … h-openwrt/

with that you can have as many external WAN IP as you want in single interface.

When I create virtual ports, then for some reason they do not write a MAC address

I skipped the commands setting the mac address, I just set it via luci under network tab or uci.network.

Ive tried this before and it works for me, specially that my ISP is DHCP based (even though its static IP assignment), we all know that DHCP hates same MAC address when leasing a IP.

just use the "ip link add link " command
and then login to openwrt luci webpage and go to network
add a new interface, find the interface name you set earlier, then set it up as you like, and dont forget to set a dedicated MAC address for it since the default MAC is all just zeros. I use this to generate mac address for me http://www.miniwebtool.com/mac-address-generator/
once done it should be working as expected.

ps: since your macvlan interface is gone once restarted, just input those command on your startup (see in system >> startup) then all below on custom commands. just put your "ip link add link" command your entered before.

pss: if for some reason that your manual assigned mac address is not displayed on luci (still bunch zeros) restart openwrt will fix this, although this is just a cosmetic issue, since it my test the MAC address did recognized in my test DHCP server with the MAC address that I assigned.

(Last edited by remlei on 18 Mar 2017, 09:39)

remlei wrote:

just use the "ip link add link " command


Virtual ports should be displayed in the ifconfig?

When you first create a port it is in "down" status and can't transfer data.  By default ifconfig only shows ports that are "up".  Use ifconfig -a to show all ports.

Here is how the network is configured, but wan1 can not receive ip on dhcp. The provider has a binding on the current mac


config interface 'loopback'
        option ifname 'lo'
        option proto 'static'
        option ipaddr '127.0.0.1'
        option netmask '255.0.0.0'

config interface 'lan'
        option ifname 'eth0.1'
        option force_link '1'
        option macaddr '1e:7e:e5:e1:3f:f2'
        option type 'bridge'
        option proto 'static'
        option netmask '255.255.255.0'
        option ip6assign '60'
        option ipaddr '192.168.1.1'

config interface 'wan'
        option ifname 'eth0.2'
        option proto 'dhcp'
        option macaddr '8a:97:57:7a:54:6c'

config switch
        option name 'switch0'
        option reset '1'
        option enable_vlan '1'

config switch_vlan
        option device 'switch0'
        option vlan '1'
        option ports '0 1 2 3 6t'

config switch_vlan
        option device 'switch0'
        option vlan '2'
        option ports '4 6t'

config interface 'wan1'
        option ifname 'eth2'
        option proto 'dhcp'
        option macaddr '1c:af:f7:2a:41:ad'
        option defaultroute '0'
        option peerdns '0'
        option gateway '0.0.0.0'

Have you been rebooting the modem after re-configuring the router?  That will sometimes work and be needed to make it take a new MAC,

If the provider is locking the service to a certain MAC address, you'll need to register a pair of MACs with them.  One for each public IP.

Or order static IPs, but that usually costs considerably more.

(Last edited by mk24 on 18 Mar 2017, 23:05)

mk24 wrote:

Have you been rebooting the modem after re-configuring the router?  That will sometimes work and be needed to make it take a new MAC,

If the provider is locking the service to a certain MAC address, you'll need to register a pair of MACs with them.  One for each public IP.

Or order static IPs, but that usually costs considerably more.

I have a static ip. Here are the settings from the provider's website
http://clip2net.com/clip/m275487/08960-clip-35kb.png

(Last edited by Oleg2339798 on 19 Mar 2017, 07:56)

The discussion might have continued from here.