Buildroot-ts Network: Difference between revisions
m (Kris moved page Buildroot-2018.02 Network to Buildroot-ts Network: No longer tied to 2018 release) |
(Update with dhcp clarity) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
Buildroot implements the | Buildroot implements the <source inline>ip</source>, <source inline>ifconfig</source>, <source inline>route</source>, etc., commands to manipulate the settings of interfaces. The first Ethernet interface is set up to come up automatically with our default configuration. The interfaces can also be manually set up: | ||
<source lang=bash> | <source lang=bash> | ||
# Bring up the CPU network interface | # Bring up the CPU network interface | ||
ifconfig eth0 up | ifconfig eth0 up | ||
# Set an | # Set an IP address (assumes 255.255.255.0 subnet mask) | ||
ifconfig eth0 192.168.0.50 | ifconfig eth0 192.168.0.50 | ||
Line 10: | Line 10: | ||
ifconfig eth0 192.168.0.50 netmask 255.255.0.0 | ifconfig eth0 192.168.0.50 netmask 255.255.0.0 | ||
# Configure | # Configure a default route. This is the server that provides an internet connection. | ||
route add default gw 192.168.0.1 | route add default gw 192.168.0.1 | ||
# Edit /etc/resolv.conf for | # Edit /etc/resolv.conf for the local DNS server | ||
echo "nameserver 192.168.0.1" > /etc/resolv.conf | echo "nameserver 192.168.0.1" > /etc/resolv.conf | ||
</source> | </source> | ||
Line 19: | Line 19: | ||
Most commonly, networks will offer DHCP which can be set up with one command: | Most commonly, networks will offer DHCP which can be set up with one command: | ||
<source lang=bash> | <source lang=bash> | ||
# To setup the default CPU | # To setup the default CPU Ethernet port | ||
udhcpc -i eth0 | udhcpc -i eth0 | ||
# | # All Ethernet ports can be made active and request DHCP addresses with: | ||
udhcpc | udhcpc | ||
</source> | </source> | ||
To have network settings take effect on startup in Buildroot, edit /etc/network/interfaces: | To have network settings take effect on startup in Buildroot, edit <source inline>/etc/network/interfaces</source>: | ||
<source lang=bash> | <source lang=bash> | ||
# interface file auto-generated by | # interface file auto-generated by Buildroot | ||
auto lo | auto lo | ||
Line 38: | Line 38: | ||
wait-delay 15 | wait-delay 15 | ||
</source> | </source> | ||
See the man page for interfaces(5) for further information on the syntax of the file. | Note that the default network startup may timeout on some networks, e.g. network protocols such as STP can delay packet movement. This can be resolved in Buildroot by adding network configuration options to fail after a number of attempts (rather than a timeout) or retry for a DHCP lease indefinitely. For example, adding one of the following lines under the <source inline>iface eth0 inet dhcp</source> section: | ||
* <source inline>udhcpc_opts -t 0</source> to infinitely retry | |||
* <source inline>udhcpc_opts -t 5</source> to fail after five attempts. | |||
See the man page for interfaces(5) for further information on the syntax of the <source inline>interfaces</source> file and all of the options that can be passed. | |||
For more information on network configuration in general, Debian provides a great resource [http://wiki.debian.org/Network here] that can be readily applied to Buildroot in most cases. | For more information on network configuration in general, Debian provides a great resource [http://wiki.debian.org/Network here] that can be readily applied to Buildroot in most cases. |
Latest revision as of 13:34, 4 April 2023
Buildroot implements the ip
, ifconfig
, route
, etc., commands to manipulate the settings of interfaces. The first Ethernet interface is set up to come up automatically with our default configuration. The interfaces can also be manually set up:
# Bring up the CPU network interface
ifconfig eth0 up
# Set an IP address (assumes 255.255.255.0 subnet mask)
ifconfig eth0 192.168.0.50
# Set a specific subnet
ifconfig eth0 192.168.0.50 netmask 255.255.0.0
# Configure a default route. This is the server that provides an internet connection.
route add default gw 192.168.0.1
# Edit /etc/resolv.conf for the local DNS server
echo "nameserver 192.168.0.1" > /etc/resolv.conf
Most commonly, networks will offer DHCP which can be set up with one command:
# To setup the default CPU Ethernet port
udhcpc -i eth0
# All Ethernet ports can be made active and request DHCP addresses with:
udhcpc
To have network settings take effect on startup in Buildroot, edit /etc/network/interfaces
:
# interface file auto-generated by Buildroot
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
pre-up /etc/network/nfs_check
wait-delay 15
Note that the default network startup may timeout on some networks, e.g. network protocols such as STP can delay packet movement. This can be resolved in Buildroot by adding network configuration options to fail after a number of attempts (rather than a timeout) or retry for a DHCP lease indefinitely. For example, adding one of the following lines under the iface eth0 inet dhcp
section:
udhcpc_opts -t 0
to infinitely retryudhcpc_opts -t 5
to fail after five attempts.
See the man page for interfaces(5) for further information on the syntax of the interfaces
file and all of the options that can be passed.
For more information on network configuration in general, Debian provides a great resource here that can be readily applied to Buildroot in most cases.