Thursday, October 18, 2012

Ubuntu VLAN Setup

Here is a quick example on how to add a VLAN interface in Ubuntu (12.04). Make sure you have the right package installed.
sudo apt-get install vlan
First test your configuration from the command line.
# modprobe 8021q
# vconfig add eth0 100
# dhclient eth0.100
Or if you are using a bridge for Virtual Machines.
# modprobe 8021q
# vconfig add br0 100
# dhclient br0.100
Then make your changes permanent by editing /etc/network/interfaces. Make sure to add 8021q to /etc/modules
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

# add home network VLAN 100
auto eth0.100
iface eth0.100 inet dhcp

# remove the default route to the new VLAN
up route del default dev eth0.100
Then execute
sudo invoke-rc.d networking restart
Make sure you have physical access to the machine so that if something goes wrong you can still change your network settings.

I had an issue where DHCP would assign a second default gateway to my VLAN interface. This caused issues with my network setup. My solution was to remove the new default route after the interface was up. I added this code to the end of my interface file.

up route del default dev eth0.100
You can verify that the route is removed with "route -n".

Wednesday, May 13, 2009

Copy Files with netcat

You can use netcat and tar to transfer large files/folders over the internet/network. If you are going to transfer sensitive files over the internet consider using this in conjunction with ssh.

On the destination
nc -l -p 7000 localhost | tar -xvf -


On the source
tar cf - directory_to_copy | nc destination_host 7000

Wednesday, April 22, 2009

Syncronize Working Directories With Rsync

I got tired of always searching all over the internet for the commands and tutorials that I use all of the time. I finally decided that I would start a blog where I kept track of all of the useful tips and tricks that I have found on the internet.

rsync -avz -delete -progress -e 'ssh -p 222' local_folder/ user@host.com:/var/www/remote_folder/

Let's review the command. -a=archive, -v=verbose, -z=compress -e=work over ssh using port 222, --stats=extra statistics followed by the source and destination. The dot stands for the current directory.

Rsync has the advantage over scp by only copying files that have changed. This is really great when you have only changed a few files in a large directory.