Archive for the ‘Interweb’ Category

Setting up networking on an ubuntu server

Monday, April 14th, 2008

Ok, by popular demand (aka ompaul) I’ve decided to do a mini-howto on setting up networking on an ubuntu server, for those who are new to it.

In Ubuntu itself, when you install the desktop version, you get a nifty little tool called “Network Manager” (you may have noticed the icon, espescially if you have wireless) which pretty much does everything for you. However, if you’re using the server, without a GUI then this isn’t generaly available.

So, where to start?

It really depends on your network setup, you need to know a few things about your network before you start this.

The first and most important question you need to find out is whether there is a DHCP server on your network that will assign you an IP address. If so, your networking setup is very very simple, so I’ll start off with that.

Networking with an available DHCP server

When you have a DHCP server available on your network, things are made a lot simpler. Cut short, a DHCP server sits on your network and hands out configurations to the different computers that ask for them. I won’t go into detail, but, generally you’ll find these on small home networks (your router will generally work as a DHCP server, which is why you (usually) magically find your way onto the internet when you plug yourself into a network with a router on it)

First of all, find out whether you actually already have an internet connection. I’ll assume for now that you have a keyboard and monitor hooked up to the computer you’re setting up as a server, and have logged in as a user with sudo rights.

Type in the command “ifconfig” (without the quotes) and you should hopefully see something like this:-

mez@stupor:~$ ifconfig

eth0      Link encap:Ethernet  HWaddr 00:16:3E:7F:AC:B2
inet addr:212.13.30.94  Bcast:212.13.30.255  Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:3576458 errors:0 dropped:0 overruns:0 frame:0
TX packets:1886783 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:10
RX bytes:836607596 (797.8 MB)  TX bytes:291514569 (278.0 MB)

lo        Link encap:Local Loopback
inet addr:127.0.0.1  Mask:255.0.0.0
RX packets:73611 errors:0 dropped:0 overruns:0 frame:0
TX packets:73611 errors:0 dropped:0 overruns:0 carrier:0
UP LOOPBACK RUNNING  MTU:16436  Metric:1
collisions:0 txqueuelen:0
RX bytes:15252378 (14.5 MB)  TX bytes:15252378 (14.5 MB)

The important bit we see here is the block of text starting with “eth0″ and espescially the line

inet addr:212.13.30.94  Bcast:212.13.30.255  Mask:255.255.255.0

This generally means that the computer already has an IP address! yay!

Next, try the command

ping google.com

Hopefully, you’ll get back a response saying something along the lines of

PING google.com (64.233.187.99) 56(84) bytes of data
64 bytes from jc-in-f99.google.com (64.233.187.99): icmp_seq=1 ttl=245 time=100 ms

If so, you have a working internet connection! Go you! you can now start using your computer on the internet (though the IP address given above might only be accessible from an internal network, depending on your setup - going into howto get this IP available on the internet proper is beyond the scope of this blog post)

If not, you’ll get one of two errors, either a “no route to host” or a “cannot resolve google.com”.

The first issue is a complex one, which again, is beyond the scope of this article (though feel free to email me to ask questions - or catch me on IRC - I will *try* to answer them)

The second one generally means that you do not have a nameserver setup.

Open DNS is a project that provides Accessible DNS resolvers for the whole world to use. More information can be found out about OpenDNS here

For now however, lets open up your DNS resolver settings

sudo nano /etc/resolv.conf

This file should be edited to contain the following lines only

nameserver 208.67.222.222
nameserver 208.67.220.220

Hit Ctrl + O then enter, then Ctrl + X to get back to your command prompt.

Try pinging google again, and hopefully it should work. If not, something went wrong somewhere, again, try emailing me or poking me on IRC.

So, what if you don’t have an IP address?

Well, assuming that you DO have a DHCP server running on your network, lets first of all check that we have a working interface on our system

ifconfig -a

You should hopefully see a couple of lines here, one starting with “lo” and another starting with “eth0″ (or similar) - remember this name

Now, open up your /etc/network/interfaces file (sudo nano /etc/network/interfaces) and make sure it contains the following

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp

Assuming that it does, we should be able to do the following

sudo ifup eth0

Which will (hopefully) bring the interface up. Go back a step if you cannot resolve google.com when trying to ping it. You might have to setup a resolver (though your DHCP server should provide these details for you!)

Voila! hopefully you now have a working network interface

Networking without an available DHCP server

Now, here is where things get more interesting. To be able to setup a network without having a DHCP server readily available, you need to know the following

  • The IP address that will be assigned to your host
  • The netmask for the IP addresses being used
  • The default gateway’s IP address (usually the IP address of your router)

It may differ how you get this information, however, I cannot tell you how to do so, I’d ask your network administrator if I were you (or your hosting provider)

So, I’m assuming here that you have the above details, are logged in at your machine and ready to go

I’ll only be brief about this setup, as a lot of the details are covered above.

First of all, make sure that your interface is down

sudo ifdown eth0

next, edit your /etc/network interfaces, replacing the information between < and > with
the information from above

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
	address <IP Address>
	netmask <Network Mask>
	gateway <Default Gateway>

So, you should have something like this

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
	address 212.13.30.94
	netmask 255.255.252.0
	gateway 212.13.30.1

Now head back to your console, and try

sudo ifup eth0

To bring your interface up. Hopefully, now, everything should be working (if not, go have a look at the DNS stuff above)

If you have any questions, feel free to leave me a comment here, or email me (martin AT sourceguru DOT net) and I will try and answer, though I make no guarantees!

Thus concludes Mez’s basic guide to server networking on ubuntu - I’ll try and add some more interesting stuff in a later blog post (IPv6, IP Aliases, etc etc)

Notes to self

Friday, April 11th, 2008
  • postfix reload does not change the listening interface settings for postfix
  • postfix really should listen on 127.0.0.1 if you are running mailman
  • when things go wrong, it’s usually your own fault

A case of mistaken identity?

Wednesday, April 18th, 2007

I just recieved a pingback for my latest blog post from opencontent.info.

It seems that they think I’m someone called Randy Charles Morin.

I like the name, I think I might use it.

It’s nice to be syndicated :D even if I don’t get credit for my work

Open Wifi Access

Wednesday, April 18th, 2007

Recently, Baz blogged about 2 people being arrested for using other people’s wifi for free access.

I actually read this in the Metro on the bus on the way home today, and I think it’s ludicrous. OK, some people don’t like it, but then most if not all Wireless Devices have the ability to use something along the lines of WEP/WPA etc. Surely, you can either blame the people setting up the wireless router for not setting it up in a secure way, or blame the manufacturers for not getting across the point of how WEP/WPA are good, and should be enabled? I can find a basic description in my routers manual, which doesn’t explain what these technologies are, just where to type in a key in the routers configuration screen.

I purposely leave my wireless open to the public (allbeit with traffic shaping so that my bandwidth doesn’t get molested!) And so far, have had 7 “visitors” with one actually taking the time out to research who I was and email me telling me I had an open access point, and how to fix it. How kind of them, but I replied and explained to them what I was doing.

I urge anyone out there to have a look at Fon - free wireless for those who share theirs :D Enjoy!

Source Guru returns

Sunday, April 15th, 2007

So, after a few issues with Paypal (damn them!) I’ve finally managed to be able to actually send my payment(s) for my VPS, and it has now returned.

Over the years, I’ve been hosted in many places, from Tripod, to Freedom2surf, to lyximer (man, I miss that place!) enhosting, one&one, and now to bitfolk and over all that time -I’ve used many a different Control Panel (except for lyximer - those were the good old days of getting down and dirty with the configuration files)

Well anyway, in Source Guru’s past implementation, I used ISPConfig which did exactly what I wanted, to an extent. It automated the creation of new domains, including mail, DNS etc etc. However, it lacked in a few features. It was horridly coded, and well, cause me more hassle than was worth (espescially when trying to upgrade)

So, now I’m using webmin, usermin, and virtualmin, and I’m surprised at how well Webmin actually interfaces with the config files actually on your server. You can add as many obscure settings as you want and webmin either recognises them, or just leaves them alone.

Unfortunately, It’s still not up to scratch, for me probably more than most. As I’m hosted by bitfolk I have access to 5 other DNS secondaries. It’s nice to know that you’ll be able to access your DNS even if things go wrong. However, using VirtualMin to create sites (for things like Realist Anew) it doesn’t actually create the proper Nameserver records, meaning that the Secondary Nameservers won’t take the transfer requests.

If I use Webmin’s DNS settings to create it, I can add in a nice bit that will add all the nameservers for me, but it seems that Virtualmin doesn’t interface with this! Gah!

So well, yeah, it’s getting down and dirty again in the config files to make things work (Many thanks to Andy Smith for helping me out with this one)

Anyways, other than a nice swap death, my server’s been up and playing nicely, now I just need to import all the old websites I had on there!

But it does lead me to want to start making my own “Control Panel” software … … …

Bored

Saturday, May 27th, 2006

It’s not often that I get so bored I start actually doing something.

Usually, I’ll just end up moaning and whining at people on [Insert name of preffered IM protocol here]

But, you know - I actually did something today. Nothing that’s really of any use to anyone… and nothing that’s really worthwhile for anything other than my own personal amusement - but hey - I took an hour or so - I hacked away - I played around a little, and this is what I came up with - Impressive huh? Didn’t think so - but it kept me amused for a while. As I hope will some of the comments that are left :D

 However, in writing the code, it did take me on a trip down memory lane, back to when I first got into web programming. My first ever website I set up over on tripod, back when I was learning HTML and thought marquee’s were cool. (though thankfully I never thought flashing text was!)

Back then - one of the websites I visited regularly was dogbomb (NSFW) - and I still do - on occasion - it has a couple of interesting forums I enjoy reading through (particularly the jokes forum - check it out) and has a few…. how shall I say… intriguing (?) topics on there.

Anyway - I’ve strayed from the point. Way back then - Simon (the webmaster) had a little thing you could click on and change a bit of writing on his main page, which I found very very cool (remember I was a newbie back then). He called this graffitti. Well, being the eager little beaver I was… I wanted it. I wanted it for my own, and, that’s how I got into it - I pored the web, yahoo searched, and eventually taught myself perl, and managed to get my own copy up and working. Of course, being a “featured site” at the time on dogbomb, I got a hell of a lot of abuse for “ripping” the code, but - I knew that I’d done it all myself - not stolen anything and well…. I was proud - it was the first time I’d sat down and programmed anything decent (apart from a few really basic RPGs on my old MSX!) and then I started getting into other things - forum software etc etc etc etc.

It all led me to where I am today.

Thing is - with all the innovations already being made - what can we do except copy them? Ok. it may be a different way of doing the same thing, but if it wasnt for the fact that there are so many restrictive licences, patents, etc etc out there, then surely we wouldn’t need all this re-making of things…. GnuPG and PGP for example… I don’t see the point in any of it. Which is why I advocate Open Source Software. Lets all work together instead of duplicating effort - and maybe we can move faster!