Jump to content

This is the support site for Andrews & Arnold Ltd, a UK Internet provider. Information on these pages is generally for our customers but may be useful to others, enjoy!

OpenWRT routers: Difference between revisions

Content deleted Content added
Adsb (talk | contribs)
Flesh out the instructions
Tags: Mobile edit Mobile web edit
Adsb (talk | contribs)
Packages
Tags: Mobile edit Mobile web edit
 
(14 intermediate revisions by the same user not shown)
Line 26: Line 26:
== VLANs ==
== VLANs ==


It's easy for new OpenWrt users to get confused by VLANs. On some routers the WAN and LAN are configured as separate VLANs on one Ethernet. So you can see the LAN defined as ''eth0.1'' and the WAN as ''eth0.2''
It's easy for new OpenWrt users to get confused by VLANs. On some routers the WAN and LAN are configured as separate VLANs on one Ethernet. So you can see the LAN defined as ''eth0.1'' and the WAN as ''eth0.2'' (where the number after the dot is the VLAN id number).


A recent change to OpenWrt has affected configuration of the network switch, so there are two possible ways the switch is configured.
Then the PPPoE instance on the WAN may need to be configured to be on a VLAN because of the carrier's requirements, but this VLAN is separate from the router hardware configuration.


Then the PPPoE instance on the WAN may need to be configured to be run over a VLAN because of the carrier's requirements, but this VLAN my be separate from the router hardware configuration.
For CityFibre connections, a VLAN ID of 911 is needed.


For VDSL connections, a VLAN ID of 101 is needed.
For CityFibre FTTP connections, a WAN VLAN ID of 911 is needed.


For VDSL connections, a WAN VLAN ID of 101 is needed.
Openreach FTTP does not need a VLAN.

Openreach FTTP does not need a WAN VLAN.


ADSL users need an ADSL modem. OpenWrt doesn't support many of the modems built into normal consumer ADSL router/modems. If using an external modem then no VLAN is needed.
ADSL users need an ADSL modem. OpenWrt doesn't support many of the modems built into normal consumer ADSL router/modems. If using an external modem then no VLAN is needed.

== On older "swconfig" versions ==

OpenWrt prior to version 21 had the "Network", "Switch" menu in Luci, and older switch configuration software. Some hardware is still using this older software even in version 24.
* Delete any wan6 interface under "Network", "Interfaces"
* If needing a WAN VLAN, go to "Network", "Switch" and you should see two VLANs defined: VLAN 1 for the LAN ports, and VLAN 2 for the WAN port. Change VLAN 2 to be numbered VLAN 911 or 101 as required. Change this VLAN on the WAN port from untagged to tagged. Save and Apply.
* Under "Network", "Interfaces" edit the wan interface. Change the protocol to PPPoE. Device should be "eth0.2" if you're not using a VLAN, or "eth0.911" or "eth0.101" if you are. Enter your AAISP username and password. Under "Advanced settings", set "Obtain IPv6 address" to automatic, tick "Use default gateway". Under DHCP server, ignore this interface.
* Save and apply, then restart the wan interface
* The wan and wan_6 interfaces should now come up online

The appropriate entries in ''/etc/config/network'' will look like the following.

With WAN VLAN:

config switch_vlan
option device 'switch0'
option vlan '2'
option ports '0t 1t'
option vid '911' OR '101'
Without WAN VLAN:

config device
option name 'eth0.2'
option macaddr 'aa.bb.cc.dd.ee.ff'

And for both configurations:

config interface 'wan'
option device 'eth0.2' OR 'eth0.911' OR 'eth0.101'
option proto 'pppoe'
option username 'xxnn@a.1'
option password 'ItIsASecret'
option ipv6 'auto'

== On new "Distributed Switch Architecture" versions ==

Newer versions of OpenWrt do not have the "Network", "Switch" menu in Luci. To configure this version in Luci:
* Delete any wan6 interface under "Network","Interfaces"
* If needing a WAN VLAN, go to "Network","Interfaces","Devices". "Add device configuration", select device type "VLAN (801.1q)", base device "Switch port: wlan", "VLAN ID" 911 or 101 as required. This will create a device named "wan.911" or "wan.101". Save.
* Under "Network", "Interfaces" edit the wan interface. Change the protocol to PPPoE. Device should be "wan" if you're not using a VLAN, or "wan.911" or "wan.101" if you are. Enter your AAISP username and password. Under "Advanced settings", set "Obtain IPv6 address" to automatic, tick "Use default gateway". Under DHCP server, ignore this interface.
* Save and apply, then restart the wan interface
* The wan and wan_6 interfaces should now come up online
The appropriate entries in ''/etc/config/network'' will look like the following.
The appropriate entries in ''/etc/config/network'' should look like the following. If you do not have Luci installed, make these edits to "/etc/config/network".


With VLAN:
With VLAN:
Line 45: Line 90:
option type '8021q'
option type '8021q'
option ifname 'wan'
option ifname 'wan'
option vid '911' OR '101'
option vid 'nnn' (911 or 101)
option name 'vlan0'
option name 'wan.nnn' (911 or 101)


And for both non VLAN and VLAN configurations:
Without VLAN:
config device
option name 'eth0.2'
option macaddr 'aa.bb.cc.dd.ee.ff'


And for both configurations:
config interface 'wan'
config interface 'wan'
option device 'vlan0' OR 'eth0.2'
option device 'wan' OR 'wan.nnn'
option proto 'pppoe'
option proto 'pppoe'
option username 'XXXX@a.1'
option username 'xxnn@a.1'
option password 'ItIsASecret'
option password 'ItIsASecret'
option ipv6 'auto'
option ipv6 'auto'


Do not have an interface named ''wan6'', the IPv6 configuration will be handled automatically.
Do not have an interface named ''wan6'', the IPv6 configuration will be handled automatically.
The ''option ipv6 auto'' line will cause a virtual interface named ''wan_6'' to be created, and an instance of the DHCPv6 client to be run on it. This will request an IPv6 Internet address, and a single Prefix to be Delegated. You can't get the DHCPv6 client started this way to accept more options. In order to use the delegated prefix, the LAN should be configured to expect it, e.g.:
The ''option ipv6 auto'' line will cause a virtual interface named ''wan_6'' to be created, and an instance of the DHCPv6 client to be run on it. This will request an IPv6 Internet address, and a single Prefix to be Delegated. You can't get the DHCPv6 client started this way to accept more options.


= Routed IPv4 addresses in the local network =

AAISP offer a block of up to 8 routed IPv4 addresses to customers. These can be configured on the lan interface instead of RFC1918 addresses, but you will have to change the firewall config. By default 2 firewall zones are created - wan and lan, and masquerading is done on the wan zone. The masquerading should be turned off for routed lan addresses - "Network", "Firewall", edit "wan" zone, untick masquerading.

= Enabling IPv6 in the local network =

OpenWrt fully supports IPv6, as well as IPv4 and dual stacks to enable the mix of both protocols.

The easiest approach is to use prefix delegation from the WAN to provide the network address. This is achieved by configuration of the ''wan'' interface to obtain the IPv6 address automatically, and to delegate IPv6 addresses downstream. This is achieved through a virtual wan_6 interface.

Then on the ''lan'' interface Advanced settings configure the IPv6 prefix filter to ''wan_6'' and set the IPv6 assignment length to 64. There is a choice of the suffix to append to the prefix - popular choices would be ''::1'' (to use that fixed value), or ''eui64'' (to use an address based on the MAC address).

There is the possibility of running a NAT64 server on OpenWrt, so the local network can use only IPv6 but hosts on it can still reach IPv4 hosts on the Internet.

For prefix delegation to the lan interface, "/etc/config/network" should look like:
config interface 'lan'
config interface 'lan'
option device 'br-lan'
option device 'br-lan'
option proto 'static'
option proto 'static'
option defaultroute '1'
option defaultroute '1'
list ipaddr '81.187.xx.yy/zz'
list ipaddr '192.168.1.1/24'
list ip6class 'wan_6'
list ip6class 'wan_6'
option ip6ifaceid 'eui64'
option ip6ifaceid 'eui64'
option ip6assign '64'
option ip6assign '64'


The ''list ip6class wan_6'' line causes the lan to use the delegated prefix from wan_6. ''option ip6ifaceid eui64'' makes the local IPv6 address on the lan use the 64 bits derived from the MAC address as the suffix (you might choose to use ''::1'' instead). ''option ip6assign 64'' defines the netmask associated with the prefix delegation.
The ''list ip6class wan_6'' line causes the lan to use the delegated prefix from wan_6. ''option ip6ifaceid ::1'' makes the local IPv6 address on the lan use ::1 as the 64 bit suffix (you might choose to use ''eui64'' instead to use the 64 bits derived from the MAC address as the suffix). ''option ip6assign 64'' defines how many bits are taken from the wan_6 prefix delegation.


== Multiple routed IPv6 /64 blocks ==
== Multiple routed IPv6 /64 blocks ==
Line 79: Line 135:
There's a gotcha for users who have multiple /64 blocks routed to them by AAISP. Current versions of OpenWrt use Policy-Based Routing (PBR) which allows routing to be configured according to multiple rules, not just by destination address.
There's a gotcha for users who have multiple /64 blocks routed to them by AAISP. Current versions of OpenWrt use Policy-Based Routing (PBR) which allows routing to be configured according to multiple rules, not just by destination address.


If DHCPv6 is used to request Prefix Delegation (PD), AAISP will reply with one block. OpenWrt uses this to set the LAN address and netmask, and then enables routing from '''just this block''' from LAN to WAN. If you have multiple /64 blocks, any other /64 blocks routed to you won't be able to send packets to the Internet.
If DHCPv6 is used to request Prefix Delegation (PD) with the virtual wan_6 interface, AAISP will reply with one block which will normally be a /64. OpenWrt uses this to set the LAN address and netmask, and then enables routing from '''just this block''' from LAN to WAN. If you have multiple /64 blocks, any other /64 blocks routed to you by AAISP won't be able to send packets to the Internet.


To quote from [https://openwrt.org/docs/guide-user/network/routing/basics OpenWrt Wiki - Routing basics] ''Note that by default OpenWrt announces IPv6 default route only for GUA and applies source filter for IPv6 that allows routing only for prefixes delegated from the upstream router.''
To quote from [https://openwrt.org/docs/guide-user/network/routing/basics OpenWrt Wiki - Routing basics] ''Note that by default OpenWrt announces IPv6 default route only for GUA and applies source filter for IPv6 that allows routing only for prefixes delegated from the upstream router.''


In my case, I have 2001:8b0:xxxx:4534::/64, ...:4535/64, ...:4536::/64 and ...:4537::/64 routed to me, but only 4534:: is routed back.
In my case, I had 2001:8b0:xxxx:4534::/64, ...:4535/64, ...:4536::/64 and ...:4537::/64 routed to me by AAISP, but only the lowest numbered block - 4534::/64 was routed back.


# ip -f inet6 route
# ip -f inet6 route
Line 94: Line 150:
=== odhcp6c ===
=== odhcp6c ===


Key to understanding the delegation of IPv6 blocks is the DHCPv6 client, which is odhcp6c on OpenWrt.
Key to understanding the delegation of IPv6 blocks is the DHCPv6 client, which is called odhcp6c on OpenWrt.


Looking back at the ''wan'' interface config there is an ''option ipv6'' line. The default value is ''auto'', which has the effect of automatically creating a virtual interface named ''wan_6'' and running odhcp6c on it BUT ignoring any config you may wish to supply. An alternative if multiple /64 blocks are to be used is ''1'' which allows you to configure ipv6 the way you want (static, dhcpv6, ...)
Looking back at the ''wan'' interface config there is an ''option ipv6'' line. The default value is ''auto'', which has the effect of automatically creating a virtual interface named ''wan_6'' and running odhcp6c on it BUT ignoring any extra config you may wish to supply. A possible alternative if multiple /64 blocks are to be used is ''1'' which allows you to configure ipv6 the way you want (static, dhcpv6, ...), but there is a simpler solution.


=== Solutions ===
=== Solution ===


We need a way for the WAN to tell the LAN about the wider routing block, whilst letting the LAN only use for itself the first /64 block.
We need a way for the WAN to tell the LAN about the wider routing block, whilst letting the LAN only use for itself the first /64 block.


This turns out to be remarkably easy. On the AAISP control panel, add a /60 block of IPv6 addresses. When DHCPv6 requests prefix delegation, AAISP returns the lowest number address block - if this is the new /60 then that's what you'll get, otherwise you might have to unroute some or more of the /64 blocks.
This turns out to be remarkably easy. On the AAISP control panel, add a /60 block of IPv6 addresses, and ensure that this is the lowest number address block (in fact, you can probably unroute some or all of your /64 blocks). When DHCPv6 requests prefix delegation, AAISP returns the lowest number address block - if this is the new /60 then that's what you'll be delegated, and you can then split this into up to 16 /64 blocks.


In my case I see for ''wan_6'':
In my case I see for ''wan_6'':
Line 111: Line 167:


And for ''lan'':
And for ''lan'':
IPv6: 2001:8b0:xyz:4520:xxxx:xxxx:xxxx:xxxx/64
IPv6: 2001:8b0:xyz:4520::1/64


It's the ''ip6assign'' option in the config for the lan which determines that the lan uses a /64.
It's the ''ip6assign'' option in the config for the lan which determines that the lan receives a /64.


Now I see:
Now I see:
Line 121: Line 177:
...
...


= Installing packages =
= Enabling IPv6 in the local network =


One of OpenWrt's key features is being able to install extra software packages. For example, you can install a VPN server on the router, or add SFTP support to the SSH server.
OpenWrt fully supports IPv6, as well as IPv4 and dual stacks to enable the mix of both protocols.


On the Luci web interface go to "System","Software", and click "Update lists...". You can then search for and install packages. ''openssh-sftp-server'' might be useful, or the ''nano'' text editor for in-situ changes to the configuration.
The easiest approach is to use prefix delegation from the WAN to provide the network address. This is achieved by configuration of the ''wan'' interface to obtain the IPv6 address automatically, and to delegate IPv6 addresses downstream.


From the command line, ''opkg'' is the tool to manage packages. "opkg update" to update the lists, "opkg find openssh*" to search, "opkg install wireguard-tools" to install.
Then on the ''lan'' interface configure the IPv6 prefix filter to ''wan_6'' and set the IPv6 assignment length to 64. There is a choice of the suffix to append to the prefix - popular choices would be ''::1'' (to use that fixed value), or ''eui64'' (to use an address based on the MAC address).

There is the possibility of running a NAT64 server on OpenWrt, so the local network can use only IPv6 but hosts on it can still reach IPv4 hosts on the Internet.


= Advanced configuration of the local network =
= Advanced configuration of the local network =