Hálózat konfigurációja

A fő hálózati konfigurációs állomány a következő fájlban található: /etc/config/network. Ebben a konfigurációs fájlban vannak a switch VLANok, interfész konfigurációk és hálózati útvonalak beállításai. A /etc/config/network szerkesztése és mentése után futtatni kell a következő parancsot

/etc/init.d/network reload

hogy a hálózatot leállítsuk és újraindítsuk a beállítások érvénybeléptetéséhez. A router újraindítása nem szükséges.

Itt tájékozódhatsz a netifd-ről (Network Interface Daemon).

Az alábbiakban áttekintjük a szekció típusokat, amelyek a hálózati konfigurációkat határozzák meg. Egy router esetében a minimális hálózati konfiguráció általában legalább két interfészt (lan és wan) és egy switch szekciót tartalmaz.

:!: A globális szekció csak a Barrier Breaker és az ez utáni kiadásokban érhető el.

A globals szekció interfész-független, álatlános hálózati beállításokat tartalmaz.

Név Típus Szükséges Alapértelmezett Leírás
ula_prefix IPv6-prefix nem (none) Az eszköz IPv6 ULA-Prefixe

A switch azért felelős, hogy a switch-et több VLANra oszthassuk, melyek egymástól független interfészeknek tűnnek, miközben ugyanazt a hardvert használják. Nem minden OpenWrt-t támogató rendelkezik programozható switchel, ezért ami ebben a fejezetben le van írva, az nem minden platformon elérhető. Vedd figyelembe, hogy néhány kapcsoló csak 4Bit-es VLAN-okat támogat.

Jelenleg két különböző konfigurációs formátum használatos, az egyik a hagyományos /proc/switch/ API, a másik az újabb swconfig-alapú switch konfiguráció.

/proc/switch

Ez a változat csak az olyan Broadcom eszközökön található meg, mint a WRT54GL. Egy tipikus konfiguráció így néz ki:

config 'switch' 'eth0'
        option 'vlan0' '0 1 2 3 5*'
        option 'vlan1' '4 5'

Az eth0 azonosító határozza meg, hogy a switch az eth0 szakaszhoz tartozik. A VLAN-okat vlan# formában határozzuk meg, ahol a # jelöli a VLAN számát. További információkért olvasd el a switch dokumentációt.

swconfig

Az újabb swconfig-keret célja, hogy felváltsa a régi switch konfigurációt.

Az swconfig felépítése minden egyes VLAN hozzáadásával egy picit módosul. VLAN-onként létrejön egy új extra VLAN szekció. Az alábbi példa egy tipikus konfigurációt mutat:

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

config switch_vlan
     option device 'eth0'
     option vlan '1'
     option vid '1'
     option ports '0t 1'

config switch_vlan
     option device 'eth0'
     option vlan '2'
     option vid '2'
     option ports '2 3 4t'

A közös beállítások a switch szekcióban vannak meghatározva; a vlan specifikus beállítások pedig további switch_vlan szakaszokban találhatók, amelyek összefüggésben vannak a switch-el a device opción keresztül. ('eth0') A fenti példa egy TP-Link TL-WR842ND routerből származik. A teljes magyarázat megtalálható a switch dokumentációban.

Az interface típusú szekciók meghatározzák a logikai hálózatok számára az IP-cím beállításokat, álneveket, útvonalakat, fizikai interfészneveket és tűzfal szabályokat - ezek központi szerepet játszanak az OpenWRT konfigurációjának felépítésében. Egy interfész minimális meghatározása a következő sorokat tartalmazza:

config 'interface' 'wan'
        option 'proto' 'dhcp'
        option 'ifname' 'eth0'
  • A wan egy egyedi logikai interfész név
  • A dhcp határozza meg az interfész protokollját, itt a DHCP csak egy lehetséges példa
  • Az eth0 az a fizikai interfész amihez tartozik ez a szekció

Interfész protokollok a következők lehetnek:

Protokoll Leírás Program
static Statikus konfiguráció fix címmel és netmaszkkal ip/ifconfig
dhcp A cím és a netmaszk DHCP-n keresztül van kiosztva udhcpc (Busybox)
dhcpv6 A cím és a netmaszk DHCPv6-n keresztül van kiosztva odhcpc6c
ppp PPP protocol - betárcsázós modem kapcsolathoz pppd
pppoe PPP over Ethernet - DSL szélessávú kapcsolathoz pppd + plugin rp-pppoe.so
pppoa PPP over ATM - DSL beépített modemmel rendelkező DSL kapcs.hoz pppd + plugin ...
3g CDMA, UMTS vagy GPRS kapcsolathoz egy AT-stílusú 3G modemmel comgt
pptp PPtP VPN kapocsolathoz ?
6in4 IPv6-in-IPv4 csatornához használják Tunnel Brokers-el, mint a HE.net ?
6to4 Stateless IPv6 over IPv4 transport ?
none Nincs meghatározva protokoll -

A használt interfész protokolltól függően számos egyéb opció szükséges egy interfész teljes meghatározásához. Az alábbi listában láthatóak a lehetséges opciók mindegyik protokoll esetén. Amelyik opció “igen” értékkel van ellátva a “Szükséges” oszlopban, azt az értéket muszáj beűllítani az interfész szekciójában, ha az adott protokollt használjuk Ha a “Szükséges” oszlopban “nem” érték szerepel, akkor lehetséges az érték megadása, de nem kötelező.

Lehetséges opciók, minden protokoll típusra

Név Típus Szükséges Alapértelmezett Leírás
ifname interface neve(k) igen(*) (none) Fizikai interfész nevét rendeli a szekcióhóz vagy interfészek neveit, ha bridge a típusa. (*) Ez az opció lehet üres, vagy hiányzó, ha csak a vezeték nélküli interfész hivatkozik erre a hálózatra, vagy ha a protokoll típusa pptp, pppoa vagy 6in4
type string nem (none) Ha “bridge”, akkor egy híd jön létre, amely tartalmazza az interfész neveket amelyekből áll
A Wlan nevek előre nem meghatárózhatók, ezért nem hivatkozhatunk rájuk közvetlenül a konfigurációban
stp boolean nem 0 Csak “bridge” típus esetén érvényes, engedélyezi a feszítőfa (STP) protokollt
bridge_empty boolean nem 0 Csak “bridge” típus esetén érvényes, engedélyezi az üres hidak létrehozását
macaddr mac address nem (none) Felülírja az adott interfész MAC címét
mtu number nem (none) Felülírja az alapértelmezett MTU-t az interfészen
auto boolean nem 0 ha a proto none, egyébként 1 Megadja, hogy az interfész kapcsoljon be bootoláskor
accept_ra boolean nem 1 ha a protocol dhcp, egyébként 0 elavult: Megadja, hogy az interfész fogadja-e az IPv6 Router Advertisement kereteket (12.09 és korábbi verziók esetén)
send_rs boolean nem 1 for protocol static, else 0 elavult: Megadja, hogy az interfészen legyen-e fogadva Router Solicitations keret (12.09 és korábbi verziók esetén)

Protocol "static"

Név Típus Szükséges Alapértelmezett Leírás
ipaddr ip-cím igen, ha nincs ip6addr beállítva (none) IP-cím
netmask netmaszk igen, ha nincs ip6addr beállítva (none) Alhálózati maszk
gateway ip-cím nem (none) Alapértelmezett átjáró
broadcast ip-cím nem (none) Szórási cím (automatikusan generált, ha nincs beállítva)
ip6addr ipv6 cím igen, ha nincs ipaddr beállítva (none) IPv6 címet rendel az interfészhez (CIDR jelölés)
ip6gw ipv6 cím nem (none) IPv6 alapértelmezett átjárót rendel az interfészhez
ip6assign előtag hossza nem (none) Meghív egy adott hosszúságú előtagot az interfész számára (csak Barrier Breaker és későbbi kiadások)
ip6hint prefix hint (hex) nem (none) Hint the subprefix-ID that should be delegeted as hexadecimal number (Barrier Breaker and later only)
ip6prefix ipv6 prefix nem (none) IPv6 prefix routed here for use on other interfaces (Barrier Breaker and later only)
ip6class list of strings nem (none) Pv6 prefix-osztályokat határoz meg az interfész számára
dns ip-cím lista nem (none) DNS szerver(ek)
metric integer nem 0 Megadja a csomagok alapértelmezett metrikus távolságát

Protocol "dhcp"

Név Típus Szükséges Alapértelmezett Leírás
gateway string nem (none) 0.0.0.0 esetén nem fogadja el a DHCP-től az alapért. átjáró címét
broadcast boolean nem 0 Engedélyezi a broadcast flag-et DHCP kérések esetén, bizonyos ISP-k esetén szükséges, pl. Charter, DOCSIS 3-al
hostname string nem (none) Hostnév, amely szerepelni fog a DHCP kérésekben
clientid string nem rendszer alapértelmezés DHCP kérés esetén felülírja a kliens azonosítót
vendorclass string nem rendszer alapértelmezés DHCP kérés esetén felülírja a vendor class-t
dns ip-cím lista nem (none) KIegészíti a DHCP-vel osztott DNS szerver(eke)t, vagy csak ezt használja ha a peerdns értéke 0
peerdns boolean nem 1 Használja a DHCP-vel osztott DNS szerver(eke)t
metric integer nem 0 Meghatározza az alapértelmezett metrikus távolságot
reqopts szólista nem (none) Továbbo DHCP kérési beállításokat határoz meg
iface6rd logikai interfész nem (none) Logikai interfész sablon a 6rd konfigurációhoz

Megjegyzés: Ahhoz, hogy a 6rd a DHCP alapján automatikusan konfigurálva legyen, létre kell hozni egy “option auto 0” interfészt azzal a névvel, ami az 'iface6rd' paraméter esetén szerepel. Ezen kívül ezt a nevet még hozzá is kell adni a megfelelő tűzfal zónához a /etc/config/firewall állományban.

Protocol "dhcpv6"

:!: Az odhcp6c csomagot telepíteni kell a dhcpv6 használatához. További információk az ipv6.routes oldalon.

Protocol "ppp" (PPP over Modem)

:!: A ppp csomagot telepíteni kell, hogy a PPP-t használhassuk.

Név Típus Szükséges Alapértelmezett Leírás
device elérési út igen (none) A modem eszköz elérési útvonala
username string nem(?) (none) Felhasználói név a PAP/CHAP azonosításhoz
password string nem(?) (none) Jelszó a PAP/CHAP azonosításhoz
connect elérési út nem (none) Egyedi PPP csatlakozási szkript elérési útvonala
disconnect elérési út nem (none) Egyedi PPP kapcsolatbontási szkript elérési útvonala
keepalive number nem (none) Sikertelen próbálkozások száma újracsatlakozás előtt
demand number nem (none) Várakozik ennyi másodpercet mielőtt inaktivitás miatt bontaná a kapcsolatot
defaultroute boolean nem 1 Alapértelmezett útvonal felülírása PPP csatlakozás esetén
peerdns boolean nem 1 Use peer-assigned DNS server(s)
dns ip-cím lista nem (none) Override peer-assigned DNS server(s)
ipv6 boolean nem 0 IPv6 engedélyezése PPP kapcsolaton
pppd_options string nem (none) További parancssori paraméterek, melyeket a pppd daemon megkap

Protocol "pppoe" (PPP over Ethernet)

:!: A ppp-mod-pppoe csomagot telepíteni kell. hpgy a PPPoE-t használhassuk.

Név Típus Szükséges Alapértelmezett Leírás
username string nem(?) (none) Felhasználói név a PAP/CHAP azonosításhoz
password string nem(?) (none) Jelszó a PAP/CHAP azonosításhoz
ac string nem (none) Specifies the Access Concentrator to connect to. If unset, pppd uses the first discovered one
service string nem (none) Megadja a szolgáltatás nevét, amihez csatlakozunk, ha nincs beállítva, akor a pppd az először felderítettet használja
connect elérési út nem (none) Egyedi PPP csatlakozási szkript elérési útvonala
disconnect elérési út nem (none) Egyedi PPP kapcsolatbontási szkript elérési útvonala
keepalive number nem (none) Sikertelen próbálkozások száma újracsatlakozás előtt
demand number nem (none) Várakozik ennyi másodpercet mielőtt inaktivitás miatt bontaná a kapcsolatot
defaultroute boolean nem 1 Alapértelmezett útvonal felülírása PPP csatlakozás esetén
peerdns boolean nem 1 Use peer-assigned DNS server(s)
dns ip-cím lista nem (none) Override peer-assigned DNS server(s)
ipv6 boolean nem 0 IPv6 engedélyezése PPP kapcsolaton
pppd_options string nem (none) További parancssori paraméterek, melyeket a pppd daemon megkap

Protocol "pppoa" (PPP over ATM AAL5)

:!: A ppp-mod-pppoa csomagot telepíteni kell a PPPoA használatához.

Név Típus Szükséges Alapértelmezett Leírás
vci number nem 35 PPPoA VCI
vpi number nem 8 PPPoA VPI
atmdev number nem 0 Megadja a 0-val kezdődő ATM adapter számát. A legtöbb rendszer csak egy ATM eszköztel rendelkezik, ezért nincs szükség erre az optióra
encaps string nem llc PPPoA beágyazás módja: 'llc' (LLC) vagy 'vc' (VC)
username string nem(?) (none) Felhasználói név a PAP/CHAP azonosításhoz
password string nem(?) (none) Jelszó a PAP/CHAP azonosításhoz
connect elérési út nem (none) Egyedi PPP csatlakozási szkript elérési útvonala
disconnect elérési út nem (none) Egyedi PPP kapcsolatbontási szkript elérési útvonala
keepalive number nem (none) Sikertelen próbálkozások száma újracsatlakozás előtt
demand number nem (none) Várakozik ennyi másodpercet mielőtt inaktivitás miatt bontaná a kapcsolatot
defaultroute boolean nem 1 Alapértelmezett útvonal felülírása PPP csatlakozás esetén
peerdns boolean nem 1 Use peer-assigned DNS server(s)
dns ip-cím lista nem (none) Override peer-assigned DNS server(s)
ipv6 boolean nem 0 IPv6 engedélyezése PPP kapcsolaton
pppd_options string nem (none) További parancssori paraméterek, melyeket a pppd daemon megkap

Protocol "3g" (PPP over EV-DO, CDMA, UMTS vagy GPRS)

:!: A comgt csomagot telepíteni kell 3G használatához. további információk a 3gdongle oldalon.

Név Típus Szükséges Alapértelmezett Leírás
device elérési út igen (none) Modem eszköz elérési útvonala
service string igen umts 3G szolgáltatás típusa: cdma/evdo, umts/umts_only/gprs_only (...._only opciók kizárólag Novatel & Option kártyákkal és eszközökkel működnek)
apn string igen (none) APN neve
pincode number nem (none) PIN kód a SIM kártya feloldásához
maxwait number nem 20 Ennyi másodpercet várakozik, hogy a modem készenléti állapotba kerüljön
username string nem(?) (none) Felhasználói név a PAP/CHAP azonosításhoz
password string nem(?) (none) Jelszó a PAP/CHAP azonosításhoz
keepalive number nem (none) Sikertelen próbálkozások száma újracsatlakozás előtt
demand number nem (none) Várakozik ennyi másodpercet mielőtt inaktivitás miatt bontaná a kapcsolatot
defaultroute boolean nem 1 Alapértelmezett útvonal felülírása PPP csatlakozás esetén
peerdns boolean nem 1 Use peer-assigned DNS server(s)
dns ip-cím lista nem (none) Override peer-assigned DNS server(s)
ipv6 boolean nem 0 IPv6 engedélyezése PPP kapcsolaton

Protocol "pptp" (Point-to-Point Tunneling Protocol)

További információk az protocol.pptp.point-to-point.tunneling.protocol oldalon.

Protocol "6in4" (IPv6-in-IPv4 Tunnel)

További információk az protocol.6in4.ipv6-in-ipv4.tunnel oldalon.

Protocol "6to4" (IPv6-in-IPv4 Tunnel)

További információk az protocol.6to4.ipv6-in-ipv4.tunnel oldalon.

Protocol "6rd" (IPv6 rapid deployment)

További információk az protocol.6rd.ipv6.rapid.deployment oldalon.

Protocol "dslite" (Dual-Stack Lite)

További információk az protocol.dslite.dual-stack.lite oldalon.

Protocol "l2tp" (L2TP Pseudowire Tunnel)

További információk az protocol.l2tp.l2tp.pseudowire.tunnel oldalon.

Protocol "relay" (Relayd Pseudo Bridge)

További információk az protocol.relay.relayd.pseudo.bridge oldalon.

Protocol "6relay" (IPv6 Pseudo Bridge)

:!: Az IPv6 pseudo-bridging saját konfigurációs fájlt kapott. Lásd: 6relayd konfiguráció.

:!: The package br2684ctl must be installed to use Ethernet over AAL5.

ATM bridges use a special config section called atm-bridge. Each atm-bridge section maps the specified ATM curcuit an atm# pseudo ethernet device which can be used for example in conjunction with pppoe to establish a DSL connection to the ISP.

A typical bridge section looks like this:

config atm-bridge
       option unit     '0'
       option vpi      '8'
       option vci      '35'
  • Unit 0 will let br2684ctl create a nas0 pseudo device
  • VPI 8 and VCI 35 specifies the circuit to bridge. Those values are ISP dependant.

The atm-bridge section allows the following options:

Name Type Required Default Description
unit number yes 0 Specifies the br2684 interface number. If ommitted, 0 is assumed which would result in a nas0 pseudo interface.
vci number no 35 PPPoA VCI
vpi number no 8 PPPoA VPI
atmdev number no 0 Specifies the ATM adapter number starting with 0. Most systems only have one ATM device and do not need this option
encaps string no llc PPPoA encapsulation mode: 'llc' (LLC) or 'vc' (VC)
payload string no bridged PPPoA forwarding mode: 'routed' or 'bridged'
The “config alias” approach is deprecated. it used to be needed when multiple interfaces sharing the same device where not supported. JoW

Alias sections can be used to define further IPv4 and IPv6 addresses for interfaces. They also allow combinations like DHCP on the main interface and a static IPv6 address in the alias, for example to deploy IPv6 on wan while keeping normal internet connectivity. Each interface can have multiple aliases attached to it.

A minimal alias declaration consists of the following lines:

config 'alias'
        option 'interface' 'lan'
        option 'proto' 'static'
        option 'ipaddr' '10.0.0.1'
        option 'netmask' '255.255.255.0'
  • lan is the logical interface name of the parent interface
  • static is the alias interface protocol
  • 10.0.0.1 specifies the alias ip address
  • 255.255.255.0 specifies the alias netmask

At the time of writing, only the static protocol type is allowed for aliases. Defined options for alias sections are listed below.

Name Type Required Default Description
interface string yes (none) Specifies the logical interface name of the parent (or master) interface this alias belongs to; must refer to one of the defined interface sections
proto string yes (none) Specifies the alias interface protocol
ipaddr ip address yes, if no ip6addr is set (none) IP address
netmask netmask yes, if no ip6addr is set (none) Netmask
gateway ip address no (none) Default gateway
broadcast ip address no (none) Broadcast address (autogenerated if not set)
ip6addr ipv6 address yes, if no ipaddr is set (none) IPv6 address (CIDR notation)
ip6gw ipv6 address no (none) IPv6 default gateway
dns list of ip addresses no (none) DNS server(s)
layer integer no 3 Selects the interface to attach to for stacked protocols (tun over bridge over eth, ppp over eth or similar).
3: attach to layer 3 interface (tun*, ppp* if parent is layer 3 else fallback to 2)
2: attach to layer 2 interface (br-* if parent is bridge else fallback to layer 1)
1: attach to layer 1 interface (eth*, wlan*)

To list IP addresses associated with devices, you can run ifconfig, but that command will show only first IP address per device. However it will show alias device if you provided name (label) for it. The error proof method to list all IP addresses is:

ip addr

Static IPv4 routes can be defined on specific interfaces using route sections. As for aliases, multiple sections can be attached to an interface.

A minimal example looks like this:

config 'route' 'name_your_route'
        option 'interface' 'lan'
        option 'target' '172.16.123.0'
        option 'netmask' '255.255.255.0'
        option 'gateway' '172.16.123.100'
  • lan is the logical interface name of the parent interface
  • 172.16.123.0 is the network address of the route
  • 255.255.255.0 specifies the route netmask

Legal options for IPv4 routes are:

Name Type Required Default Description
interface string yes (none) Specifies the logical interface name of the parent (or master) interface this route belongs to; must refer to one of the defined interface sections
target ip address yes (none) Network address
netmask netmask no (none) Route netmask. If omitted, 255.255.255.255 is assumed which makes target a host address
gateway ip address no (none) Network gateway. If omitted, the gateway from the parent interface is taken; if set to 0.0.0.0 no gateway will be specified for the route
metric number no 0 Specifies the route metric to use
mtu number no interface MTU Defines a specific MTU for this route
table routing table no (none) Defines the table ID to use for the route. The ID can be either a numeric table index ranging from 0 to 65535 or a symbolic alias declared in /etc/iproute2/rt_tables. The special aliases local (255), main (254) and default (253) are recognized as well

IPv6 routes can be specified as well by defining one or more route6 sections.

A minimal example looks like this:

config 'route6'
        option 'interface' 'lan'
        option 'target' '2001:0DB8:100:F00:BA3::1/64'
        option 'gateway' '2001:0DB8:99::1'
  • lan is the logical interface name of the parent interface
  • 2001:0DB8:100:F00:BA3::1/64 is the routed IPv6 subnet in CIDR notation
  • 2001:0DB8:99::1 specifies the IPv6 gateway for this route

Legal options for IPv6 routes are:

Name Type Required Default Description
interface string yes (none) Specifies the logical interface name of the parent (or master) interface this route belongs to; must refer to one of the defined interface sections
target ipv6 address yes (none) IPv6 network address
gateway ipv6 address no (none) IPv6 gateway. If omitted, the gateway from the parent interface is taken
metric number no 0 Specifies the route metric to use
mtu number no interface MTU Defines a specific MTU for this route
table routing table no (none) Defines the table ID to use for the route. The ID can be either a numeric table index ranging from 0 to 65535 or a symbolic alias declared in /etc/iproute2/rt_tables. The special aliases local (255), main (254) and default (253) are recognized as well

Since OpenWrt Barrier Braker, netifd supports IP rule declarations which are required to implement policy routing.
IPv4 rules can be defined by declaring one or more sections of type rule, IPv6 rules are denoted by sections of type rule6. Both types share the same set of defined options.

A simple IPv4 rule may look like:

config rule
	option mark   '0xFF'
        option in     'lan'
	option dest   '172.16.0.0/16'
	option lookup '100'
  • 0xFF is a fwmark to be matched
  • lan is the incoming logical interface name
  • 172.16.0.0/16 is the destination subnet to match
  • 100 is the routing table ID to use for the matched traffic

Similary, an IPv6 rule looks like:

config rule6
        option in     'vpn'
	option dest   'fdca:1234::/64'
	option action 'prohibit'
  • vpn is the incoming logical interface name
  • fdca:1234::/64 is the destination subnet to match
  • prohibit is a routign action to take

The options below are defined for IP rule (rule and rule6) sections:

Name Type Required Default Description
in string no (none) Specifies the incoming logical interface name
out string no (none) Specifies the outgoing logical interface name
src ip subnet no (none) Specifies the source subnet to match (CIDR notation)
dest ip subnet no (none) Specifies the destination subnet to match (CIDR notation)
tos integer no (none) Specifies the TOS value to match in IP headers
mark mark/mask no (none) Specifies the fwmark and optionally its mask to match, e.g. 0xFF to match mark 255 or 0x0/0x1 to match any even mark value
invert boolean no 0 If set to 1, the meaning of the match options is inverted
priority integer no (incrementing) Controls the order of the IP rules, by default the priority is auto-assigned so that they are processed in the same order they're declared in the config file
lookup routing table at least one of (none) The rule target is a table lookup, the ID can be either a numeric table index ranging from 0 to 65535 or a symbolic alias declared in /etc/iproute2/rt_tables. The special aliases local (255), main (254) and default (253) are recognized as well
goto rule index The rule target is a jump to another rule specified by its priority value
action string The rule target is one of the routing actions outlined in the table below

Routing Actions

Action Description
prohibit When reaching the rule, respond with ICMP prohibited messages and abort route lookup
unreachable When reaching the rule, respond with ICMP unreachable messages and abort route lookup
blackhole When reaching the rule, drop packet and abort route lookup
throw Stop lookup in the current routing table even if a default route exists

Below are a few examples for special, non-standard interface configurations.

config 'interface' 'example'
        option 'type'    'bridge'
        option 'proto'   'none'
        option 'ifname'  'eth0 eth1'
        option 'auto'    '1'
config 'interface' 'example'
        option 'proto'   'dhcp'
        option 'ifname'  'eth0'
        option 'gateway' '0.0.0.0'
config 'interface' 'example'
        option 'proto'     'dhcp'
        option 'ifname'    'eth0'

config 'alias'
        option 'interface' 'example'
        option 'proto'     'static'
        option 'ip6addr'   '2001:0DB8:100:F00:BA3::1'
config 'interface' 'example'
        option 'proto'     'static'
        option 'ifname'    'eth0'
        option 'ipaddr'    '192.168.1.200'
        option 'netmask'   '255.255.255.0'
        option 'dns'       '192.168.1.1'

config 'route'
        option 'interface' 'example'
        option 'target'    '0.0.0.0'
        option 'netmask'   '0.0.0.0'
        option 'gateway'   '192.168.1.1'
        option 'metric'    '100'
config 'interface' 'wan'
        option 'proto'     'pppoe'
        option 'ifname'    'eth1'
        option 'username'  'user'
        option 'password'  'pass'
        option 'timeout'   '10'

config 'interface' 'vpn'
        option 'proto'     'pptp'
        option 'ifname'    'vpn'
        option 'username'  'vpnuser'
        option 'password'  'vpnpass'
        option 'server'    'vpn.example.org'

:!: Additionally the “wan” firewall zone must include both interfaces in /etc/config/firewall:

config 'zone'
        option 'name'      'wan'
        option 'network'   'wan vpn'  # Important
        option 'input'     'REJECT'
        option 'forward'   'REJECT'
        option 'output'    'ACCEPT'
        option 'masq'      '1'
config adsl-device 'adsl'
        option fwannex 'a'
        option annex 'a'

config interface 'wan'
        option proto 'pppoa'
        option username 'jbloggs@plusdsl.net'
        option password 'XXXXXXXXX'
        option vpi '0'
        option vci '38'
        option encaps 'vc'

The example below illustrates a static tunnel configuration in /etc/config/network file for the Hurricane Electric (he.net) broker. Option ipaddr specifies the local IPv4 address, peeraddr is the broker IPv4 address and ip6addr the local IPv6 address routed via the tunnel.

config 'interface' 'wan6'
        option 'proto'     '6in4'
        option 'ipaddr'    '178.24.115.19'
        option 'peeraddr'  '216.66.80.30'
        option 'ip6addr'   '2001:0DB8:1f0a:1359::2/64'

:!: You should also add an address from your routed IPv6 network to the “lan” interface.

:!: If you define a new, dedicated zone just for the tunnel interface, make sure to set option conntrack 1 in order to force enabling connection tracking, otherwise unidirectional forwarding rules will not work.

:!: Don't forget to set up forwarding rules between the LAN and the tunnel if you want to route IPv6 traffic between them.

Setup behind one-to-one NAT

If your public IP, e.g. 178.24.115.19, is not matching the IP address on your WAN interface, your ISP is probably using one-to-one NAT (aka full-cone NAT) and you won't be able to establish static IPv6-in-IPv4 tunnel. IP address of your WAN interface can be obtained with the following command:

  • Backfire
    uci -P/var/state get network.wan.ipaddr
  • Trunk/Attitude Adjustment
    . /lib/functions/network.sh; network_get_ipaddr ip wan; echo $ip

If this is your case you should fill the WAN IP address into ipaddr option instead of your actual public IP that might have been provided to Hurricane Electric during tunnel creation.1) Or you may completely omit the optional ipaddr option and let auto configuration to handle the correct IP. (FIXME Auto configuration is vague. Is uci handling this case?) That would be preferred solution if your WAN IP is dynamic (i.e. obtained via DHCP) or you are not sure. Example of /etc/config/network entry:

config 'interface' 'wan6'
        option 'proto'     '6in4'
        option 'peeraddr'  '216.66.80.30'
        option 'ip6addr'   '2001:0DB8:1f0a:1359::2/64'

Note: you could probably try to define alias for WAN interface with your public IP address. Then you could use your public IP in ipaddr option and system would find its way to your WAN interface that has only private IP address because of the one-to-one NAT. (FIXME However, it didn't really worked for me. I got this advice on IRC and it looks reasonable, thats why I put it here anyway. If it was not supposed to fix it, just delete this note.)

The example below illustrates a dynamic tunnel configuration for the Hurricane Electric (he.net) broker with enabled IP update. The local IPv4 address is automatically determined and tunnelid, username and password are provided for IP update.

config 'interface' 'wan6'
        option 'proto'     '6in4'
        option 'peeraddr'  '216.66.80.30'
        option 'ip6addr'   '2001:0DB8:1f0a:1359::2/64'
        option 'tunnelid'  '12345'
        option 'username'  'myusername'
        option 'password'  '098f6bcd4621d373cade4e832627b4f6'

:!: You should also add an address from your routed IPv6 network to the “lan” interface.

:!: To apply IPv6 firewall rules to the tunnel interface, add it to the “wan” firewall zone, see example above for details.

:!: The password entered above should be the md5sum of the password you use to log in to tunnelbroker.net.

This example establishes a Pseudowire Tunnel and bridges it to the LAN ports. The existing lan interface is reused with protocol l2tp instead of static.

config 'interface' 'lan'
        option 'proto'     'l2tp'
        option 'type'      'bridge'
        option 'ifname'    'eth0'
        option 'ipaddr'    '192.168.1.1'
        option 'netmask'   '255.255.255.0'
        option 'localaddr' '178.24.154.19'
        option 'peeraddr'  '89.44.33.61'
        option 'encap'     'udp'
        option 'sport'     '4000'
        option 'dport'     '5410'

This example sets up a relayd pseudo bridge between a wireless client network and LAN, so that it works similarly to the Broadcom Bridged Client mode.

Wireless configuration (excerpt):

config wifi-iface
        option 'device'     'radio0'
        option 'mode'       'sta'
        option 'ssid'       'Some Wireless Network'
        option 'encryption' 'psk2'
        option 'key'        '12345678'
        option 'network'    'wwan'

Network configuration (excerpt):
:!: Note that the LAN subnet must be different from the one used by wireless network's DHCP.

config 'interface' 'lan'
        option 'ifname'     'eth0.1'
        option 'proto'      'static'
        option 'ipaddr'     '192.168.1.1'
        option 'netmask'    '255.255.255.0'

config 'interface' 'wwan'
        option 'proto'      'dhcp'

config 'interface' 'stabridge'
        option 'proto'      'relay'
        option 'network'    'lan wwan'

In contrast to true bridging, traffic forwarded in this manner is affected by firewall rules, therefore both the wireless client network and the lan network should be covered by the same LAN firewall zone with forward policy set to accept to allow traffic flow between both interfaces:

config 'zone'
        option 'name'        'lan'
        option 'network'     'lan wwan'  # Important
        option 'input'       'ACCEPT'
        option 'forward'     'ACCEPT'    # Important
        option 'output'      'ACCEPT'

The complete network configuration can be re-applied by running /etc/init.d/network restart. Individual interfaces can be brought up with ifup name or down with ifdown name where name corresponds to the logical interface name of the corresponding config interface section. An ifup implies a prior ifdown so there is no need to invoke both when reloading an interface.

Note that wireless interfaces are managed externally and ifup may break the relation to existing bridges. In such a case it is required to run wifi up after ifup in order to re-establish the bridge connection.

In order to derive a Linux interface name like eth1 from a logical network name like wan for use in scripts or tools like ifconfig and route the uci utility can be used as illustrated in the example below which opens port 22 on the interface.

WANIF=$(uci -P/var/state get network.wan.ifname)
iptables -I INPUT -i $WANIF -p tcp --dport 22 -j ACCEPT

The uci state vars are deprecated and not used anymore for network related information Quoting jow in the forum.
Use /lib/functions/network.sh:

source /lib/functions/network.sh
 
if network_get_ipaddr addr "wan"; then
    echo "IP is $addr"
fi

1)
You should always use your public IP while creating Hurricane Electric tunnel, so don't change it just because you are behind one-to-one NAT.
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
  • Last modified: 2021/10/15 08:10
  • by bobafetthotmail