This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM3352: Static IP address configuration

Part Number: AM3352

Tool/software: Linux

Hi Yordan

I have a related question need your help.

As below your steps, I can set static ip as default on one port, but it would cause other ports disappear. (there are two eth and one wlan on my board)

How could I make other ports show on ifconfig? (pic 1 is current ifconfig, pic 2 is default ifconfig)

Modify the /lib/systemd/system/systemd-networkd.service file:                                                                                                                                                                                                                                                    

#ExecStart=/lib/systemd/systemd-networkd                                          /*The default configuration has this enabled. COMMENT IT*/                  

ExecStart= ExecStart=/sbin/ifup eth1                                                    /*Add this line so that systemd runs ifup upon board boot*/         

  • Hi,

    ifconfig by default I believe (I could be wrong) shows the active interfaces. The difference in your two pictures is "possibly" due to that none of the interfaces in the second picture is active since there is not an external (non-loopback) ip address is defined and the fallback is to show all the interfaces. Once eth0 has the static address it becomes the active interface .

    If you perform "ifconfig -a show" you will see all the interfaces.

    Best Regards,
    Schuyler
  • Hi Schuyler

    I tried, if I use ifup eth0, ifup eth1 and ip link set wlan0 up in system, all device would show in ifconfig

    Now, I want to do this in code.

    BTY, I have to set static ip on both eth0 and eth1.

    I tried

    ExecStart=/sbin/ifup eth0

    ExecStart=/sbin/ifup eth1    

    ExecStart=/sbin/ip link set wlan0 up

    if I wrote both this three ExecStart,both eth0 eth1 wlan0 would disappear.

  • Hi ,

    OK, I think you are asking about how to setup static interfaces. If the system is systemD based there may be more ways that one to set up static interfaces. Here is one that you might want to try set up static a interfaces, your setup will vary as I guess what the gateway would be. You will need a file for each interface.

    Please try this to see if this creates your static ip, create this file in this directory /etc/systemd/network/01-eth-static.network.

    ---- File contents -----
    [Match]
    Name=eth0

    [Network]
    Address=192.168.66.66
    Broadcast=192.168.66.255
    Netmask=255.255.255.0
    Gateway 192.168.66.1

    ----- EOF -----------

    Best Regards,
    Schuyler
  • Hi Schuyler

    I meet a big problem with this solution.

    I have two files

    one is 01-eth.network

    another is 10-eth.network

    code as below

    01-eth.network

    [Match]
    Name=eth0
    KernelCommandLine=!root=/dev/nfs

    [Network]
    Address=192.168.66.66
    Broadcast=192.168.66.255
    Netmask=255.255.255.0
    Gateway=192.168.66.1

    10-eth.network

    [Match]
    Name=eth1
    KernelCommandLine=!root=/dev/nfs

    [Network]
    Address=192.168.66.88
    Broadcast=192.168.66.255
    Netmask=255.255.255.0
    Gateway=192.168.66.1

    In kernal, eth0 ip is 192.168.66.66; eth1 ip is 192.168.66.88

    when I ping eth1, both 192.168.66.66 and 192.168.66.88 are work ,means both 66 and 88 work on eth1

    when I ping eth0, both 192.168.66.66 and 192.168.66.88 are fail

     

  • Hi,

    This is expected behavior for the Linux kernel. Ethernet ports cannot be on the same subnet eth0 and eth1. Both ports are using the .66 subnet, one has to be different.

    This presentation highlights what is happening, starting about slide 51.

    training.ti.com/eth_sys_sw_am_devices

    Best Regards,
    Schuyler
  • Hi Schuyler

    My eth0 ip is 192.168.66".66", eth1 is  192.168.66".88"

    There are different.

  • Hi,

    The eth0 xx.xx.xx.66 and eth1 xx.xx.xx.88 are the host identifiers. The number I am referring to is the subnet identifier which in this example is xx.xx.66.xx and is the same for both eth0 and eth1 interfaces. The .66 cannot be the same for both interfaces. One example on how to resolve the problem would be to assign eth0 as 192.168.66.66 like it is currently and assign eth1 to 192.168.67.88.

    Since both eth0 and eth1 were on the same subnet this will cause a change to the network topology that you have, whatever eth1 is connected will now need to be placed on a different subnet or network.

    Best Regards,
    Schuyler
  • Hi Schuyler

    Bad news.

    If I try your new solution, both eth0 and eth1 would fail.

    static ip is right in ifconfig, but both this two ports can't be ping.

    01-eth-static.network

    [Match]

    Name=eth0

    KernelCommandLine=!root=/dev/nfs

    [Network]

    Address=192.168.66.66

    Gateway=192.168.66.1

    10-eth.network

    [Match]

    Name=eth1

    KernelCommandLine=!root=/dev/nfs

    [Network]

    Address=192.168.67.88

    Gateway=192.168.67.1

  • Hi Schuyler
    I saw an information on web as below, can it use on AM335X?
    if yes, where can I add this code?
    ***
    if both two lan card use same subnet, Linux would bind two IP on first card by auto, another would fail.
    setting routing table would make both two cards work.
    ip route add 172.16.10.0/24 dev eth0 src 172.16.10.10 table 10
    ip route add default via 172.16.10.251 table 10
    ip route add 172.16.10.0/24 dev eth1 src 172.16.10.20 table 20
    ip route add default via 172.16.10.251 table 20
    ip route add 172.16.10.0/24 dev eth0 src 172.16.10.10
    ip route add 172.16.10.0/24 dev eth1 src 172.16.10.20
    ip route add default via 172.16.10.251
    ip rule add from 172.16.10.10 table 10
    ip rule add from 172.16.10.20 table 20
    ip route flush cache

    add the script to /etc/rc.local
    ***
    others:
    askubuntu.com/.../set-up-two-ip-addresses-with-one-gateway
  • Hi,

    It might be possible but this is beyond the support that TI provides since this above the cpsw driver and is up in the IP routing of the kernel.

    Is there a reason you want both ports on the same subnet?

    Best Regards,
    Schuyler
  • Hi Schuyler
    Because of there are two eth ports on our board.
    When we use a IP sharer, the host IP is 192.168.66.xxx, gateway IP is 192.168.66.1
    Through the sharer assign IP, the eth on board would get IP as 192.168.66.xxx, right?
    We can't make sure that user would connect the Lan to eth0, eth1 or both this two.
    If we set different subnet on both those two ports, one of port would fail when get IP from IP sharer.
    So, the base way is setting same subnet on both those two ports.

    thanks.