LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   problem with releasing a Dynamic IP address (https://www.linuxquestions.org/questions/linux-networking-3/problem-with-releasing-a-dynamic-ip-address-554442/)

dids22 05-16-2007 03:57 PM

problem with releasing a Dynamic IP address
 
hey
first, i use archlinux dis'.
i'm connected to the internet without dialer (some call it mpls)
the way to change the ipin windows is using this script
Code:

ipconfig /release
netsh interface ip set address "local area connection" static 192.168.0.10 255.255.255.0 192.168.0.1 1
ipconfig /release
netsh interface ip set address "local area connection" dhcp

and it's work fine.
i tried to make a similar script for arch- but my ip stay the same
what i do worng?
Code:

#! /bin/bash
INET_IP=`/sbin/ifconfig eth0 | grep 'inet addr' | awk '{print $2}'| sed -e 's/.*://'` #Get IP
echo your old ip was $INET_IP
dhcpcd eth0 -k
ifconfig eth0 192.168.0.2 netmask 255.255.255.0 broadcast 192.168.0.255
sleep 2
dhcpcd eth0
sleep 2
INET_IP=`/sbin/ifconfig eth0 | grep 'inet addr' | awk '{print $2}'| sed -e 's/.*://'` #Get IP
echo your new ip is $INET_IP

ty!!

bsdunix 05-16-2007 07:38 PM

Quote:

i tried to make a similar script for arch- but my ip stay the same
I used your script on my Slackware box and it works fine. My box gets the same DHCP assigned IP also. The DHCP server cached the IP address for the requested MAC address and it hasn't expired yet. Nice script :)

dids22 05-17-2007 05:44 AM

if you get the same ip then the script isn't fine

Quote:

Originally Posted by bsdunix
The DHCP server cached the IP address for the requested MAC address and it hasn't expired yet. Nice script :)

then how u explain that this script working?
Code:

ipconfig /release
netsh interface ip set address "local area connection" static 192.168.0.10 255.255.255.0 192.168.0.1 1
ipconfig /release
netsh interface ip set address "local area connection" dhcp

http://i11.tinypic.com/4uizouq.jpg

bsdunix 05-17-2007 07:17 AM

Quote:

if you get the same ip then the script isn't fine
Quote:

then how u explain that this script working?
I did the DHCP/static changes several times on my Windows box, in about 50% of the time I either get the same IP or next incremented number. During my test, the Slackware box always gets the same IP. Why is Windows different? Must be a Windows thing. :) I don't have a scientific answer for you.


All times are GMT -5. The time now is 11:37 PM.