Here we will setup an initial network configuration for Buildroot on your ESPRESSObin. As mentioned in Quick User Guide, let us start by setting up ESPRESSObin as a network client with no routing. You can skip this step if you have already configured it.
Network client
Connect one end of an Ethernet cable to the WAN port on ESPRESSObin and the other end to your router or IP switch. In the Buildroot shell insert the following commands to configure eth0 interface to use DHCP for obtaining an IP address:
#ifconfig eth0 up #dhclient wan [ 162.790397] IPv6: ADDRCONF(NETDEV_UP): wan: link is not ready [ 164.323110] dsa dsa@0 wan: Link is Down [ 165.331782] dsa dsa@0 wan: Link is Up - 100Mbps/Full - flow control rx/tx [ 165.338761] IPv6: ADDRCONF(NETDEV_CHANGE): wan: link becomes ready
using ifconfig command we can verify that the IP address has been obtained, e.g.:
# ifconfig eth0 Link encap:Ethernet HWaddr F0:AD:4E:03:5F:30 inet6 addr: fe80::f2ad:4eff:fe03:5f30%8270400/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:460 errors:0 dropped:0 overruns:0 frame:0 TX packets:32 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:532 RX bytes:38118 (37.2 KiB) TX bytes:3456 (3.3 KiB) Interrupt:9 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1%8272704/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:2 errors:0 dropped:0 overruns:0 frame:0 TX packets:2 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1 RX bytes:140 (140.0 B) TX bytes:140 (140.0 B) wan Link encap:Ethernet HWaddr F0:AD:4E:03:5F:30 inet addr:192.168.1.7 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::f2ad:4eff:fe03:5f30%8271552/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:287 errors:0 dropped:0 overruns:0 frame:0 TX packets:22 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:17784 (17.3 KiB) TX bytes:1948 (1.9 KiB)
we can also ping any IP address on the web to check our Internet connection, e.g.
# ping www.google.com PING www.google.com (172.217.20.164): 56 data bytes 64 bytes from 172.217.20.164: seq=0 ttl=54 time=49.404 ms 64 bytes from 172.217.20.164: seq=1 ttl=54 time=48.036 ms 64 bytes from 172.217.20.164: seq=2 ttl=54 time=48.721 ms ^C --- www.google.com ping statistics --- 3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max = 48.036/48.720/49.404 ms
Routing
To enable routing in Buildroot we again (as we did in Ubuntu - initial network configuration) need to enable NETFILTER/IPTABLES/NAT options in kernel configuration, so refer to that page if your kernel does not have them enabled.
When these options are included, we additionally need to enable dnsmasq in Buildroot source tree. Head to where you have setup Buildroot and issue make menuconfig:
espressobin@buildserver:~/buildroot$ make menuconfig
and in there search for and select BR2_PACKAGE_DNSMASQ:
Symbol: BR2_PACKAGE_DNSMASQ [=y] Type : boolean Prompt: dnsmasq Location: -> Target packages (1) -> Networking applications Defined at package/dnsmasq/Config.in:1
once dnsmasq is enabled, save and exit menuconfig. Now we rebuild Buildroot with:
espressobin@buildserver:~/buildroot$ make -j4
To copy dnsmasq binary to a microSD card already containing Buildroot we would mount the SD card and copy the binary located in /output/target/usr/sbin/ from our Buildroot source tree to /usr/sbin/ directory on our SD card:
espressobin@buildserver:~/buildroot/output/target/usr/sbin$ sudo cp dnsmasq /mnt/sdcard/usr/sbin/
Alternatively, you can replace your entire root file system on the SD card by again extracting rootfs.tar.gz from output/images/ directory as was shown in Boot from removable storage - Buildroot page. Also make sure to transfer kernel images with NETFILTER/NAT/IPTABLES options enabled to the SD card as well.
Exit the directory and unmount the SD card:
espressobin@buildserver:/mnt/sdcard$ cd espressobin@buildserver:/$ sudo umount /mnt/sdcard
and insert the SD card in the microSD card slot in your ESPRESSObin. Follow booting procedure from Boot from removable storage - Buildroot. Once you get to Buildroot console and have the basic network client configuration from above set up, you can run the commands below (or put them in a file and run as script) to get routing functionality:
brctl addbr br0 ifconfig eth0 0.0.0.0 up ifconfig wan 0.0.0.0 up ifconfig lan0 0.0.0.0 up ifconfig lan1 0.0.0.0 up brctl addif br0 lan0 brctl addif br0 lan1 ifconfig br0 192.168.22.1 dnsmasq --interface=br0 --dhcp-range=br0,192.168.22.2,192.168.22.199,12h echo 1 > /proc/sys/net/ipv4/ip_forward iptables -t nat -A POSTROUTING -o wan -j MASQUERADE dhclient wan