4

In https://askubuntu.com/a/470245/1471

  1. You will need you need to change /etc/network/interfaces to:

    auto eth0
    iface eth0 inet static
       address 10.253.0.50
       netmask 255.255.255.0
       network 10.253.0.0
       gateway 10.253.0.1
       dns-nameservers 8.8.8.8
    

    what do the first and second lines mean? In particular, what do auto, iface, and inet mean?

    What does network mean?

    Is gateway the router?

  2. You will have to change the numbers around depending on you network, but you can find out the information by checking out ipconfig from Windows.

    Can I find out the dns-nameservers, gateway, network, netmaskt, and address in Ubuntu, instead of in Windows?

  3. Is there an alternative way of setting up static IP, instead of editing etc/network/interfaces? For example, provide the settings as arguments to some commands?
Tim
  • 25,177

2 Answers2

5

auto eth0 : This is Link layer option that will start the interface(s) at booting of system automatically.

iface eth0 : iface is suffix of defining interface and creates a stanza called eth0 on an Ethernet device.This is Network layer option.

inet and inet6 is version of ip protocol:

inet : IPv4 protocol inet6 : IPv6 protocol

inet static : Defines a static IP address of interface.

inet dhcp : It get IP address from DHCP protocol.

inet manual : It Does not define an IP address for an interface. Generally used by interfaces that are bridge , aggregation members,VLAN device configured on them etc.

What does network mean?

network : It define class of Network like A,B,C etc. in which IP address belong to .you can learn more about network and class from here and here

Is gateway the router?

No, gateway can be any where all data/packet pass through to go somewhere and router used to communicate two or more different network.

Can I find out the dns-nameservers, gateway, network, netmask, and address in Ubuntu, instead of in Windows?

For IP address,netmask,MAC address, Broadcast IP use command :

ifconfig : It will print all interface IP

ifconfig eth0 : It will print only particular interface eth0 IP

For dns-nameservers you can see in /etc/resolv.conf file

For gateway use command:

route -n 

or

netstat -nr

Is there an alternative way of setting up static IP, instead of editing etc/network/interfaces

if you are using Ubuntu server then you can use @kyodake answer or other but if you are using Ubuntu Desktop environment then you can

System setting -->  Network --> Wired --> options --> IP4 settings 

pic

you can take help from here

pl_rock
  • 11,297
  • thanks. what is inet? What did you mean by network? – Tim Oct 24 '15 at 05:08
  • inet and inet6 is version of ip protocol: inet : IPv4 protocol inet6 : IPv6 protocol. i have added this in answer. – pl_rock Oct 24 '15 at 05:18
  • route or netstat may list multiple gateways, how do you choose which one to use for static IP? – Tim Oct 24 '15 at 17:28
  • it list which interface and ip have what gateway. if any network shows gateway 0.0.0.0 means default gateway will use(generally default gatway is first line of output ) . otherwise every network have gateway if multiple entry then upper entry will used as gateway – pl_rock Oct 24 '15 at 17:39
  • if you want to change gateway command line then you can change also. you can understand more from http://www.thegeekstuff.com/2012/04/route-examples/ and http://askubuntu.com/questions/168033/how-to-set-static-routes-in-ubuntu-server – pl_rock Oct 24 '15 at 17:47
  • THanks. Can you give examples for explaining " if any network shows gateway 0.0.0.0 means default gateway will use(generally default gatway is first line of output )" and "otherwise every network have gateway if multiple entry then upper entry will used as gateway"? – Tim Oct 24 '15 at 18:01
1

Is there an alternative way of setting up static IP, instead of editing etc/network/interfaces?

Yes:

If you connect via a regular UTP cable to your router, and assuming you have DHCP enabled do the following:

sudo -i
ip link set dev eth0 down
dhclient eth0

This will bring your eth0 up by using DHCP and your network is now configured.

If you don't have DHCP enabled configure your network by issueing the commands below, the gateway address is the IP address of your router. And your IP should be in the same range as the router is.

sudo -i
ip addr add 10.10.1.14/24 dev eth0
ip link set dev eth0 up
ip route add default via 10.10.1.1

These commands configure your interface but these changes will not survive a reboot, since the information is not stored anyhwere.

Source

kyodake
  • 15,401