LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-12-2014, 06:19 PM   #1
AndrewNZ
LQ Newbie
 
Registered: Nov 2013
Posts: 16

Rep: Reputation: Disabled
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?
 
Old 06-12-2014, 07:52 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,310
Blog Entries: 28

Rep: Reputation: 6136Reputation: 6136Reputation: 6136Reputation: 6136Reputation: 6136Reputation: 6136Reputation: 6136Reputation: 6136Reputation: 6136Reputation: 6136Reputation: 6136
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
 
Old 06-12-2014, 08:48 PM   #3
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
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?
 
Old 06-12-2014, 10:07 PM   #4
AndrewNZ
LQ Newbie
 
Registered: Nov 2013
Posts: 16

Original Poster
Rep: Reputation: Disabled
After I restart networking it only comes up with the local loopback details and nothing else.
 
Old 06-12-2014, 10:09 PM   #5
Tadaen
Member
 
Registered: Sep 2005
Distribution: Arch
Posts: 210

Rep: Reputation: 39
no auto or allow-hotplug eth0 line. it doesn't realize there is an interface to bring up?
 
Old 06-13-2014, 04:39 AM   #6
AndrewNZ
LQ Newbie
 
Registered: Nov 2013
Posts: 16

Original Poster
Rep: Reputation: Disabled
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)
 
Old 06-13-2014, 11:59 AM   #7
Tadaen
Member
 
Registered: Sep 2005
Distribution: Arch
Posts: 210

Rep: Reputation: 39
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

Last edited by Tadaen; 06-13-2014 at 12:14 PM.
 
Old 06-14-2014, 12:46 AM   #8
AndrewNZ
LQ Newbie
 
Registered: Nov 2013
Posts: 16

Original Poster
Rep: Reputation: Disabled
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.
 
Old 06-14-2014, 05:30 PM   #9
Tadaen
Member
 
Registered: Sep 2005
Distribution: Arch
Posts: 210

Rep: Reputation: 39
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.
 
Old 06-14-2014, 06:11 PM   #10
DJ Shaji
Member
 
Registered: Dec 2004
Location: Yo Momma's house
Distribution: Fedora Rawhide, ArchLinux
Posts: 518
Blog Entries: 15

Rep: Reputation: 106Reputation: 106
Quote:
Originally Posted by Tadaen View Post
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
setting static IP on linux PCs with no static IP address from internet provider? solvetek Linux - Networking 1 10-22-2011 08:04 AM
Setting static IP callumacrae Linux - Server 2 11-12-2009 12:12 PM
setting a static IP roenstad Linux - Newbie 1 10-02-2005 02:56 AM
Setting a static IP hongman Linux - Networking 6 02-22-2005 05:07 AM
setting a static IP EMHagerty Linux - Networking 1 09-09-2004 03:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:23 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration