Setting up a static network IP in Ubuntu

4sak3n

Active Member
Joined
Oct 8, 2008
Messages
38
Reaction score
0
Location
Cape Town
I suspect that this may be over my head because it deals with networking in Linux (EEPS!) but can anyone help me set up a static IP in Ubuntu so that I can do port forwarding on my router?

In Windows one sets this up in the IP properties when you right click your network connection. I have next to know idea how to do that in Ubuntu.

Many thanks for any and all help you can give.
 
alt-f2 > gnome-terminal

sudo nano /etc/network/interfaces

edit it to the following changing IP's etc. as necessary

auto eth0
iface eth0 inet static
address 10.0.0.1
netmask 255.255.255.0
network 10.0.0.2
broadcast 10.0.0.255
gateway 10.0.0.2

ctrl-O [ENTER]
ctrl-X [ENTER]

sudo /etc/init.d/networking restart
 
Thanks for the help. I really appreciate it. But unless I understand what I am doing the help isn't that useful. So let me take a crack at what I know and perhaps you can fill in the blanks in my knowledge.

alt-f2 > gnome-terminal <-- self explanatory

sudo nano /etc/network/interfaces <-- open interfaces file ... in Linux everything is file based. Even partitions and flash drives are represented by a file. So naturally the network rules are stored in a file somewhere.

edit it to the following changing IP's etc. as necessary

auto eth0 <-- would change this to wlan0 in my case because I'm using wireless
iface eth0 inet static <-- telling the interface to use static IP
address 10.0.0.1 <-- IP address to use
netmask 255.255.255.0 <-- netmask ... it always seems to be 255.255.255.0 no matter what
network 10.0.0.2 <-- ?
broadcast 10.0.0.255 <-- ?
gateway 10.0.0.2 <-- gateway ... this would be my router's IP yes?

ctrl-O [ENTER] <-- shortcut for ... ?
ctrl-X [ENTER] <-- shortcut for ... ?

sudo /etc/init.d/networking restart <--restart the network device to use new settings

Still not 100% on what everything does but working through it line by line does make it somewhat clearer.
 
Last edited:
Thanks for the help. I really appreciate it. But unless I understand what I am doing the help isn't that useful. So let me take a crack at what I know and perhaps you can fill in the blanks in my knowledge.

alt-f2 > gnome-terminal <-- self explanatory

sudo nano /etc/network/interfaces <-- open interfaces file ... in Linux everything is file based. Even partitions and flash drives are represented by a file. So naturally the network rules are stored in a file somewhere.

edit it to the following changing IP's etc. as necessary

auto eth0 <-- would change this to wlan0 in my case because I'm using wireless
iface eth0 inet static <-- telling the interface to use static IP
address 10.0.0.1 <-- IP address to use yes
netmask 255.255.255.0 <-- netmask ... it always seems to be 255.255.255.0 no matter what
network 10.0.0.2 <-- ? made a mistake here, should be 10.0.0.0 ie. the network you're on
broadcast 10.0.0.255 <-- ? IP address when sending a broadcast packet
gateway 10.0.0.2 <-- gateway ... this would be my router's IP yes? yes

ctrl-O [ENTER] <-- shortcut for ... ? saving the changes
ctrl-X [ENTER] <-- shortcut for ... ? exiting

sudo /etc/init.d/networking restart <--restart the network device to use new settings yes, restart the network daemon so new changes take effect

Still not 100% on what everything does but working through it line by line does make it somewhat clearer.

I prefer using the interfaces file and pppoeconf (for setting up broadband dial up connections) instead of using the ubuntu network manager.
 
Thanks for taking the time to help BlaQ_Phoenix.

As I understand things then my file should be as follows:

auto wlan0
iface wlan0 inet static
address 192.168.1.100 <-- could be anything from 1 to 253
netmask 255.255.255.0
network 192.168.1.0 <-- not sure on this ... is it my gateway with a 0 at the end?
broadcast 191.168.1.255 <-- ditto on not sure ... IP with 255 on the end?
gateway 192.168.1.254 <-- here's my router's IP.

I tried the network manager and had no luck with that. Then again I might have put in bum settings rather than it being a fault with the network manager. Will give the file a whirl and see how things go.
 
Last edited:
The netmask won't always be 255.255.255.0 - just check your router settings in order to get all the settings in the same range. My default (on router) is 255.0.0.0 and my ip ranges are 10.0.0.x
 
I prefer using the interfaces file and pppoeconf (for setting up broadband dial up connections) instead of using the ubuntu network manager.

That's cos network manager is hideous. Horrible thing.

wicd is pretty decent if you ever want to get away from interfaces file.
 
Festering pile of dog excrement.
I'm interested why you say that? There have been some bugs with certain use cases but on the whole I've found that it does the job rather well - cant say I've had the same experience with any of the othe net managers.
 
I'm interested why you say that? There have been some bugs with certain use cases but on the whole I've found that it does the job rather well - cant say I've had the same experience with any of the othe net managers.

Maybe it's because I don't like net managers. The bloody thing would only allow operation via one interface at a time which seriously grated my ass. Wireless was also a hit & miss afair and things would go pear shaped if you wanted to use the vodafone mobile connect client with it. So using dual ethernet LAN, wireless & 3G at the time was a no-no. It's been a while though so things might have improved, I still prefer the old fashioned way of editing the config file.
 
Last edited:
Network manager and PPPOE don't work well together. The network manager always works fine, but as soon as I set up PPPOE connection it screws out. I just uninstalled network manager and set up a static ip in /etc/network/interfaces. This works best for me.
 
Top
Sign up to the MyBroadband newsletter
X