Category Archives: Uncategorized

Quick and dirty way to create a bunch of loopbacks with IP addresses

This can be handy when doing some sort of BGP lab. There are ways to pull various source data with real prefixes into BGP, but sometimes you just want to create a bunch of local addresses.

Daniel helped me out with this initially and I’ve simple added a couple of things.

This is the script on my linux box:

#!/usr/bin/perl
for ($ip=1; $ip<256; $ip++)
{
print "interface loopback$ip\n";
print "ip address 1.2.3.$ip 255.255.255.255\n";
print "ip address 2.2.3.$ip 255.255.255.255 secondary\n";
print "ip address 3.2.3.$ip 255.255.255.255 secondary\n";
print "ip address 4.2.3.$ip 255.255.255.255 secondary\n";
print "ip address 5.2.3.$ip 255.255.255.255 secondary\n";
print "ip address 6.2.3.$ip 255.255.255.255 secondary\n";
print "ip address 7.2.3.$ip 255.255.255.255 secondary\n";
print "ip address 8.2.3.$ip 255.255.255.255 secondary\n";
print "ip address 9.2.3.$ip 255.255.255.255 secondary\n";
print "ip address 10.2.3.$ip 255.255.255.255 secondary\n";
print "ip address 11.2.3.$ip 255.255.255.255 secondary\n";
print "ip address 12.2.3.$ip 255.255.255.255 secondary\n";
print "ip address 13.2.3.$ip 255.255.255.255 secondary\n";
print "ip address 14.2.3.$ip 255.255.255.255 secondary\n";
print "ip address 15.2.3.$ip 255.255.255.255 secondary\n";
print "ip address 16.2.3.$ip 255.255.255.255 secondary\n";
print "ip address 17.2.3.$ip 255.255.255.255 secondary\n";
print "ip address 18.2.3.$ip 255.255.255.255 secondary\n";
print "ip address 19.2.3.$ip 255.255.255.255 secondary\n";
print "ip address 20.2.3.$ip 255.255.255.255 secondary\n";
}

Running the script spits out a ton of IPs:

./IP_Generate.pl
interface loopback1
ip address 1.2.3.1 255.255.255.255
ip address 2.2.3.1 255.255.255.255 secondary
ip address 3.2.3.1 255.255.255.255 secondary
ip address 4.2.3.1 255.255.255.255 secondary
ip address 5.2.3.1 255.255.255.255 secondary
ip address 6.2.3.1 255.255.255.255 secondary
ip address 7.2.3.1 255.255.255.255 secondary
ip address 8.2.3.1 255.255.255.255 secondary
ip address 9.2.3.1 255.255.255.255 secondary
ip address 10.2.3.1 255.255.255.255 secondary
ip address 11.2.3.1 255.255.255.255 secondary
ip address 12.2.3.1 255.255.255.255 secondary
ip address 13.2.3.1 255.255.255.255 secondary
ip address 14.2.3.1 255.255.255.255 secondary
ip address 15.2.3.1 255.255.255.255 secondary
ip address 16.2.3.1 255.255.255.255 secondary
ip address 17.2.3.1 255.255.255.255 secondary
ip address 18.2.3.1 255.255.255.255 secondary
ip address 19.2.3.1 255.255.255.255 secondary
ip address 20.2.3.1 255.255.255.255 secondary
interface loopback2
ip address 1.2.3.2 255.255.255.255
ip address 2.2.3.2 255.255.255.255 secondary
ip address 3.2.3.2 255.255.255.255 secondary
ip address 4.2.3.2 255.255.255.255 secondary
ip address 5.2.3.2 255.255.255.255 secondary
ip address 6.2.3.2 255.255.255.255 secondary
ip address 7.2.3.2 255.255.255.255 secondary
ip address 8.2.3.2 255.255.255.255 secondary
ip address 9.2.3.2 255.255.255.255 secondary
ip address 10.2.3.2 255.255.255.255 secondary
ip address 11.2.3.2 255.255.255.255 secondary
ip address 12.2.3.2 255.255.255.255 secondary
ip address 13.2.3.2 255.255.255.255 secondary
ip address 14.2.3.2 255.255.255.255 secondary
ip address 15.2.3.2 255.255.255.255 secondary
ip address 16.2.3.2 255.255.255.255 secondary
ip address 17.2.3.2 255.255.255.255 secondary
ip address 18.2.3.2 255.255.255.255 secondary
ip address 19.2.3.2 255.255.255.255 secondary
ip address 20.2.3.2 255.255.255.255 secondary
interface loopback3
ip address 1.2.3.3 255.255.255.255
ip address 2.2.3.3 255.255.255.255 secondary
ip address 3.2.3.3 255.255.255.255 secondary
ip address 4.2.3.3 255.255.255.255 secondary
ip address 5.2.3.3 255.255.255.255 secondary
ip address 6.2.3.3 255.255.255.255 secondary
ip address 7.2.3.3 255.255.255.255 secondary
ip address 8.2.3.3 255.255.255.255 secondary
ip address 9.2.3.3 255.255.255.255 secondary
ip address 10.2.3.3 255.255.255.255 secondary
ip address 11.2.3.3 255.255.255.255 secondary
ip address 12.2.3.3 255.255.255.255 secondary
ip address 13.2.3.3 255.255.255.255 secondary
ip address 14.2.3.3 255.255.255.255 secondary
ip address 15.2.3.3 255.255.255.255 secondary
ip address 16.2.3.3 255.255.255.255 secondary
ip address 17.2.3.3 255.255.255.255 secondary
ip address 18.2.3.3 255.255.255.255 secondary
ip address 19.2.3.3 255.255.255.255 secondary
ip address 20.2.3.3 255.255.255.255 secondary
etc
etc
etc
...

You can redirect that to a text file to import or whatever. Adjust as needed

Connecting the CSR1000V to dynamips and to the external world

I’ve had a few questions on my post over here. How can we effectively connect a CSR to an existing dynamips topology, as well as how to break it out to the real world. The initial goal is to create this topology:
CSR Connecting the CSR1000V to dynamips and to the external world

I don’t have an ESX v5 server to play around with, so I’ll be doing all of this under vmware fusion on my Macbook Pro. I’ll show you how to install the CSR first. How to modify a dynamips .net file running on the same laptop to connect to the CSR. And finally how to break that out to a switch where I can connect all manner of real devices. The configuration of vmware player/fusion/workstation and ESX vsphere are going to be very similar

Install the CSR1000v

You need to download the CSR from Cisco’s website. Go to Cisco – Support – Download – Routers – Cloud Routers – CSR1000V
This is a free download. You just need a Cisco account.
In ESX you can install – install from OVF. With vmware fusion installed all I need to do is doubleclick the download from Cisco. That will open up an import dialogue:
Screen Shot 2013 04 19 at 09.16.00 Connecting the CSR1000V to dynamips and to the external world
Let it import
Screen Shot 2013 04 19 at 09.16.29 Connecting the CSR1000V to dynamips and to the external world
Screen Shot 2013 04 19 at 09.18.57 Connecting the CSR1000V to dynamips and to the external world
The first time you run the VM, it’ll fully install. You don’t have to do anything except let it run through its install. Once it reboots your router will start up:
Screen Shot 2013 04 19 at 09.24.51 Connecting the CSR1000V to dynamips and to the external world

Configure vmware player networking

I’ve installed Ubuntu server 64bit in the meantime and installed dynamaips. What we want to do now is ensure certain virtual interfaces are connected to different virtual switches. Ubuntu/CSR will consider these to be real interfaces.
The CSR comes with three interfaces by default. I’ve mapped two of these to separate internal switched networks.

NOTEvmware player/esx/workstation makes this very easy. Vmware Fusion doesn’t give you the option to create multiple virtual networks. I’ll add a section at the end of this post to show how to do this.
For dynamips I’ve also got two interfaces. Each mapped to the same networks respectively as the CSR above.

Configure dynamips .net file

The goal now is to map interface. I want to map the two virtual interface (which linux considers real) to a virtual ethernet switch within dynamips. I’ll also connect R1 and R2 directly to each other in dynamips:

autostart = False
[127.0.0.1:7200]
    workingdir = /home/darreno/dynamips/working
[[7200]]
        image = /home/darreno/dynamips/ios/c7200-advipservicesk9-mz.122-33.SRE7.bin
        ram = 256
        idlepc = 0x6278f1a4
        ghostios = True
[[ROUTER R1]]
        model = 7200
        console = 2001
        f0/0 = s1 1
	f1/0 = R2 f1/0
[[ROUTER R2]]
        model = 7200
        console = 2002
        f0/0 = s1 2
[[ETHSW s1]]
        1 = access 2
        2 = access 3
        3 = access 2 NIO_linux_eth:eth1
        4 = access 3 NIO_linux_eth:eth2

There is a virtual switch internal to dynamips called ETHSW S1. I’ve mapped R1 interface fa0/0 to port 1 of this switch. Switch port 1 is mapped to vlan 2 untagged. Port 3 of this dynamips switch is also in vlan 2 which connects to what linux considers eth0. eth0 is connected to vmnet2 which we created earlier. This is the virtual network within vmware. The same has been done for R2 and port 4, just that those are in vlan 3 connected to the vmnet3 network inside vmware. It’s a bit confusing at first as we are dealing with multiple levels of virtualisation here, but once you wrap your head around it it’s not so difficult.

Testing

I’ve configured the network as above. I’ve configured a loopback interface on all routers and they are all running OSPF. Let’s check CDP and OSPF:

IOS-XE#sh cdp neighbors
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
                  S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone,
                  D - Remote, C - CVTA, M - Two-port Mac Relay

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID
R2               Gig 2             121               R    7206VXR   Fas 0/0
R1               Gig 1             171               R    7206VXR   Fas 0/0

IOS-XE#sh ip ospf neighbor

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/DR         00:00:39    10.1.1.50       GigabitEthernet2
1.1.1.1           1   FULL/DR         00:00:34    10.0.0.50       GigabitEthernet1
R1#sh cdp nei
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
                  S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID
R2               Fas 1/0           157            R       7206VXR   Fas 1/0
IOS-XE           Fas 0/0           136           R I      CSR1000V  Gig 1
R1#
R1#sh ip ospf nei

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/BDR        00:00:33    192.168.1.2     FastEthernet1/0
5.5.5.5           1   FULL/BDR        00:00:39    10.0.0.1        FastEthernet0/0
2#sh cdp nei
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
                  S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone

Device ID        Local Intrfce     Holdtme    Capability  Platform  Port ID
R1               Fas 1/0           125            R       7206VXR   Fas 1/0
IOS-XE           Fas 0/0           178           R I      CSR1000V  Gig 2
R2#
R2#sh ip ospf nei

Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1           1   FULL/DR         00:00:32    192.168.1.1     FastEthernet1/0
5.5.5.5           1   FULL/BDR        00:00:34    10.1.1.1        FastEthernet0/0

Connect to the real world

I’m not going to show this as it’s very simple. It’s nearly identical to the config above. All you need to do is map a vmnet to a physical interface. You can also map a vmnet to a physical tagged interface. This means on a single physical interface you can have multiple vmnets mapped. From there you can connect it to a switch where you cn use vlans to connect to other kit.

Footnote – Adding more vmnets in Vmware Fusion

I got these instructions from here: http://www.virtual-hike.com/how-to-create-additional-vmnets-in-vmware-fusion/

The following all needs to be done through the cli. I’m using Fusion 5 so you may need to adjust for different versions. You first need to install your VMs as above. Once that is done, open a terminal and navigate to /Library/Preferences/VMware Fusion

Darrens-MacBook-Pro:/ darrenoconnor$ cd /Library/Preferences/VMware\ Fusion/

Copy the vnmet1 folder to vmnet2

Darrens-MacBook-Pro:VMware Fusion darrenoconnor$ sudo cp -R vmnet1 vmnet2
Password:

Navigate to the new folder and edit dhcpd.conf:

arrens-MacBook-Pro:VMware Fusion darrenoconnor$ cd vmnet2
Darrens-MacBook-Pro:vmnet3 darrenoconnor$ sudo vi dhcpd.conf

In that file you should adjust the subnet address, MAC address, and vmnet name. Save and exit.

Edit the network file:

Darrens-MacBook-Pro:vmnet3 darrenoconnor$ sudo vi ../networking

Add the following with the subnets you used above. We don’t actually need DHCP so you can switch it off:

answer VNET_2_DHCP no
answer VNET_2_HOSTONLY_NETMASK 255.255.255.0
answer VNET_2_HOSTONLY_SUBNET x.x.x.x
answer VNET_2_VIRTUAL_ADAPTER yes

That’s the second vmnet now created. Now we need to modify our previous VM’s to connect to that new vmnet. Once again this needs to be done via the command line.

Navigate to your VM:

Darrens-MacBook-Pro:vmnet3 darrenoconnor$ cd ~/Documents/Virtual\ Machines.localized/

Go into the folder for each of your VMs you want to add to the vmnet. Open the .vmx file and add it to the vmnet added earlier.

Go down to ethernet2 and change it like so:

ethernet2.present = "TRUE"
ethernet2.connectionType = "custom"
ethernet2.vnet = "vmnet2"
ethernet2.virtualDev = "e1000"
ethernet2.wakeOnPcktRcv = "FALSE"
ethernet2.addressType = "generated"

Do that for all the needed VMs and away you go. You can add more vmnets as needed

Managed to break my server again – Booo

I logged onto my server and did a standard update and upgrade. For some odd reason, MySQL refused to start up and hence my blog went offline.

In particular I got this error:

darreno@blog:~$ service mysql start
start: Rejected send message, 1 matched rules; type="method_call", sender=":1.4" 
(uid=1000 pid=1406 comm="start mysql ") interface="com.ubuntu.Upstart0_6.Job" 
member="Start" error name="(unset)" requested_reply="0" destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init")

I tried starting manually. I tried uninstalling and reinstalling MySQL. But I couldn’t even get that far. Thankfully I had a backup of the entire server from last night. Restored, started up. Same problem.

Hmm. What else could it be? After a bit of searching I managed to start MySQL with this:

darreno@blog:~$ sudo -u mysql mysqld

I was however seeing errors such as is marked as crashed and should be repaired

 

After some further searching, I found that you can sometimes get these MySQL errors when your disk is full. So let’s have a look at the disk then. 100% full. Great.

This VM itself has a fairly small hard disk. I was running the cli version of the dropbox daemon and slowly but surely my dropbox folder completely filled the disk :(

 

I removed dropbox and removed everything out of my synced folder. Restarted MySQL and no more problems :)

Hurricane Sandy’s affect on the core BGP table

A couple of interesting graphs. You can see in the following diagrams how Sandy affected the BGP table. These images I got from the CIDR report

450 AS numbers disappeared as well as roughly 3000 prefixes. Which of course gradually returned

I don’t have figures for RTT to various sites as my guess is that a fair amount of trans-Atlantic traffic would’ve been quite higher.

Update: RIPE has a good RTT graph over here

plot2 Hurricane Sandys affect on the core BGP table
plot Hurricane Sandys affect on the core BGP table

Twitter

So I’ve not really used Twitter as much as I should, mainly as most people speak a load of shit on there.

But I would like to actually follow and be followed by people in the field, as it’s a great way to get some communication going when I/You run into problems.

Anyways, feel free to add me: https://twitter.com/mellowdrifter