openwrt configuration. Users guide. Part 1. How to configure network.
Short topic explaining openwrt configuration to get IP address via DHCP. Explained on example of NetSom development board but suitable for all another OpenWrt driven devices.
Initially, fresh built and flashed image won’t get IP address as it configured as DHCP server itself:
# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:11:22:33:44:55
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
eth0 Link encap:Ethernet HWaddr 00:11:22:33:44:55
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
# ifconfig eth1
eth1 Link encap:Ethernet HWaddr 23:58:7F:3D:44:78
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
eth1 Link encap:Ethernet HWaddr 23:58:7F:3D:44:78
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
It is pretty simple to change configuration and get IP address via DHCP.
For that you need to edit /etc/config/network:
root@OpenWrt:/# vi /etc/config/network
and change lan interface:
config interface ‘lan’
# option type ‘bridge’
option ifname ‘eth0’
option proto ‘dhcp’
# option ipaddr ‘192.168.1.1’
# option netmask ‘255.255.255.0’
# option ip6assign ’60’
# option type ‘bridge’
option ifname ‘eth0’
option proto ‘dhcp’
# option ipaddr ‘192.168.1.1’
# option netmask ‘255.255.255.0’
# option ip6assign ’60’
to enable second ethernet interface add following:
config interface ‘lan2’
option ifname ‘eth1’
option proto ‘dhcp’
option ifname ‘eth1’
option proto ‘dhcp’
then exit (by typing :wq) and restart network configuration:
root@OpenWrt:/# /etc/init.d/network restart
and check if ip addresses taken:
root@OpenWrt:/# ifconfig eth0 && ifconfig eth1
eth0 Link encap:Ethernet HWaddr 01:2D:3C:56:06:2B
inet addr:192.168.1.22 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::4cd:5cff:fd86:6fb/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:105 errors:0 dropped:0 overruns:0 frame:0
TX packets:218 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:8497 (8.4 KiB) TX bytes:31956 (26.5 KiB)
eth1 Link encap:Ethernet HWaddr 00:21:12:37:54:55
inet addr:192.168.1.18 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::271:22ff:fd33:4455/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:82 errors:0 dropped:0 overruns:0 frame:0
TX packets:33 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3921 (3.9 KiB) TX bytes:1518 (1.2 KiB)
eth0 Link encap:Ethernet HWaddr 01:2D:3C:56:06:2B
inet addr:192.168.1.22 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::4cd:5cff:fd86:6fb/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:105 errors:0 dropped:0 overruns:0 frame:0
TX packets:218 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:8497 (8.4 KiB) TX bytes:31956 (26.5 KiB)
eth1 Link encap:Ethernet HWaddr 00:21:12:37:54:55
inet addr:192.168.1.18 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::271:22ff:fd33:4455/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:82 errors:0 dropped:0 overruns:0 frame:0
TX packets:33 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3921 (3.9 KiB) TX bytes:1518 (1.2 KiB)
In a case of facing network issue during developing custom SW/HW steps to troubleshoot described here might be useful:
- IMX6 Ethernet. Development process to add second ethernet PHY IC support. part 1.
- IMX6 Ethernet. Development process to add second ethernet PHY IC support. part 2.
- IMX6 Ethernet. Development process to add second ethernet PHY IC support. part 3.
Keep following as here at our telegram channel.