Thursday, 12 May 2016

remote desktop to ubuntu

Step 1 – Install xRDP
Open Terminal (Crtl+Alt+T) and execute following commands :
sudo apt-get update
sudo apt-get install xrdp
Step 2 – Install XFCE4 (Unity doesnt seem to support xRDP in Ubuntu 14.04 although in Ubuntu 12.04 it was supported thats why we install XFCE4)
sudo apt-get install xfce4
Step 3 – Configure xRDP
In this step we modify 2 files to make sure xRDP uses xfce4. First we need to create or edit our .xsession file in our home directory. We can either use nano or simply redirect an echo statement (easier):
echo xfce4-session >~/.xsession
The second file we need to edit is the startup file for xRDP, so it will start xfce4.
sudo nano /etc/xrdp/startwm.sh
The content should look like this (pay attention to the last line and ignore . /etc/X11/Xsession):
#!/bin/sh

if [ -r /etc/default/locale ]; then
  . /etc/default/locale
  export LANG LANGUAGE
fi

startxfce4
Step 4 – Restart xRDP
To make all these changes effective, restart xRDP as such:
sudo service xrdp restart
Testing your xRDP connection
On the computer that will remotely control your Ubuntu machine, start you RDP client. Windows comes standard with a Remote Desktop client (mstsc.exe – you can start it from a command prompt, or find the shortcut to Remote Desktop under Accessories). Or Search 'remote' in start (Windows 7) Or 'remote' in search box in Windows 8.
Remote Desktop Connection
Whichever client you use, most work with either the computer network name or IP address of your Ubuntu machine.
To find the IP address on your Ubuntu box, type:
hostname -I
(note: this is a capital “i”)
Enter IP address of your Ubuntu Machine. For Example
enter image description here
Depending on your RDP client capabilities and settings (for example: Microsoft RDP Client allows automatic login), you might or might not see the login screen. Here we enter our Ubuntu username and password and click “OK”
xRDP – Login screen
You are done,enjoy
RDP – Your Ubuntu xfce4 desktop

How to create vlan on Linux (with Cisco Catalyst Switch)

In this article I want to share to you on how to create and configure vlan on Linux through Cisco Catalyst Switch.
Requirements:
1. Linux installed on a PC with one or more NICs (Network Interface Card). I use Centos 5.4 using 2.6.18-164.11.1.el5PAE kernel. It should be applicable on other Linux distros such as Slackware, Ubuntu, Fedora, Debian, etc.
2. Cisco Catalyst Switch 2950
3. 2 PC/Laptop running Windows/Linux/BSD/MacOSX
4. 3 straight cables
This tutorial is based-on network diagram below:
Linux VLAN Trunking Topology
Linux VLAN Trunking Topology
Here are the full steps.
1. Load 802.1q module into the system
By default the 802.1q module is not loaded so we firstly have to load it. You can check whether it is already loaded or not by using ‘lsmod’ command.
lsmod |grep 802
If there is nothing shown by lsmod command, it means the module has not been loaded yet. Run ‘modprobe’ to load it.
modprobe 8021q
Make sure the module was successfully loaded by running the ‘lsmod’ again
lsmod |grep 802
8021q                  24649  0
If you see something similar like above, the 8021q has been successfully loaded.
2. Create vlan interface
We will use eth1 interface in the Linux box. We have to bring the interface up without IP address assigned to it before we can use it.
ifconfig eth1 0.0.0.0 up
We will create interface vlan 11 and vlan 12 on this eth1 interface. To create a vlan interface, use ‘vconfig add’ command as below:
vconfig add eth1 11
Added VLAN with VID == 11 to IF -:eth1:-

vconfig add eth1 12
Added VLAN with VID == 12 to IF -:eth1:-
These commands above will create devices eth1.11 and eth1.12 to your system. Linux will consider these as another network devices so you can configure and assign IP address like other.
You also see the vlan interfaces by typing ‘ifconfig -a’ command.
ifconfig -a

eth1.11   Link encap:Ethernet  HWaddr 00:30:48:BF:4E:BD
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

eth1.12   Link encap:Ethernet  HWaddr 00:30:48:BF:4E:BD
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
3. Assign IP address to the vlan interfaces
The vlan interfaces were successfully created on the previous step. Now we assign IP address on those interfaces using ifconfig command as below:
ifconfig eth1.11 192.168.11.254 netmask 255.255.255.0 up
ifconfig eth1.12 192.168.12.254 netmask 255.255.255.0 up
Make sure that the IP addresses were assigned successfully on the interfaces.
ifconfig eth1.11
eth1.11   Link encap:Ethernet  HWaddr 00:30:48:BF:4E:BD
          inet addr:192.168.11.254  Bcast:192.168.11.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

ifconfig eth1.12
eth1.12   Link encap:Ethernet  HWaddr 00:30:48:BF:4E:BD
          inet addr:192.168.12.254  Bcast:192.168.12.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
Until this step, creating and configuring vlans have been done on the Linux box. Now we are going to configure vlan and trunk on the Cisco Catalyst switch.
4. Configure cisco catalyst switch, add vlan database, configure interface access vlan and trunk
As said before, we use vlan 11 and vlan 12 on this tutorial. So those vlan must be added into the vlan database of the switch.
switch#conf terminal
Enter configuration commands, one per line.  End with CNTL/Z.
switch(config)#vlan 11
switch(config-vlan)#name test-vlan11
switch(config-vlan)#exit
switch(config)#vlan 12
switch(config-vlan)#name test-vlan12
switch(config-vlan)#exit
switch(config)#exit
switch#wr mem
Building configuration...
[OK]


switch#show vlan | include test-vlan
11   test-vlan11                      active
12   test-vlan12                      active
Vlan 11 and 12 have been successfully added to the database and active.
Now we have to configure 3 ports in the cisco catalyst switch. 1 port is for trunk between the switch and Linux box and 2 ports are for PC-A and PC-B.
We will use port Fa0/16 as trunk port and Fa0/14 and Fa0/15 as vlan access port connected to PC-A and PC-B respectively. Below are the commands:
switch#conf terminal
Enter configuration commands, one per line.  End with CNTL/Z.
switch(config)#int f0/14
switch(config-if)#description To_PC-A
switch(config-if)#swi acc vlan 11
switch(config-if)#no shutdown
switch(config-if)#exit
switch(config)#int f0/15
switch(config-if)#description To_PC-B
switch(config-if)#swi acc vlan 12
switch(config-if)#no shutdown
switch(config-if)#exit
switch(config)#int f0/16
switch(config-if)#description Trunk_To_Linux_Router
switch(config-if)#switchport trunk allowed vlan 11,12
switch(config-if)#switchport mode trunk
switch(config-if)#no shutdown
switch(config-if)#exit
switch(config)#exit
switch#wr mem
Building configuration...
[OK]
switch#


switch#show running-config interface f0/14
Building configuration...

Current configuration : 82 bytes
!
interface FastEthernet0/14
 description To_PC-A
 switchport access vlan 11
end

switch#show running-config interface f0/15
Building configuration...

Current configuration : 82 bytes
!
interface FastEthernet0/15
 description To_PC-B
 switchport access vlan 12
end

switch#show running-config interface f0/16
Building configuration...

Current configuration : 129 bytes
!
interface FastEthernet0/16
 description Trunk_To_Linux_Router
 switchport trunk allowed vlan 11,12
 switchport mode trunk
end

switch#
The configurations on both Linux box and Switch have completed.
Now it is the time to test whether PC-A and PC-B can ping to the same network on the Linux box. Make sure the cables are connected properly to each ports on the devices.
5. Test ping to Linux box using vlan ip address
Test from PC-A:
C:\Users\Fuad NAHDI>ping 192.168.11.254

Pinging 192.168.11.254 with 32 bytes of data:
Reply from 192.168.11.254: bytes=32 time=1ms TTL=64
Reply from 192.168.11.254: bytes=32 time
Test from PC-B:
C:\Users\Fuad NAHDI>ping 192.168.12.254

Pinging 192.168.12.254 with 32 bytes of data:
Reply from 192.168.12.254: bytes=32 time=2ms TTL=64
Reply from 192.168.12.254: bytes=32 time
6. Make everything active at boot
Everything we have done above is temporary configuration, meaning that it will be cleared from configuration when we reboot or shutdown the linux box.
To make it permanent or active at boot, simply add the following lines into the rc.local file (e.g Centos: /etc/rc.local ; Slackware: /etc/rc.d/rc.local):
modprobe 8021q
ifconfig eth1 0.0.0.0 up
vconfig add eth1 11
vconfig add eth1 12
ifconfig eth1.11 192.168.11.254 netmask 255.255.255.0 up
ifconfig eth1.12 192.168.12.254 netmask 255.255.255.0 up
Everything has been done. Now you should understand on how to create and configure vlan on Linux and Cisco Catalyst switch.

How to configure SPAN and RSPAN in Cisco Catalyst switches

Switched Port Analyzer (SPAN) allows you to send a copy of traffic passing through ports to another port on the switch. SPAN is important to mirror received or transmitted (or both) traffic on one or more source ports to a destination port for analysis. While SPAN is mirroring ports in the same switch, RSPAN(Remote SPAN) is mirroring ports in one switch to a port in different switch.
This post describes how to configure SPAN and RSPAN on Cisco Catalyst switches. On this example I use Cisco 2970.
1. SPAN
See the figure below, you would like to monitor the incoming traffic on port Gi0/1 using Wireshark connected to port Gi0/2.
 
Cisco SPAN Sample Topology
Here is the config you should have in the Switch
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#monitor session 1 source interface Gi0/1 rx
Switch(config)#monitor session 1 destination interface Gi0/2
Switch(config)#end
Incoming traffic passing through port Gi0/1 will be mirrored to port Gi0/2 and captured by Wireshark on Laptop connectedd to port Gi0/2.
2. RSPAN (Remote SPAN)
See the image below for sample topology. You would like to monitor traffic on port Gi0/1 in Switch1 using a Laptop connected to port Gi0/2 in Switch2. Both switches must be able to run RSPAN to work properly.
Create a VLAN that will be used as an RSPAN-VLAN on both switches. On this example we use vlan id 30 as the RSPAN-VLAN. Then allow the RSPAN-VLAN on the trunk port between Switch1 and Switch2.
 
Cisco RSPAN Sample Topology
Here is the config you should have:
Switch1 (Source switch)
Switch1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch1(config)#vlan 30
Switch1(config-vlan)#name RSPAN-Vlan
Switch1(config-vlan)#remote-span
Switch1(config-vlan)#exit
Switch1(config)#monitor session 1 source interface Gi0/1 rx
Switch1(config)#monitor session 1 destination remote vlan 30 
Switch1(config)#end
Allow vlan id 30 on the trunk port Gi0/2
Switch1#sh run int g0/2
Building configuration...

Current configuration : 175 bytes
!
interface GigabitEthernet0/2
 description To-Switch2-port-Gi0/1
 switchport trunk encapsulation dot1q
 switchport trunk allowed vlan 10,20,30
 switchport mode trunk
end
Switch2 (destination switch)
Switch2#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch2(config)#vlan 30
Switch2(config-vlan)#name RSPAN-Vlan
Switch2(config-vlan)#remote-span
Switch2(config-vlan)#exit
Switch2(config)#monitor session 1 destination interface Gi0/2
Switch2(config)#monitor session 1 source remote vlan 30 
Switch2(config)#end
Allow vlan id 30 on the trunk port Gi0/1
Switch2#sh run int g0/1
Building configuration...

Current configuration : 175 bytes
!
interface GigabitEthernet0/1
 description To-Switch1-port-Gi0/2
 switchport trunk encapsulation dot1q
 switchport trunk allowed vlan 10,20,30
 switchport mode trunk
end
With the config above, incoming traffic passing through port Gi0/1 on Switch1 will be mirrored to port Gi0/2 onSwitch2 and captured by a traffic analyzer on Laptop connected to port Gi0/2.