Topic: aliases

What is the difference between:

config interface 'wan'
    option ifname 'eth0.1'
    option proto 'dhcp'

config alias
    option interface 'wan'
    option proto 'static'
    option ipaddr '192.168.10.100'
    option netmask '255.255.255.0'
    option layer '1'
config interface 'wan'
    option ifname 'eth0.1'
    option proto 'dhcp'

config 'interface' 'wan_1'
        option 'ifname' 'eth0.1:1'
        option 'proto' 'static'
        option 'ipaddr' '192.168.10.100'
        option 'netmask' '255.255.255.0'

The first "just" adds a second IP address to eth0.1. Ifconfig doesn't even show it. Only ip. The second should create an interface called eth0.1:1. This is also showed by ifconfig.

I think we need this to access a DOCSIS-Router (It is supposed to have a fancy web-interface) from behind NAT. With SNAT:

iptables -t nat -A POSTROUTING -o $IF_WAN -j MASQUERADE
iptables -t nat -A POSTROUTING -o $IF_WAN2 -s 192.168.1.157 -d 192.168.10.72 -j SNAT --to-source 192.168.10.100

Re: aliases

The "config alias" approach is deprecated, it used to be needed when multiple interfaces sharing the same device where not supported.

Re: aliases

Than you, for your support., I updated the wiki: http://wiki.openwrt.org/doc/uci/network#aliases

Re: aliases

Good, for updating the Wiki :-)

Re: aliases

Is that also the right syntax for virtual interface on the lan side? I tried the following but openwrt didn't create any additional alias interface for "lan2":

config interface lan
        option ifname 'eth0.1'
        option type 'bridge'
        option proto 'static'
        option ipaddr '192.168.1.5'
        option netmask '255.255.255.0'

config interface lan2
        option ifname 'eth0.1:1'
        option proto 'static'
        option ipaddr '192.168.2.5'
        option netmask '255.255.255.0'

Re: aliases

eth0.1 is a bridge member so you cannot assign IPs to it, use something like:

config interface lan
        option ifname 'eth0.1'
        option type 'bridge'
        option proto 'static'
        option ipaddr '192.168.1.5'
        option netmask '255.255.255.0'

config interface lan2
        option ifname 'br-lan:1'
        option proto 'static'
        option ipaddr '192.168.2.5'
        option netmask '255.255.255.0'

Re: aliases

Is this hardware specific? The suggestion didn't create any additional interface and this is the ifstatus result:

# ifstatus lan2
{
    "up": false,
    "pending": false,
    "available": false,
    "autostart": true,
    "proto": "static",
    "device": "br-lan:1",
    "data": {
        
    }
}

I'm trying to avoid VLAN because routing is slow on the netgear hardware but I want to run two sets of IP address in LAN.

Re: aliases

remove the :1

9 (edited by phuque99 2013-06-07 13:55:03)

Re: aliases

jow wrote:

remove the :1

Thanks and that kinda work. There's a new 192.168.2.5 IP address in the router.  However there isn't a new "interface" created for "lan2" that I can see with ifconfig. It is still associated with br-lan:

# netstat -nr
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         196.196.64.1    0.0.0.0         UG        0 0          0 eth1
196.196.64.0    0.0.0.0         255.255.192.0   U         0 0          0 eth1
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 br-lan
192.168.2.0     0.0.0.0         255.255.255.0   U         0 0          0 br-lan

Is there any other way to actually create an virtual interface with different IP and interface name?

Edit:
This is what I'm trying to achieve: https://forum.openwrt.org/viewtopic.php?pid=66096#p66096

Re: aliases

ifconfig eth0.1:1 192.168.2.1/24

works even if eth0.1 is part of a bridge!

Re: aliases

It seams you can create a real alias interface, that is a virtual interface and give that an ip address. But you can also assign multiple ip addresses to an interface without creating an additional alias interface.

Re: aliases

Or only ifconfig displays them aliases as ethx:y.
ip a l or ip r l does not.

13 (edited by phuque99 2013-06-07 14:31:58)

Re: aliases

kirschwasser wrote:

It seams you can create a real alias interface, that is a virtual interface and give that an ip address. But you can also assign multiple ip addresses to an interface without creating an additional alias interface.

The actual reason why I *want* additional interfaces is because I have 2 IPv6 prefixes. And I want to have both prefixes explicitly on separate virtual interfaces to avoid confusing RA daemon. I was able to achieve that VLANs. Unfortunately there is a driver issue with Netgear switch that causes slow VLAN routing.

14

Re: aliases

kirschwasser wrote:
ifconfig eth0.1:1 192.168.2.1/24

works even if eth0.1 is part of a bridge!

Sure it "works" but it will never receive any traffic smile

15

Re: aliases

kirschwasser wrote:

It seams you can create a real alias interface, that is a virtual interface and give that an ip address. But you can also assign multiple ip addresses to an interface without creating an additional alias interface.

The underlying concept is 100% identical. That additional alias interface isn't actually an interface but just a label for an additional ip.

16

Re: aliases

phuque99 wrote:

Is there any other way to actually create an virtual interface with different IP and interface name?

For what purpose? Whats wrong with having multiple IPs on one iface?

Re: aliases

I have 2 IPv6 link and prefixes:

1. Hurricane Electric with fixed prefix (lower performance because it's 6in4 to a further end point)
2. My ISP's with *dynamic* prefix, with good performance


Goals:

1. Public accessible server machines will be assigned HE's fix prefixes for obvious reason
2. Client PCs, Mac, tablets etc will be assigned ISP's dynamic prefix via RA for better performance

If I have both prefixes in the same br-lan, HE's prefix usually get assigned first (because it is static), followed by the dynamic one obtained by odhcp6c from wan6. Both radvd and 6relayd will always pickup the "first" v6 prefix to advertise, the HE's one. Neither 6relayd nor radvd allows selection of prefixes. That's why I'm trying use virtual network interfaces to separate them and have 6relayd/radvd use only that interface with ISP's dynamic prefix.