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/07/13 18:23] – fix and improve dhcp options charles_harrisdocs: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 32: Line 21:
 | ''dns'' | list of ip addresses | no | //(none)// | DNS server(s) | | ''dns'' | list of ip addresses | no | //(none)// | DNS server(s) |
 | ''dns_metric'' | integer | no | ''0'' | [[commit>?p=project/netifd.git;a=commitdiff;h=7f6be657e2dabc185417520de4d0d0de2580c27d|DNS metric]] | | ''dns_metric'' | integer | no | ''0'' | [[commit>?p=project/netifd.git;a=commitdiff;h=7f6be657e2dabc185417520de4d0d0de2580c27d|DNS metric]] |
-| ''dns_search'' | list of domain names | no | //(none)// | Search list for host-name lookup |+| ''dns_search'' | list of domain names | no | //(none)// | Search list for host-name lookup, relevant only for the router |
 | ''metric'' | integer | no | ''0'' | Specifies the default route metric to use | | ''metric'' | integer | no | ''0'' | Specifies the default route metric to use |
  
 ===== Protocol "dhcp" ===== ===== Protocol "dhcp" =====
 ^ Name ^ Type ^ Required ^ Default ^ Description ^ ^ Name ^ Type ^ Required ^ Default ^ Description ^
-| ''<del>gateway</del>'' | <del>string</del> | <del>no</del> | <del>//(none)//</del> | <del>Suppresses DHCP-assigned default gateway if set to 0.0.0.0</del> \\ (deprecated) | 
 | ''broadcast'' | boolean | no | ''0'' | Enable the broadcast flag in DHCP requests, required for certain ISPs, e.g. Charter with DOCSIS 3 | | ''broadcast'' | boolean | no | ''0'' | Enable the broadcast flag in DHCP requests, required for certain ISPs, e.g. Charter with DOCSIS 3 |
 | ''ipaddr'' | IP address | no | //(none)// | IP address to request from the DHCP server | | ''ipaddr'' | IP address | no | //(none)// | IP address to request from the DHCP server |
 | ''hostname'' | string | no | //system hostname// | Hostname to include in DHCP requests (option 12)| | ''hostname'' | string | no | //system hostname// | Hostname to include in DHCP requests (option 12)|
 | ''clientid'' | string | no | //(none)// | Override client identifier in DHCP requests (option 61)| | ''clientid'' | string | no | //(none)// | Override client identifier in DHCP requests (option 61)|
-| ''vendorid'' | string | no | ''`udhcp VERSION'' | Override the vendor class in DHCP requests (option 60)|+| ''vendorid'' | string | no | ''udhcp VERSION'' | Override the vendor class in DHCP requests (option 60)|
 | ''dns'' | list of ip addresses | no | //(none)// | Supplement DHCP-assigned DNS server(s), or use only these if peerdns is 0 | | ''dns'' | list of ip addresses | no | //(none)// | Supplement DHCP-assigned DNS server(s), or use only these if peerdns is 0 |
 | ''peerdns'' | boolean | no | ''1'' | Use DHCP-provided DNS server(s) | | ''peerdns'' | boolean | no | ''1'' | Use DHCP-provided DNS server(s) |
Line 54: 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 72: 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 90: 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 118: 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