LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Setting Static IP (https://www.linuxquestions.org/questions/linux-newbie-8/setting-static-ip-4175507892/)

AndrewNZ 06-12-2014 06:19 PM

Setting Static IP
 
Hi

I have changed the file /etc/network/interfaces to the following to set a static IP but this does not seem to work:


# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

iface eth0 inet static
address 192.168.20.5
netmask 255.255.255.0
network 192.168.20.0
broadcast 192.168.20.255
gateway 192.168.20.2
dns-namesevers 121.98.0.1 121.98.0.2

Where am I going wrong?

frankbell 06-12-2014 07:52 PM

The gateway looks odd to me. They are usually xxx.xxx.xxx.001, but "usually" certainly doesn't mean always.

Here's a copy of my /etc/network/interfaces in case it helps.

Code:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet static
address 192.168.2.5
netmask 255.255.255.0
gateway 192.168.2.1


btmiller 06-12-2014 08:48 PM

Also "does not seem to work" is a bit vague ... what actually happens? Does the interface come up, but still get a DHCP IP address? Does it not come up at all? Does it come up with the correct IP but is not able to communicate?

AndrewNZ 06-12-2014 10:07 PM

After I restart networking it only comes up with the local loopback details and nothing else.

Tadaen 06-12-2014 10:09 PM

no auto or allow-hotplug eth0 line. it doesn't realize there is an interface to bring up?

AndrewNZ 06-13-2014 04:39 AM

I have edited the file to be:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

iface eth0 inet static
address 192.168.20.1
netmask 255.255.255.0
gateway 192.168.20.2

then I write sudo service networking restart and then I get the following when typing ifconfig

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1184 errors:0 dropped:0 overruns:0 frame:0
TX packets:1184 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:60502 (60.5 KB) TX bytes:60502 (60.5 KB)

Tadaen 06-13-2014 11:59 AM

I'll say it again. Look at the differences between the lo and the eth0. You are missing a line. From my minecraft server.

Code:

jason@debian75:~$ cat /etc/network/interfaces
# 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
allow-hotplug eth0 # could also be auto eth0
iface eth0 inet static
        address 10.0.1.176
        netmask 255.255.255.0
        gateway 10.0.1.1
        dns-nameservers 8.8.8.8 8.8.4.4


AndrewNZ 06-14-2014 12:46 AM

thank you now I have a static IP

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.20.55
netmask 255.255.255.0
gateway 192.168.20.2
dns-nameservers 8.8.8.8 8.8.4.4

but I cant ping externally , nothing in IP tables seems to be blocking

Chain INPUT (policy ACCEPT)
target prot opt source destination

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Resolv.conf is

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 192.168.20.1
nameserver 127.0.1.1
search Home

# OpenDNS Fallback (configured by Linux Mint in /etc/resolvconf/resolv.conf.d/tail).
nameserver 208.67.222.222
nameserver 208.67.220.220

Thank you.

Tadaen 06-14-2014 05:30 PM

Quote:

# OpenDNS Fallback (configured by Linux Mint in /etc/resolvconf/resolv.conf.d/tail).
If this is a desktop linux mint install then you need to undo all of this in the /etc/network/interfaces file and use the gui network configuration. Stuff directly in the /etc/network/interfaces can't be managed by the mint networking tool.

DJ Shaji 06-14-2014 06:11 PM

Quote:

Originally Posted by Tadaen (Post 5188207)
If this is a desktop linux mint install then you need to undo all of this in the /etc/network/interfaces file and use the gui network configuration. Stuff directly in the /etc/network/interfaces can't be managed by the mint networking tool.

That or stuff like NetworkManager / Wicd might be managing the device. Use these or the /etc/network interface, one or other but not both


All times are GMT -5. The time now is 06:57 AM.