Tag Archives: debian

Hot add Nic into Vyatta VM – no reboot required

Recently I was asked about how to add a nic to a Vyatta VM, my reply “add it in VMware and reboot”- their response “We cannot reboot”. I asked why they can’t reboot and they said “If we were to reboot this Vyatta (Bring down the Client VPNs) then we would have to send out an email a ton of clients and let them know” – huge ordeal .

So we need to add a nic via VMware, and then have Vyatta recognize that nic right away, with out a reboot. So I added the Nic (see image below) in VMware:

Add-int

After I add the NIC, I can look on the Vyatta and see it still shows only two NICs.

showint

So, VMware added the nic but Vyatta(debian) never sees it. After trying to ifup/ifdown , service network restart – and many other commands it could never find it.

So, what is needed – we have to rescan the PCI bus to find the nic. Most Linux users are probably like — ya of course you do! But I just reboot and it works. In this case cant reboot.

To Rescan the PCI bus, we have to first change our permissions on that file, echo into that file, than change the permissions back. The commands to do so are:

configure

sudo chmod 0777 /sys/bus/pci/rescan

sudo echo 1 > /sys/bus/pci/rescan

sudo chmod 0220 /sys/bus/pci/rescan

After doing that look at your interfaces:

int3

Now we see the interface and can configure it. This process should work with Debian no problem (since Vyatta is Debian).

Advertisements

Vyatta out of space?

Today I had a vyatta that has limited HD space and could not  bring up VPN tunnels due to the lack of space. The below command is what I used to find the largest folder on the Vyatta file system :

find / -type f -size +20M -exec ls -lh {} \; 2> /dev/null | awk '{ print $NF ": " $5 }' | sort -nk 2,2

The command above searches the whole file system and reports back files larger than 20M.

I found that my wireshark folder had a lot of old captures. I navigated to the folder and removed all old captures and that freed up the missing space.

Using Logrotate in Vyatta to manage logs

Logrotate is a tool that is built into Debian which is really what Vyatta is built on. Logrotate is a tool that allows automatic rotation, compression, removal, and mailing of log files.  Each log file may be handled daily, weekly, monthly, or when it grows too large. Recently I had an issue where all the space on my Vyatta was filled up, after some investigation it was the auth.log that had reached a couple hundred mb. After clearing it I was fine. After more investigation I found that auth.log was never in the logrotate config.

Below is an example. In this example if the size of the log file gets above 50m it will copy itself (by rotating), compress the copy and then start logging to the new auth.log. In another 50m it will rotate back. So at most I would have 100m of auth.log.

/var/log/auth.log {
size 50M
rotate 2
create
compress
}

I would just edit the /etc/logrotate.conf file and add this in.

 

Vyatta Default gateway Script creation

I had to add a script into Vyatta the other day due to a bug in the OS. Well, bug might be a bad word, I think it was a driver issue with the NICs we were using. Any, the Vyatta would show the NIC as operation and up, but would not add the IP subnet configured on it into the routing table. Because of this, the default gateway would never come up. Since Vyatta is really just Debian the script creation is very simple.

This was Brocade’s VRouter 6.6 R3.

What I did was create a script in /etc/rc.d/ , change privileges, and then add it to rc.local.

Sample script

#!/bin/bash
sudo route add default gw 1.1.1.1 eth3

I save this into /etc/inid.d

then run : sudo chmod 755 /etc/init.d/Default-GW-Script

Next edit /etc/rc.local and add the script to run.

After a restart this came up no problem.