# ifconfig Weird situation

**URL:** <https://forums.digi.com/t/ifconfig-weird-situation/10238>\
**Category:** Rabbit\
**Created:** [February 3, 2009, 10:20pm UTC](https://forums.digi.com/t/ifconfig-weird-situation/10238 "2009-02-03T22:20:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![seulater](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@seulater](https://forums.digi.com/u/seulater)\
**Post date:** [February 3, 2009, 10:20pm UTC](https://forums.digi.com/t/ifconfig-weird-situation/10238/1 "2009-02-03T22:20:30Z")

</div>

I need my app to be able to switch from using DHCP to Static configurations depending on a jumper on the board. For right now i am using the static configuration.

To prove that its working i have defined the following:  
#define \_PRIMARY\_STATIC\_IP “192.168.0.9”  
#define \_PRIMARY\_NETMASK “255.255.255.0”  
#define MY\_GATEWAY “192.168.0.1”  
#define MY\_NAMESERVER “192.168.0.1”

I have pourposly made the static IP x.x.x.9 so that if ifconfig really works my IP should be x.x.x.10, see below…

In my main i have the following:

```
// Set Up Static IP information on Network Interface
ifconfig(IF_ETH0,
				IFS_DOWN,
               	IFS_IPADDR, aton("192.168.0.10"),
               	IFS_NETMASK,aton("255.255.255.0"),
               	IFS_ROUTER_SET, aton("192.168.0.1"),
               	IFS_NAMESERVER_SET, aton("192.168.0.1"),
               	IFS_NAMESERVER_ADD, aton("192.168.0.1"),
                IFS_UP,
               	IFS_END);

// Wait for interface to come up
while (ifpending(IF_ETH0) == IF_COMING_UP)
{
	tcp_tick(NULL);
}

if (ifpending(IF_ETH0) == IF_UP)
{
	printf("Ethernet Is Up

```

");  
}  
else  
{  
printf("Ethernet Failed To Come Up  
");  
}

Now, after it boots all is well. i can ping it at its IP @ x.x.x.10.

Yet when i add a TCP listener it does not work. then if i comment out the above and add “sock\_init\_or\_exit(1);” my TCP listener works just fine. whats the deal ?

---

<div class="post-metadata">

**Author:** ![Ski1](https://avatars.discourse-cdn.com/v4/letter/s/5fc32e/32.png) [@Ski1](https://forums.digi.com/u/Ski1)\
**Post date:** [February 6, 2009, 9:41pm UTC](https://forums.digi.com/t/ifconfig-weird-situation/10238/2 "2009-02-06T21:41:34Z")

</div>

Where does your sock\_init occure in your program? Remember it only needs to be called once so if it is in a loop it could cause complications. Hope this helps; it took me a few head bangs to figure out a simular problem.

---

<div class="post-metadata">

**Author:** ![seulater](https://avatars.discourse-cdn.com/v4/letter/s/54ee81/32.png) [@seulater](https://forums.digi.com/u/seulater)\
**Post date:** [February 6, 2009, 9:43pm UTC](https://forums.digi.com/t/ifconfig-weird-situation/10238/3 "2009-02-06T21:43:25Z")

</div>

Thanks, that was the problem. :o
