How to set a static IP Address in Linux

preview_player
Показать описание
Here is a quick tutorial video on how to set up a static IP address in Linux. I assume that you have not changed any of your IP address settings in your modem/router, but if you have you'll get the information you need from ifconfig. I know there are a couple other ways to do this, but this seems the simplest to me.

I do zoom in on the video, so you won't need to worry if you can't, or don't, want to watch this in high definition.

A few errors I made in the video
1. I declared eth1 as the adapter to give a static address. If you only have one NIC in your machine, it will be eth0.
2. The command I gave to restart networking should have been $ sudo /etc/init.d/networking restart.
Рекомендации по теме
Комментарии
Автор

thank you so much, after trying a couple of other guides this finally worked and i have my static IP

rafaeldomenikos
Автор

Thanks! I got a problem with my gateway value. Your video helped me

cyjexdc
Автор

@barnbarn122
Either contacting your ISP to setup a static IP address, or using DynDNS (or something like it), you would then set up port forwarding on your modem/router (to the port that MineCraft uses for communications).
I wish I could give you exact directions, but this will vary depending on the company/equipment/software.

FuzzyGhost
Автор

@alnuwan
Not having used Redhat, I'm unfamiliar with the directories, but I found this guide that is hopefully still relevant. Otherwise, you can use the ifconfig command to statically set it.

FuzzyGhost
Автор

@barnbarn122
I've not used Hamachi, but I've not had a need for a Virtual Private Network. Are you sure you need that for a Minecraft server? Seems like you would just need a public static IP address, which would cost extra with your ISP, or using a Dynamic DNS client.

FuzzyGhost
Автор

@barnbarn122
DynDNS makes sure that any attempt at finding your domain, points to your network, even though you have a changing network address.

FuzzyGhost
Автор

btw, not sure if you've encountered this problem, but with both, debian-based and red hat-based distros, i've had NetworkManager screw up these configurations.
NetworkManager seems to override these settings and do it's own thing.
if you're going to do it this way, i recommend stopping the NM daemon, or removing it altogether.
(even though in RH-based distros, you can add an option in the ifcfg-eth0 file that says "NM_CONTROLLED=no" and you should be fine with that)

sleepee
Автор

I would have, if I had known that. I've mainly stuck to Ubuntu, but I've experimented with Fedora, Open SuSE, Damn Small Linux, IPCop, and a couple others I can't remember.
How does it differ though? Is it just a different directory, completely different syntax structure, both?

FuzzyGhost
Автор

@barnbarn122
The principle and method are the same, just swap out the name of the networking device. Instead of using eth0, us whatever ifconfig pops up for your wireless networking device (for example, wlan0).

FuzzyGhost
Автор

@FuzzyGhost Wow thats confusing...I know how to port forward (port on MC is 25565 and i have a d-link router) and my ISP is xfinity/comcast. So what does DynDNS do?

barnbarn
Автор

well, the "/etc/resolv.conf" and "/etc/hosts" file are the same, but in red hat based distros, instead of "/etc/network/interfaces", the info for the network interfaces is stored in (assuming it's for the eth0 interface).
the hostname is stored in the "/etc/sysconfig/network" file
also the syntax is slightly different.
for example, instead of "address 192.168.x.x" you write "IPADDR=192.168.x.x"
not a huge change, but it's noteworthy.

sleepee
Автор

@FuzzyGhost Well thanks but I'm only trying to make a public minecraft server for a few friends and hamachi wont work on Wine(Linux mint 11) Any help?

barnbarn
Автор

@FuzzyGhost lol i'm not into networking that much but exactly how would i setup a server with my public ip and port so anyone could get on it?

barnbarn
Автор

What happened when you tried the above commands?

FuzzyGhost
Автор

Can you copy & paste the whole error message?

FuzzyGhost
Автор

Ronny OnBass Can you provide some information as to what your goal was, and what didn't work?

FuzzyGhost
Автор

I use redhat as a guest in windows 7 host using virtualbox. I do not see the /etc/network/interfaces file. help?

alnuwan
Автор

Can some1 explain to me y my eth0 inet addr is 10.0.02.15 instead of like 192.168.02.108
Every video I see their inet addr starts with 192 why doesn't mine

LGNDxZannu
Автор

you should've specified that this is for debian-based linux distros.
redhat based distros are totally different as far as setting up static ip's..

sleepee
Автор

why use ethic when your ifconfig showed wlan an eth0, this kind of random assignment is what causes confusion when we are trying to learn and copy. Just a heads up. You should have explained why not using ethic, or wlan, are they different, do we have a choice, can it be random ? I dunno

benjaminwarr