# Restart network interface

**URL:** <https://forums.digi.com/t/restart-network-interface/9882>\
**Category:** Rabbit\
**Created:** [May 9, 2007, 11:29am UTC](https://forums.digi.com/t/restart-network-interface/9882 "2007-05-09T11:29:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![koutasek](https://avatars.discourse-cdn.com/v4/letter/k/4bbf92/32.png) [@koutasek](https://forums.digi.com/u/koutasek)\
**Post date:** [May 9, 2007, 11:29am UTC](https://forums.digi.com/t/restart-network-interface/9882/1 "2007-05-09T11:29:41Z")

</div>

Hello,  
how I can restart network interface, when I try reconfigure this interface? I’m using RCM3700 and when I call setIP(), which reconfire ETH0:  
err = ifconfig(IF\_ETH0,  
IFS\_IPADDR, aton(set.ip\_unit),  
IFS\_NETMASK, aton(set.nm\_unit),  
IFS\_ROUTER\_SET,aton(set.gw\_unit),  
IFS\_UP,  
IFS\_END);

err is zero and IP is still old ☹

---

<div class="post-metadata">

**Author:** ![topherfangio](https://avatars.discourse-cdn.com/v4/letter/t/ccd318/32.png) [@topherfangio](https://forums.digi.com/u/topherfangio)\
**Post date:** [May 14, 2007, 10:13pm UTC](https://forums.digi.com/t/restart-network-interface/9882/2 "2007-05-14T22:13:40Z")

</div>

Don’t know if it is happening to you, but I had to manually disable the DHCP configuration in order to switch.

Should be able to do so with:

ifconfig( IF\_ETH0, IFS\_DHCP, 0, IFS\_END );

However, I am using the RCM4000 and the calls may be different. Also, I don’t see you using IFS\_DOWN at the beginning. You may not be able to bring it up before it goes down.

---

<div class="post-metadata">

**Author:** ![Leodox](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@Leodox](https://forums.digi.com/u/Leodox)\
**Post date:** [May 29, 2007, 7:36pm UTC](https://forums.digi.com/t/restart-network-interface/9882/3 "2007-05-29T19:36:08Z")

</div>

koutasek,

Are you calling sock\_init() in setIP() at all? If so, you must call ifconfig() AFTER sock\_init()!

Also, you need to add IFS\_DOWN to the ifconfig() call so that the interface is stopped before you try to change the IP.

Try this:

//Call this before ifconfig()!  
sock\_init();

//Do not forget the IFS\_DOWN  
err = ifconfig(IF\_ETH0,  
IFS\_DOWN,  
IFS\_IPADDR, aton(set.ip\_unit),  
IFS\_NETMASK, aton(set.nm\_unit),  
IFS\_ROUTER\_SET,aton(set.gw\_unit),  
IFS\_UP,  
IFS\_END);

Hope that helps…

---

<div class="post-metadata">

**Author:** ![OmarGarcia](https://avatars.discourse-cdn.com/v4/letter/o/82dd89/32.png) [@OmarGarcia](https://forums.digi.com/u/OmarGarcia)\
**Post date:** [May 29, 2007, 5:49pm UTC](https://forums.digi.com/t/restart-network-interface/9882/4 "2007-05-29T17:49:10Z")

</div>

hi…  
I use this in my programs for Rabbit 3000 :

TCPCONFIG 6  
.  
.  
.  
unsigned long ip\_address;  
unsigned long netmask;  
unsigned long gateway;

ip\_addres=0xC0A80023l;  
netmask=0xffffff00l;  
gateway=0xC0A80001l;

.  
.  
.

ifconfig(IF\_ETH0,IFS\_DHCP,0,IFS\_END);  
ifconfig(IF\_ETH0,IFS\_IPADDR,ip\_address,IFS\_END);  
ifconfig(IF\_ETH0,IFS\_NETMASK,netmask,IFS\_END);  
ifconfig(IF\_ETH0,IFS\_ROUTER\_SET,gateway,IFS\_END);  
ifconfig(IF\_ETH0,IFS\_UP,IFS\_END);

while (ifpending(IF\_ETH0)&1)  
{  
tcp\_tick(NULL);  
}

i hope this code help you
