Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
docs:guide-user:network:ipv4:configuration [2023/09/29 21:38] – [Protocol "dhcp"] update vgaeteradocs:guide-user:network:ipv4:configuration [2023/10/08 04:27] – optimize vgaetera
Line 2: Line 2:
 Due to obvious reasons, IPv4 is fully supported in default firmware. Due to obvious reasons, IPv4 is fully supported in default firmware.
  
-===== Upstream configuration for WAN-Interfaces ===== +===== Upstream configuration for WAN interfaces ===== 
-The following sections describe the configuration of IPv4 connections to your ISP or an upstream router. +The following sections describe the configuration of IPv4 connections to your ISP or an upstream router.
  
 For an uplink with native IPv4 connectivity you can just use the default configuration. For an uplink with native IPv4 connectivity you can just use the default configuration.
  
 <code bash> <code bash>
-# uci show network 
-... 
-network.wan=interface 
-network.wan.device='eth0.2' 
-network.wan.proto='dhcp' 
-... 
-</code> 
- 
-<code bash># cat /etc/config/network 
-... 
 config interface 'wan' config interface 'wan'
  option device 'eth0.2'  option device 'eth0.2'
  option proto 'dhcp'  option proto 'dhcp'
-... 
 </code> </code>
  
Line 53: Line 42:
 | ''zone'' | firewall zone | no | //(none)// | Firewall zone to which this interface should be added | | ''zone'' | firewall zone | no | //(none)// | Firewall zone to which this interface should be added |
  
-:!: These parameters are handled partially by netifd (in ''interface.c'') and partially by a shell script in ''lib/netifd/proto/dhcp.sh'' Note prior to commit 3cee6f3f24 the norelease option was known as release and had the opposite sense.+:!: These parameters are handled partially by netifd (in ''interface.c'') and partially by a shell script in ''lib/netifd/proto/dhcp.sh''. 
 +Note prior to commit 3cee6f3f24 the norelease option was known as release and had the opposite sense.
  
 FIXME Outdated information, please proofread and test it:  FIXME Outdated information, please proofread and test it: 
  
-:!: If an interface is configured as dhcp client, the default route received by dhcp will be the only one listed and will remove other default route/metrics defined for other interfaces if those interfaces comes "before" the interface with dhcp in terms of "device" values. For example:+:!: If an interface is configured as DHCP client, the default route received by DHCP will be the only one listed and will remove other default route/metrics defined for other interfaces if those interfaces comes "before" the interface with DHCP in terms of "device" values. 
 +For example:
  
 <code bash> <code bash>
Line 71: Line 62:
 </code> </code>
  
-The interface with dhcp comes after (because eth1 comes after eth0 in a lexicografical order) +The interface with DHCP comes after (because eth1 comes after eth0 in a lexicografical order) and will overwrite the default routes set up by the interface "wan", while the contrary is not true:
-and will overwrite the default routes set up by the interface "wan". While is not true the contrary. +
-If we have:+
  
 <code bash> <code bash>
Line 89: Line 78:
 Both default routes set up by wan and wan2 will appear in the routing table. Both default routes set up by wan and wan2 will appear in the routing table.
  
-===== Downstream configuration for LAN-Interfaces =====+===== Downstream configuration for LAN interfaces =====
 For a downlink with IPv4 connectivity you can just use the default configuration, DHCP server is enabled by default, please see [[docs:guide-user:base-system:dhcp|DHCP configuration]] for more details on that. For a downlink with IPv4 connectivity you can just use the default configuration, DHCP server is enabled by default, please see [[docs:guide-user:base-system:dhcp|DHCP configuration]] for more details on that.
  
 <code bash> <code bash>
-# uci show network 
-network.lan=interface 
-network.lan.device='br-lan' 
-network.lan.proto='static' 
-network.lan.netmask='255.255.255.0' 
-network.lan.ip6assign='60' 
-network.lan.ipaddr='192.168.1.1' 
-... 
-</code> 
- 
-<code bash> 
-# /etc/config/network 
 config interface 'lan' config interface 'lan'
  option device 'br-lan'  option device 'br-lan'
Line 117: Line 94:
  list ports 'lan3'  list ports 'lan3'
  list ports 'lan4'  list ports 'lan4'
-... 
-</code> 
- 
-===== Examples ===== 
-Below are a few examples for special, non-standard interface configurations. 
- 
-==== Bridge without IP ==== 
-<code bash> 
-config interface 'example' 
- option proto   'none' 
- option device  'br-lan' 
- option auto    '1' 
- 
-config device 'example_dev' 
- option name 'br-lan' 
- option type 'bridge' 
- list ports 'eth0' 
- list ports 'eth1' 
-</code> 
- 
-==== DHCP without default gateway ==== 
-<code bash> 
-config interface 'example' 
- option proto   'dhcp' 
- option device  'eth0' 
- option defaultroute' '0' 
-</code> 
- 
-==== DHCP and IPv6 ==== 
-<code bash> 
-config interface 'example' 
- option proto     'dhcp' 
- option device    'eth0' 
- 
-config alias 
- option interface 'example' 
- option proto     'static' 
- option ip6addr   '2001:0DB8:100:F00:BA3::1' 
-</code> 
- 
-==== Static IP configuration with multiple DNS servers ==== 
-<code bash> 
-config interface 'example' 
- option proto     'static' 
- option device    'eth0' 
- option ipaddr    '192.168.1.200' 
- option netmask   '255.255.255.0' 
- list   dns       '192.168.1.1' 
- list   dns       '192.168.10.1' 
-</code> 
- 
-:!: The last DNS listed will be the first one to be chosen for the name resolution. 
- 
-:!: Restart the service to apply the new DNS configuration: ''service dnsmasq restart'' 
- 
-==== Static IP configuration and default gateway with non-zero metric ==== 
-<code bash> 
-config interface 'example' 
- option proto     'static' 
- option device    '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' 
-</code> 
- 
-==== Multiple IP addresses ==== 
-Assigning multiple IP addresses to the same interface: 
- 
-<code bash> 
-config interface 'foo' 
- option device 'eth1' 
- list ipaddr '10.8.0.1/24' 
- list ipaddr '10.9.0.1/24' 
- list ip6addr 'fdca:abcd::1/64' 
- list ip6addr 'fdca:cdef::1/64' 
-</code> 
- 
-Specifying multiple interfaces sharing the same device: 
- 
-<code bash> 
-config interface 'foo' 
- option device 'eth1' 
- option ipaddr '10.8.0.1' 
- option netmask '255.255.255.0' 
- option ip6addr 'fdca:abcd::1/64' 
- 
-config interface 'foo2' 
- option device 'eth1' 
- option ipaddr '10.9.0.1' 
- option netmask '255.255.255.0' 
- option ip6addr 'fdca:cdef::1/64' 
-</code> 
- 
-Originally posted at [[https://dev.openwrt.org/ticket/2829#comment:7]]. 
- 
-==== Custom MAC address ==== 
-<code bash> 
-config device 
- option name 'eth0' 
- option macaddr '00:11:22:33:44:55' 
 </code> </code>
  
  • Last modified: 2024/05/29 20:25
  • by zorun