Project

General

Profile

Setting Static IP Address

In order to configure a static IP address, an entry needs to be made in systemd-network configuration directory

  • Enter systemd-network directory
    root@mitysom-am57x:~# cd /etc/systemd/network/
    
  • By default there is a 15-eth.network which matches all eth* devices and configures them for dhcp
    root@mitysom-am57x:/etc/systemd/network# cat 15-eth.network
    [Match]
    Name=eth*
    KernelCommandLine=!root=/dev/nfs
    
    [Link]
    RequiredForOnline=no
    
    [Network]
    DHCP=yes
    
  • And there is 10-eth.network which only matches eth0, this has priority since the number is lower
    root@mitysom-am57x:/etc/systemd/network# cat 10-eth.network
    [Match]
    Name=eth0
    KernelCommandLine=!root=/dev/nfs
    
    [Network]
    DHCP=yes
    
  • To configure eth0 for example to a static ip address, we create a 01-eth0.network file.
    root@mitysom-am57x:/etc/systemd/network# vi 01-eth0.network
    [Match]
    Name=eth0
    KernelCommandLine=!root=/dev/nfs
    
    [Network]
    Address=192.168.0.29/24
    Gateway=192.168.0.1
    

    This will take precedence since it is the lowest number
    root@mitysom-am57x:/etc/systemd/network# ls
    01-eth0.network            30-wlan.network
    10-eth.network             50-usb-dhcpserver.network
    15-eth.network             60-usb.network
    
  • Restart the network service
    root@mitysom-am57x:/etc/systemd/network# systemctl restart systemd-networkd
    
  • Verify the assigned address
    • Note that the assigned static address will only appear if a cable is plugged in.
      root@mitysom-am57x:/etc/systemd/network# ip address
      root@mitysom-am57x:/etc/systemd/network# ip address show dev eth0
      

Go to top
Add picture from clipboard (Maximum size: 1 GB)