iproutes

routes

With regard to static routing, consider the above diagram. We have three separate networks: 192.168.1.0, 192.168.2.0, and 192.168.3.0. At first, network hosts (routers, computers, etc.) can only communicate with other hosts that are on their own network. For instance, the computer named James has a single interface on network 192.168.1.0, so that’s the only network that it can ‘see’. Initially, it will only be able to communicate with Router A.

Router A has network interfaces on the 192.168.1.0 and 192.168.2.0 networks, so those are the two networks that it can ‘see’. These are the only networks Router A ‘knows’ about, so it can only communicate with hosts on the 192.168.1.0 and 192.168.2.0 networks. So Router A doesn’t even ‘know’ that the 192.168.3.0 network exists.

Similarly, Router B can ‘see’ networks 192.168.2.0 and 192.168.3.0. When you enter a route into the table, you’re telling a host that there’s a new network it can get to, and you’re giving it the address of a gateway that it can use to get to the new network.

So to be able to contact Jesus (or any other host on the 192.168.3.0 network) from Router A, you’d enter the command:

ip route 192.168.3.0 255.255.255.0 192.168.2.2
             ^             ^             ^
           network        mask         gateway

This works because Router B can ‘see’ both Router A and Jesus. Thanks to this routing table entry when Router A wants to reach the 192.168.3.0 network, it knows it can get there via Router B at 192.168.2.2, so it sends the packet to Router B. Router B can see the 192.168.3.0 network directly, so it forwards the packet along to Jesus at 192.168.3.11.

So, now we know how to direct router A to the 192.168.3.0 network. But what if we want James to also be able to reach the 192.168.3.0 network? Well, Router A already knows how to get there, and James can already ‘see’ Router A, since they’re both on network 192.168.1.0. So we can just tell James to use Router A as its gateway to the 192.168.3.0 network. If James were a router instead of a computer, we’d use the command:

ip route 192.168.3.0 255.255.255.0 192.168.1.1
             ^             ^             ^
           network        mask         gateway

James would then be able to contact Jesus (or any host on the 192.168.3.0) network by forwarding the packet to 192.168.1.1 (Router A), which would then forward the packet to 192.168.2.2 (Router B) which would then forward the packet to its destination (Jesus in this case) via its directly connected interface.

Now, for Jesus to be able to respond to James, Jesus would need to have Router B set up as its gateway to the 192.168.1.0 network, and Router B would have to have Router A set up as its gateway to the 192.168.1.0 network. Then, any host on the 192.168.1.0 network would have a path to the 192.168.3.0 network and vice versa.

(reference: https://serverfault.com/questions/171551/help-me-understand-the-ip-route-command-for-cisco-routers )

Adding additional IP Address to ethernet interface

network card

Scenario: You have several devices within your network, you’ve changed the address range for the network but you’ve forgotten to change one in particular. It’s easier to log into the device than to physically attend to it (it may be headless, it may not be in your immediate vicinity, or you’re just to lazy to get out of your chair to do it.

Q. How do you log into a network device that isn’t on your subnet?

A. You create an alias IP address for your current interface within the scope of the IP address you need to hit.

In this example we’ve moved a network from a 192.168.0.1 to 10.0.0.1.

The router has been configured, all the devices have been configured and you’re up and running but realised you forgot the file server in the garage. Your whole network is now setup on the 10.0.0.1 network, but the file server is sitting patiently waiting for you back on the 192.168.0.1 network.

Here’s how you would do it in linux (Ubuntu):

>$ ifconfig
enp6s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
 inet 10.0.0.5 netmask 255.255.255.0 broadcast 10.0.0.255
 RX packets 6406862 bytes 7485766742 (7.4 GB)
 RX errors 0 dropped 0 overruns 0 frame 0
 TX packets 3920089 bytes 1566938600 (1.5 GB)
 TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

The old server is at 192.168.0.100, our computer was at 192.168.0.77. You can use any IP address that is not the device you want to connect to, and that is still within the same subnet range.

$ ifconfig enp6s0:0 192.168.0.77 up

Confirm it worked:

enp6s0: flags=4163  mtu 1500
        inet 10.0.0.5  netmask 255.255.255.0  broadcast 10.0.0.255
        ether 11:22:dd:99:4e:ee  txqueuelen 1000  (Ethernet)
        RX packets 6413204  bytes 7488178719 (7.4 GB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3925411  bytes 1568449079 (1.5 GB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp6s0:0: flags=4163  mtu 1500
        inet 192.168.0.77  netmask 255.255.255.0  broadcast 192.168.0.255
        ether 11:22:dd:99:4e:ee  txqueuelen 1000  (Ethernet)

note: this won’t survive a reboot. But for most intents and purposes, this will suffice. You can log into the file server and change the IP address and jump back out.

To make it permanent we will need to edit

/etc/network/interfaces

from: https://askubuntu.com/questions/585468/how-do-i-add-an-additional-ip-address-to-an-interface-in-ubuntu-14 (modified only to match the example above)

# vi /etc/network/interfaces

Append the following to the file (This is in addition to existing information, not a replacement for it)

auto enp6s0:0
iface enp6s0:0 inet static
name Ethernet alias LAN card
address 192.168.0.77
netmask 255.255.255.0
broadcast 192.168.0.255
network 192.168.0.0

Save and close the file. Restart the network:

# /etc/init.d/networking restart

Changing WordPress username

wordpress profile capture showing the message "can't change username"Have you ever checked your WordPress profile and noticed you can’t change your username?

Did you ever realise that most people choose the same display name as the username, which then gives hackers a legitimate username to try and hack into your site?

Do you use the same username and display name and now want to change your username (because you don’t want to change your display name)?

Then you should change your username.

There are two ways you could do this:-

  1. through WordPress itself:
    • Create a new user with the username (backend name) that you want
    • Login as that user and verify your account
    • Make sure permissions are right between the users (you’ll want the new user to be (super/) admin)
    • Delete the old user and assign all old posts to the new user
  2. through the database:-
    • edit the username for the user in the user table
    • edit the username in the site meta table for super admin (only applicable in a multi site install)

I didn’t do it through WordPress itself, since I do like to play with the database :) But in theory it should work and is the suggested theory on multiple sites.

Let’s break down the second option:

  1. Make a backup of the database
  2. Open the database using your chosen method
    • for me this is to log into my providers cPanel, and select myPHPAdmin
    • go to the users table (not the usermeta table). The table will be called something {DB_Prefix}_users (usually wp_users or wp_x_users in a multisite install where x is the identifier for the site).
    • change the username field to the new desired name
    • when you save the entry you will most likely be kicked out of the backend immediately, simply login with your new username and all is good to go
    • if you do NOT have a MultiSite install, your job is done. If you DO have a multisite install, read on:
  3. still in the database, navigate to the wp_sitemeta table and look for the meta_key: site_admins.
    • There will be an entry like: <pre>a:1:{i:0;s:4:”john”;}</pre> and change it to the username you created in step 2. You will also need to change the “S:n” (in this case “s:4”) to a new value depending on the length of your username. So you’ll note for “john” it’s 4. For “john-you-won’t-guess-this-827646″ you would make the entry:<pre>a:1:{i:0;s:31:”john-you-wont-guess-this-827646”;}</pre>. For reference, the “i:0” is Index 0. If you have multiple users here, this line will have multiple indexes with each one serialised onto the line and having their own section. Make sure you change the correct one(s).

Not doing this final step will not kick you from the individual site admins, but it will prevent you from getting to the Network Settings area to add plugins, themes and do other “network” maintenance things (like adding or removing sites amongst others).

I’ll let you know now, I learned about step 3 the hard way after being locked out from the Network Settings area after changing my main username.

I could do everything an admin could do for their site, I just could no longer administer the network.

Searching the net found this entry on WordPress.org and solved my problem.

WordPress media library limited to 10MB

Screenshot 2015-09-14 11.23.102
I think I’m a little over my quota!

Have you ever noticed this in your blog? It’s never been there before, but it appeared in the last day or two. At the time I wasn’t sure how or why. It’s my blog hosted on one of my web hosting accounts, and I have no shortage of space. So why was I getting this warning?

Screenshot 2015-09-14 11.35.24Worse yet, I went to add a photo, and this happened. That’s when I realised the quota was real!

My first question is, what dickhead gave me such a quota!

My first action was to work out where it was imposed.

Then I found who the right royal dick was. It was yours truly!

I’ve been doing too much playing in the back end and I at some point, and for some unknown reason, have turned it on.

I’m running WordPress Multisite and it’s a setting hidden in the Network Settings.

To navigate to it, click on My Sites in the top left corner, and select Network Admin. Then from the next menu select Settings.

secret hiding place for the 10MB upload quota
this little setting on the right… Make sure you turn it off! :)

And that’s it! Once, you clear that little baby, you’ll be able to upload to your little hearts content.

UPDATE: It looks like I wasn’t the only one who’s ever done this! 

Ubuntu – changing DHCP to Static

Before jumping in and making the changes, do
ifconfig -a
and note down any particular settings which you may need (if you don’t already know them)

Then edit /etc/network/interfaces

change:

iface eth0 inet dhcp

to:

iface eth0 inet static
address 10.0.0.101
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255
gateway 10.0.0.100

May also need to add nameservers to /etc/resolv.conf, eg:
nameserver 10.0.0.100
nameserver 192.122.108.211

Obviously change to suit your network settings.

Once done, don’t forget to restart the networking interface

sudo /etc/init.d/networking restart