Loading...
 

Use network in Linux

There are 4 Ethernet interfaces available on MACCHIATObin, one 1GbE RJ45 port, two 10GbE with RJ45 or SFP interfaces, and one 2.5GbE SFP port. In the Linux environment, the initial mapping of the 4 Ethernet ports on the MACCHIATObin is shown in the picture below:

Ethernet Port   Linux  

 Note

The 10G copper connectors are only available on the Double Shot version of MACCHIATObin; they are not mounted on the Single Shot MACCHIATObin board.


To use one of the Ethernet such as the 1GbE RJ45 interface on the left in the Buildroot root file system, you need to plug in the Ethernet cable, then use the dhclient command to acquire the IP address for this port:

# dhclient eth2
[  338.571610] mvpp2 f4000000.ppv22 eth2: link up
#


Check the IP address you have just acquired, do a ping test to confirm the network connection.

# ifconfig
eth2      Link encap:Ethernet  HWaddr 00:00:00:00:00:05
          inet addr:10.82.40.222  Bcast:10.82.43.255  Mask:255.255.252.0
          inet6 addr: fe80::200:ff:fe00:5%769308352/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:115 errors:0 dropped:0 overruns:0 frame:0
          TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:2048
          RX bytes:14818 (14.4 KiB)  TX bytes:1332 (1.3 KiB)
          Interrupt:136 Memory:f4000000-f408ffff

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1%769309504/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)

# ping www.google.com
PING www.google.com (172.217.4.164): 56 data bytes
64 bytes from 172.217.4.164: seq=0 ttl=53 time=10.960 ms
64 bytes from 172.217.4.164: seq=1 ttl=53 time=10.780 ms


To use the SFP port such as the eth0 interface shown above in the picture, connect the 10G SFP cable between the eth0 port on the MACCHIATObin and the switch. Then try the dhclient command to acquire the Ethernet address on this port.

# dhclient eth0
[  285.128817] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[  285.220836] mvpp2 f2000000.ppv22 eth0: link up
[  285.225324] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
#


Check the IP address and do a ping test to confirm the network connection.

# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:00:00:00:51:81
          inet addr:10.82.40.144  Bcast:10.82.43.255  Mask:255.255.252.0
          inet6 addr: fe80::200:ff:fe00:5181%141779520/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:140 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:2048
          RX bytes:21139 (20.6 KiB)  TX bytes:942 (942.0 B)
          Interrupt:124 Memory:f2000000-f208ffff

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1%141781824/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)

# ping www.google.com
PING www.google.com (172.217.5.68): 56 data bytes
64 bytes from 172.217.5.68: seq=0 ttl=53 time=11.004 ms


Now you have the network configured on your MACCHIATObin.

To auto configure the Ethernet ports during the Linux boot, you may edit the file /etc/network/interfaces to add the configure requirments for the interfaces. The example interfaces file below will bring up the eth2 port with dhcp client by default.

# cat /etc/network/interfaces
# interface file auto-generated by buildroot

auto lo
iface lo inet loopback

auto eth2
iface eth2 inet dhcp


For Ubuntu root file system, when you setup the /etc/network/interfaces like the example above, it will get you wait for 5 minutes when you boot the MACCHIATObin without the Ethernet cable plugged in. Please change the file like below, this allows the network configuration being bypassed if the Ethernet cable is not inserted. Once you plug in the cable afterward, Ubuntu will automatically configure the ip address on that port for you.

root@localhost:~# cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

allow-hotplug eth2
iface eth2 inet dhcp


If you want to have your Ethernet port statically configured, please use the /etc/network/interfaces below as an example:

root@localhost:~# cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto eth2
iface eth2 inet static
        address 192.168.1.100
        netmask 255.255.255.0
        gateway 192.168.1.254