TS-4900 Network configuration example: Difference between revisions

From embeddedTS Manuals
No edit summary
No edit summary
Line 1: Line 1:
Most commonly networks will offer DHCP which can be set up with one command:
Our default yocto image uses systemd which stores its network files in "/etc/systemd/network/".  The simplest network config would look like this:
<source lang=bash>
# To setup the network for this boot:
udhcpc -i eth0
# Or if you're on a baseboard with a second ethernet port, you can use that as:
udhcpc -i eth1


# To instead manually configure the interface for this boot:
In /etc/systemd/network/50-eth.network
killall udhcpc
<source lang=ini>
# Set IP + subnet mask
[Match]
ifconfig eth0 192.168.0.50 netmask 255.255.255.0
Name=eth*
# Set default gateway, usually your router
 
route add default gw 192.168.0.1
[Network]
# Set your DNS server
DHCP=yes
echo "nameserver 8.8.8.8" > /etc/resolv.conf
</source>
 
For a static configuration you would create a config file for that specific interface.
/etc/systemd/network/10-static-eth0.network
<source lang=ini>
[Match]
Name=eth0
 
[Network]
Address=192.168.0.50/24
Gateway=192.168.0.1
DNS=192.168.0.1
</source>
</source>


To make your network settings take effect on startup in Yocto, edit /etc/network/interfaces: 
For more information on what options are available to configure the network, see the [http://www.freedesktop.org/software/systemd/man/systemd.network.html systemd network documentation].
  # We always want the loopback interface.                        
  #                                                               
  auto lo                                                         
  iface lo inet loopback                                           
                                                                   
  auto eth0                                                       
  iface eth0 inet static                                           
    address 192.168.0.50                                           
    netmask 255.255.255.0                                         
    gateway 192.168.0.1                                           
  auto eth1                                                       
  iface eth1 inet dhcp

Revision as of 11:18, 15 January 2015

Our default yocto image uses systemd which stores its network files in "/etc/systemd/network/". The simplest network config would look like this:

In /etc/systemd/network/50-eth.network

[Match]
Name=eth*

[Network]
DHCP=yes

For a static configuration you would create a config file for that specific interface. /etc/systemd/network/10-static-eth0.network

[Match]
Name=eth0

[Network]
Address=192.168.0.50/24
Gateway=192.168.0.1
DNS=192.168.0.1

For more information on what options are available to configure the network, see the systemd network documentation.