Results 1 to 6 of 6

Thread: [SOLVED] Configure Network Addreses from command line!

  1. #1
    Join Date
    Oct 2008
    Location
    Panama City
    Beans
    175
    Distro
    Ubuntu 8.04 Hardy Heron

    [SOLVED] Configure Network Addreses from command line!

    Hello, anyone can help me in how to configure the network addresses like
    ip, dns, gateway, mask, from command line without using the gui interface?

    Thanks

  2. #2
    Join Date
    Mar 2008
    Beans
    1,755

    Re: Configure Network Addreses from command line!

    DNS I am not sure about but assigning a static IP is easy.I have already wrote a guide for it that I will copy and paste here.

    Before I begin I would like to make any readers aware that this guide is Debian (and its derivatives) specific. This means that you will not be able to go in Slackware or RHEL and expect files mentioned in this guide to exist because they will not.

    This guide will show you how a static IP address is set up. It is a fairly simple processes so lets get started.


    [edit] Setting the Static IP

    The file that contains the configurations for your network interfaces is located at /etc/network/interfaces. Here is an example of the default configuration of that file:

    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


    As you can see each interface is represented by two lines. The first one indicates whether or not the interface will activate automatically or manually. The above configuration automatically brings up the eht0 interface whenever a) the computer is rebooted b) networking is restarted. Here is an example of manual and automatic setups:

    Automatic:

    auto eth0

    Manual:

    manual eth0

    Whenever a interface is set to manual this means that it must be started with the command "sudo ifconfig INTERFACE up".
    Now, moving along to the second line of the interface. This will determine if your network address is acquired via DHCP or statically set. In the above example (default) it is set to dhcp indicated by the dhcp at the end of the line. In order to get a static address we will change "dhcp" to "static". Then we will have three new lines. These lines will be, in order: IP address, subnet mask, default gateway.

    I am a big fan of examples, so lets have a look:

    DHCP:

    iface eth0 inet dhcp

    Static:

    iface eth0 inet static

    address 192.168.192.24

    netmask 255.255.255.0

    gateway 192.168.192.1

    Once you have made the change then you must restart networking. This is done with the following command:

    sudo /etc/init.d/networking restart


    So complete it would look like this:

    auto eth0
    iface eth0 inet static
    address 192.168.192.24
    netmask 255.255.255.0
    gateway 192.168.192.1

  3. #3
    Join Date
    Apr 2005
    Beans
    13

    Re: Configure Network Addreses from command line!

    cd into /etc/network/ in there is the config file called interfaces
    to access and change the config settings type
    sudo nano interfaces

  4. #4
    Join Date
    Jun 2008
    Location
    Colombia
    Beans
    443

    Re: Configure Network Addreses from command line!

    To quickly make the changes
    Code:
    sudo ifconfig <interface> <ip> netmask <netmask>
    That won't be preserved if you reboot.

    To set a new gateway
    Code:
    route add
    Not sure about the exact syntax after that, but you can search for it or use man route.

    To set DNS, you have to modify a text file
    Code:
    sudo nano /etc/resolv.conf
    Add the server's ip like this
    Code:
    nameserver <ip>

  5. #5
    Join Date
    Oct 2008
    Location
    Panama City
    Beans
    175
    Distro
    Ubuntu 8.04 Hardy Heron

    Re: Configure Network Addreses from command line!

    Awesome help guys! everyting works, sorry i dont want to use the gui that much, the gui is easy, i want something more advance then i use the gui hehehe..
    thanks.

  6. #6
    Join Date
    Oct 2005
    Beans
    107

    Re: [SOLVED] Configure Network Addreses from command line!

    Just to inform:
    A fix is found in:
    http://ubuntuforums.org/showthread.php?p=6049183

    and that is far easier then the fixes mentioned in this thread. also enables you to still use network manager.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •