WiFi to Ethernet using Raspberry Pi

Standard

You can use your PI as a router to share the ethernet connection to  WiFi Devices , What about the other way ?

Here is tut for Ethernet to WiFihttp://elinux.org/RPI-Wireless-Hotspot ( This tut helped me to get idea )

Requirements

  • A Raspberry Pi, model B.
  • A boot SD card for the Raspberry Pi.
  • Connected to Networking Via WiFi
  • An Ethernet cable to connect PC

Assumes that you have connected your device via WiFi and ssh logged in using WiFi .

If wifi is not setup perfectly please see this one :

Wifi auto connect : https://blog.arevindh.com/solved-raspberry-pi-wifi-disconnect-problems.html

Instructions

1. Install the necessary software.

sudo apt-get install udhcpd

2. Configure DHCP. Edit the file /etc/udhcpd.conf and configure it like this:

start 192.168.42.2 # This is the range of IPs that the hostspot will give to client devices.
end 192.168.42.20
interface eth0 # The device uDHCP listens on.
remaining yes
opt dns 8.8.8.8 4.2.2.2 # The DNS servers client devices will use.
opt subnet 255.255.255.0
opt router 192.168.42.1 # The Pi's IP address on wlan0 which we will set up shortly.
opt lease 864000 # 10 day DHCP lease time in seconds

Edit the file /etc/default/udhcpd and change the line:

DHCPD_ENABLED="no"

to

#DHCPD_ENABLED="no"

You will need to give the Pi a static IP address with the following command:

sudo ifconfig eth0 192.168.42.1

To set this up automatically on boot, edit the file /etc/network/interfaces and replace the line “iface eth0 inet dhcp” to:

iface eth0 inet static
  address 192.168.42.1
  netmask 255.255.255.0

If the line “iface eth0 inet dhcp” is not present, add the above lines to the bottom of the file.

Configure Your WiFi

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
 address 192.168.0.116
 netmask 255.255.255.0
 gateway 192.168.0.1
 wpa-ssid "HOME"  // your wifi ssid
 wpa-psk "xxxxxxxx" // your wifi pass

dns-nameservers 8.8.8.8 8.8.4.4

3. Configure NAT (Network Address Translation). First, enable IP forwarding in the kernel:

sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

To set this up automatically on boot, edit the file /etc/sysctl.conf and add the following line to the bottom of the file:

net.ipv4.ip_forward=1

Second, to enable NAT in the kernel, run the following commands:

sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
sudo iptables -A FORWARD -i wlan0 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT

Your Pi is now NAT-ing. To make this permanent so you don’t have to run the commands after each reboot, run the following command:

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"

Now edit the file /etc/network/interfaces and add the following line to the bottom of the file:

up iptables-restore < /etc/iptables.ipv4.nat

4. Issue commands to start the dhcp server:

sudo service udhcpd start

Your Pi should now be hosting a ethernet hotspot. To get the hotspot to start on boot, run these additional commands:

sudo update-rc.d udhcpd enable

Reboot  Pi and plugin the LAN cable and you can see the auto allocated ip on command ipconfig (on windows) / ifconfig (on linux).

If you have any problems please comment Below .

Buy Raspberry Pi Model A Plus India

Standard

The Raspberry Pi Model A+ is the perfect board for the minimalist Pi fan. This low-cost Pi uses the same processor as the model B+, but does away with the Ethernet jack and three of the USB Ports. This makes it lower power, less expensive and much lighter & smaller! It’s still compatible with all Pi operating systems and software, and has the exact same 40 pin GPIO connector and camera/display sockets, so any HATs or Pi Plates or other things that plug into the model B+ will work just the same.

It also has the same HDMI, sound/composite connector and micro USB connector for power.

Unlike the Raspberry Model B+, there’s only one USB port and no ethernet jack but it’s also significantly smaller at 65mm x 56mm if you don’t include overhang from the connectors. Also, there is only 256 MB of RAM onboard instead of 512, so if you have a RAM-intensive application you may need to stick with the B+

buynow-green-5

Technical Specs :

  • Dimensions: 65mm x 56mm / 2.5″ x 2.25″
  • Processor: ARM 700Mhz CPU
  • USB: One USB 2.0 Port – Keeping it compact means minifying the footprint as much as possible
  • Video Output: HDMI and Composite
  • Sound: L/R Stereo (via 3.5mm 4 Pole Cable)
  • Memory: 256MB Ram
  • Operating System: Uses microSD card slot to load O/S
  • Digital interfaces: 2 onboard ribbon slots for Camera and Display
  • GPIO: 40 GPIO pins, backwards compatible to B board
  • No Ethernet jack

buynow-green-5

[Solved] Raspberry Pi Wifi Disconnect Problems

Standard

Here Sometimes due to signal strength and some other issues the raspberry pi WiFi disconnects and will not reconnect automatically. Here is a script to check status of the WiFi and keep it connected.

Tip :- You can disconnect and connect wifi using   `sudo ifdown wlan0` and 'sudo ifup wlan0` respectively 

Change directory to /usr/local/bin  and create file Continue reading

Super VPN

Standard

When planning to protect your online identity, you should look for a VPN service that offers an ideal balance of price, features and online security. Everyone can benefit from using efficient VPN service – students, workers, Wi-Fi users and all those who want to download safely and free of charge. A VPN provider usually owns servers in various countries and can enable your secure communication via mail, chat and VoIP. All you have to do is easily set up a VPN connection and save yourself a lot of trouble. PPTP and SSL protocols guarantee data confidentiality and superior protection for all VPN users. You can save money, gain online anonymity and get total web freedom. Every client can easily unblock Facebook, explore the web freely and access any content. With so many sites locked, even the famous Wikipedia, using VPN service is a necessity nowadays. Basically, it ensures so many benefits that are hard to neglect. On the other hand, with so many online threats, VPN methods can also provide you with a safe way of browsing the Internet from your home computers or mobile devices. Your online presence is masked behind your provider so that your traffic cannot be monitored or restricted in any way.

How to Protect Your SSH Server With Fail2Ban [Linux/Ubuntu]

Standard

SH is a good tool for you to remotely access your computer/server and make changes to it as if you are in front of the computer. If you have a SSH server, we have shown you how to generate and use a public/private key so you can connect to the remote server securely, but that doesn’t mean your SSH server is safe. On the contrary, most SSH servers are vulnerable to brute force attack and if you are not paying attention, hackers could easily hack into your server and destroy/steal everything you have.

Fail2Ban is a simple, yet useful tool that can monitor your server from malicious attack and block them before they can wreak havoc.

Installation

Fail2Ban is already available in the Ubuntu repository, so you just issue install  command:

sudo apt-get install fail2ban

When you have finished installing Fail2Ban, the next step is to move the configuration file to a local folder so you won’t change the main configuration file accidentally.

sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local

Configuring fail2ban

After installall, Fail2Ban will automatically start to monitor your server for malicious attacks. In most cases, the default settings are sufficient to protect your site, but if you have some custom server configuration (like different port for SSH access) or want to enable some other services, here is how you can do so:

sudo nano /etc/fail2ban/jail.local

The configuration file is divided into different sections. The first one that you will come across is

[DEFAULT].

[DEFAULT]

# "ignoreip" can be an IP address, a CIDR mask or a DNS host
ignoreip = 127.0.0.1/8
bantime  = 600
maxretry = 3

# "backend" specifies the backend used to get files modification. Available
# options are "gamin", "polling" and "auto".
# yoh: For some reason Debian shipped python-gamin didn't work as expected
#      This issue left ToDo, so polling is default backend for now
backend = auto

#
# Destination email address used solely for the interpolations in
# jail.{conf,local} configuration files.
destemail = root@localhost

 

The few parameters that you need to take note here is ignoreipbantime and maxretry.

  • ignoreip – this is the place where you whitelist the IP that you don’t want to block. The default is the localhost (127.0.0.1/8). You can add additional IPs to the field, separating each IP with a space.
  • bantime – this is the amount of time in seconds to block the IP from accessing your server. The default is 10 minutes (600 seconds)
  • maxretry -this is the number of failed login attempt before the IP is blocked.

There is also the destemail field to specify an email  to notify when there is malicious attack is detected. (You need a mail server installed to get email working).

The next section is the “Actions”.

# ACTIONS
#

# Default banning action (e.g. iptables, iptables-new,
# iptables-multiport, shorewall, etc) It is used to define
# action_* variables. Can be overridden globally or per
# section within jail.local file
banaction = iptables-multiport

# email action. Since 0.8.1 upstream fail2ban uses sendmail
# MTA for the mailing. Change mta configuration parameter to mail
# if you want to revert to conventional 'mail'.
mta = sendmail

# Default protocol
protocol = tcp

# Specify chain where jumps would need to be added in iptables-* actions
chain = INPUT

#
# Action shortcuts. To be used to define action parameter

# The simplest action to take: ban only
action_ = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]

# ban &amp; send an e-mail with whois report to the destemail.
action_mw = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
              %(mta)s-whois[name=%(__name__)s, dest="%(destemail)s", protocol="%(protocol)s", chain="%(chain)s"]

# ban &amp; send an e-mail with whois report and relevant log lines
# to the destemail.
action_mwl = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
               %(mta)s-whois-lines[name=%(__name__)s, dest="%(destemail)s", logpath=%(logpath)s, chain="%(chain)s"]

# Choose default action.  To change, just override value of 'action' with the
# interpolation to the chosen action shortcut (e.g.  action_mw, action_mwl, etc) in jail.local
# globally (section [DEFAULT]) or per specific section
action = %(action_)s

 

Most of the settings here can be left default unless you want to change the banaction andprotocol. The default “banaction” is via the IPTable. You can get it to use the multi-port setting or create a new IpTable for this. The default value for the “protocol” is tcp, but you can change it to udp , depending on which connection you are using.

The last part of the “Jail” section where you can configure Fail2Ban to monitor your Apache server, FTP server, mail server and DNS server.

[ssh]
enabled  = true
port     = ssh
filter   = sshd
logpath  = /var/log/auth.log
maxretry = 6

 

n most cases, you just have to change the “enabled = false” setting to “enabled = true” and it will be activated for that service. If you are not using the usual port 20 for SSH, you can also change the port number in the setting above.

Once you are done with the configuration, press “Ctrl + o” to save and “ctrl + x” to exit.

Lastly, restart the Fail2Ban service with the command:

sudo service fail2ban restart

If you want to protect your Webmin which is running on port 10000

[webmin-iptables]
enabled  = true
filter   = webmin-auth
action   = iptables[name=webmin, port=10000, protocol=tcp]
 sendmail-whois[name=WEBMIN, dest=example@example.com, sender=example@example.com]
logpath  = /var/log/secure

Ref : 

How to Protect Your SSH Server With Fail2Ban [Linux/Ubuntu]

http://www.fail2ban.org/wiki/index.php/Fail2ban:Community_Portal

http://www.syntaxtechnology.com/2009/08/prevent-bruteforce-attacks-with-fail2ban/

Fix Missing Wireless Drivers on Ubuntu 12.04 , 13.10 BCM43xx Laptop

Standard

Your  Laptop’s Wifi not working in Ubuntu ? Here we have solution for BCM43xx Laptops ,

To check your model number

lspci | grep Wireless

Sample Result

0c:00.0 Network controller: Broadcom Corporation BCM4311 802.11a/b/g/n Wireless LAN Controller [14e4:432b] 

Here BCM4311 is ur model

How to FIX 

Get Internet  Via LAN cable or some where and run following command on terminal.

sudo apt-get remove --purge bcmwl-kernel-source
sudo apt-get install linux-firmware-nonfree
sudo modprobe b43

Restart your Laptop

Running Same WordPress Site on 2 Or More Domains !

Standard

 

Have you ever thought of running your wordpress site on two domains ie, with same content ?

Here is a simple solution for you.

Logic

Overriding the WP_SITEURL , WP_HOME, WP_PLUGIN_URL

Add the following lines to wp-config.php

$telsite=$_SERVER['SERVER_NAME'];

if($telsite=="arevindh.me")
   {
   define( 'WP_SITEURL', 'http://www.arevindh.me' );
   define( 'WP_HOME', 'http://www.arevindh.me' );
   define( 'WP_PLUGIN_URL', 'hwww.arevindh.me/wp-content/plugins' );
   }

else 
   {
   define( 'WP_SITEURL', 'http://www.arevindh.com' );
   define( 'WP_HOME', 'http://www.arevindh.com' ); 
   define( 'WP_PLUGIN_URL', 'http://www.arevindh.com/wp-content/plugins' );
   }

This is most simple method and you can also try something like this

define( 'WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']);

define( 'WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);

define( 'WP_PLUGIN_URL', 'http://' . $_SERVER['HTTP_HOST'].'/wp-content/plugins' );

Have any questions ? Just comment below 😀

-S!D