1 (edited by Oleg2339798 2017-03-20 15:24:08)

Topic: [SOLVED]2 external IP by one cable

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

Re: [SOLVED]2 external IP by one cable

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

Re: [SOLVED]2 external IP by one cable

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

4 (edited by ulmwind 2017-03-16 23:24:27)

Re: [SOLVED]2 external IP by one cable

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.

Re: [SOLVED]2 external IP by one cable

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.

6 (edited by mk24 2017-03-16 23:46:23)

Re: [SOLVED]2 external IP by one cable

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.

Re: [SOLVED]2 external IP by one cable

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

Re: [SOLVED]2 external IP by one cable

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).

9 (edited by ulmwind 2017-03-17 00:02:24)

Re: [SOLVED]2 external IP by one cable

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...

?

Re: [SOLVED]2 external IP by one cable

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 ?

11 (edited by Oleg2339798 2017-03-17 00:23:06)

Re: [SOLVED]2 external IP by one cable

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

Re: [SOLVED]2 external IP by one cable

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'

Re: [SOLVED]2 external IP by one cable

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

Re: [SOLVED]2 external IP by one cable

What about example from manual above?

Re: [SOLVED]2 external IP by one cable

ulmwind wrote:

What about example from manual above?

the same

Re: [SOLVED]2 external IP by one cable

Bring sections from config for wan1 and wan2.

Re: [SOLVED]2 external IP by one cable

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.

Re: [SOLVED]2 external IP by one cable

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

Re: [SOLVED]2 external IP by one cable

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

20 (edited by remlei 2017-03-18 09:39:59)

Re: [SOLVED]2 external IP by one cable

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.

Re: [SOLVED]2 external IP by one cable

remlei wrote:

just use the "ip link add link " command


Virtual ports should be displayed in the ifconfig?

Re: [SOLVED]2 external IP by one cable

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.

Re: [SOLVED]2 external IP by one cable

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'

24 (edited by mk24 2017-03-18 23:05:54)

Re: [SOLVED]2 external IP by one cable

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.

25 (edited by Oleg2339798 2017-03-19 07:56:38)

Re: [SOLVED]2 external IP by one cable

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