LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Assignment of IP-Address (https://www.linuxquestions.org/questions/linux-software-2/assignment-of-ip-address-334177/)

santosh_pn 06-16-2005 07:23 AM

Assignment of IP-Address
 
Hi,

How to assign the IP-Address to a system by software.

Regards.

Bruce Hill 06-16-2005 07:32 AM

netconfig

Half_Elf 06-16-2005 10:31 AM

ifconfig eth0 1.2.3.4

Lleb_KCir 06-16-2005 10:47 AM

if you are using debian, then you can edit your /etc/network/interfaces file and put all of the data there you need:

when i get to the house i will post what my interfaces file looks like and explain why i do it the way i do.

Lleb_KCir 06-16-2005 11:22 AM

here is the /etc/network/interfaces file on my laptop.

Code:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
#auto eth0
#iface eth0 inet dhcp
#iface eth0 inet static
#        address 192.168.2.50
#        netmask 255.255.255.0
#        network 192.168.2.0
#        broadcast 192.168.2.255
#        gateway 192.168.2.1
#        address 192.168.1.55
#        netmask 255.255.255.0
#        network 192.168.1.0
#        broadcast 192.168.1.255
#        gateway 192.168.1.1

auto wlan0
#iface wlan0 inet dhcp
 iface wlan0 inet static
        address 192.168.2.55
        netmask 255.255.255.0
        network 192.168.2.1
        broadcast 192.168.2.255
        gateway 192.168.2.1

the reason i have the eth0 # out is that i do not want to use that connection when i am at the house. it is enough of a pain in the arse to get the ndiswrappers to work properly after a reboot (takes about 5-20 attempts to get it stable and working). I also set a static IP for the wlan0 so i always know exactly what LAN IP my laptop has for when i am going to ssh into that box.

In the eth0 you notice it has 2 differnt sets of IPs. one is for the house when i do use the eth0 (only when i get really tired of ndiswrappers locking up my laptop) and the other is when i am at the office. this allows me to go in and just remove the # for the proper IP range, if i want to go static, then type the following command:

Code:

ifconfig restart
and poof away i run on the eth0. you do have to # out the wlan0 portion to prevent it from giving you fits while running on the eth0.

notice that i also have the dhcp setting line for both eth0 and wlan0 device. If i choose or need to use the local DHCP server, then i comment everything else out, and uncomment the line with the iface device inet dhcp and away i go after running the above command to restart my network.

FYI if the above line does not work you should also be able to type the following:

Code:

/etc/init.d/networking restart
that should also do the trick. you can always replace restart with stop/start and do the command 2 times. ifconfig maybe up/down not restart/stop/start but either way it will get the job done for you.

best of luck.


All times are GMT -5. The time now is 02:54 PM.