change IP address (static/DHCP)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

change IP address (static/DHCP)

13,310 Views
niklasmolin
Senior Contributor I

Hi.

I'm running an image (Yocto) on a SabreSD board and wonder how I change from DCHP client mode to static mode, when it comes to setting the network port?

How do I a turn on/off DHCP from the command line?

Also, how do I change the MAC address?

Thanks,

Niklas

Labels (2)
6 Replies

5,714 Views
AnsonHuang
NXP Employee
NXP Employee

To disable DHCP, please remove it(ip=dhcp) in uboot command line;

To use a static IP, you can use ifconfig command such as:

ifconfig eth0 10.192.242.117

To change MAC address, you can use below command in commandline:

fec.macaddr=0x00,0x10,0x20,0x30,0x40,0x88

5,714 Views
niklasmolin
Senior Contributor I

Hi Yongcai.

This means that I can only run the image with either DCHP on or off.

In our case we want to be able to change it dynamically, when the Linux image is running.

I found in /etc/networking/interfaces that I think I should be able to change this setting.

0 Kudos

5,714 Views
b36401
NXP Employee
NXP Employee

As for MAC address it can be permanently changed by burning e-fuse.
Alternatively you can add the command like this

ifconfig eth0 hw ether 00:04:9f:00:e9:bb

into init script of the system to overwrite the value.

5,714 Views
b36401
NXP Employee
NXP Employee

You can simply add "ifconfig" command with exact IP address into system init script.
And when the system is running you can use "ifconfig" command as well.

0 Kudos

5,714 Views
claymontgomery
Contributor IV

The better way to configure eth0 for a static IP address, rather than dhcp, is like this in the  /etc/network/interfaces  file:

# Wired or wireless interfaces
auto eth0
#iface eth0 inet dhcp
iface eth0 inet static
        address 192.168.0.100
        netmask 255.255.255.0
        gateway 192.168.0.1

There is a good tutorial here:

   https://www.howtoforge.com/tutorial/howto-set-a-static-ip-on-ubuntu/ 

Regards, Clay

0 Kudos

5,714 Views
AnsonHuang
NXP Employee
NXP Employee

as far as I know, if you want to enable DHCP, you can ifconfig eht0 down, then ifconfig eth0 up, udhcpc eth0.....not sure whether it helps.

0 Kudos