OpenWRT routers: Difference between revisions
Appearance
Content deleted Content added
Flesh out the instructions Tags: Mobile edit Mobile web edit |
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. |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
For |
For CityFibre FTTP connections, a WAN VLAN ID of 911 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. |
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. |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
option vlan '2' |
|||
option ports '0t 1t' |
|||
option vid '911' OR '101' |
|||
Without WAN VLAN: |
|||
config device |
|||
option name 'eth0.2' |
|||
| ⚫ | |||
| ⚫ | |||
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'' |
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 ' |
option vid 'nnn' (911 or 101) |
||
option name ' |
option name 'wan.nnn' (911 or 101) |
||
And for both non VLAN and VLAN configurations: |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
config interface 'wan' |
config interface 'wan' |
||
option device ' |
option device 'wan' OR 'wan.nnn' |
||
option proto 'pppoe' |
option proto 'pppoe' |
||
option username ' |
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. |
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. |
||
| ⚫ | |||
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 = |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | 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). |
||
| ⚫ | |||
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 ' |
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 |
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 |
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. |
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. |
||
=== |
=== 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 |
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: |
IPv6: 2001:8b0:xyz:4520::1/64 |
||
It's the ''ip6assign'' option in the config for the lan which determines that the lan |
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 = |
|||
| ⚫ | |||
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. |
|||
| ⚫ | |||
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. |
|||
| ⚫ | |||
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. |
|||
| ⚫ | |||
| ⚫ | |||
= Advanced configuration of the local network = |
= Advanced configuration of the local network = |
||