simple networking on raspberry pi

network configuration file
sudo nano /etc/network/interfaces

use pre/post-scripts in interfaces-file

restart network interface
sudo /etc/init.d/networking restart

get open connections and open ports on your machine
netstat -a
netstat -an

hosts / hostname
/etc/hosts
/etc/hostname

nameserver
/etc/resolv.conf

configure an access-point with edimax

install packages hostapd and dnsmasq
sudo apt-get install hostapd dnsmasq

add the wlan0 config to /etc/network/interfaces

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
  address 10.0.0.1
  netmask 255.255.255.0
check /etc/default/hostapd if the path is set correct
DAEMON_CONF=“/etc/hostapd.conf“

configure your /etc/hostapd.conf to something like this (additional info here)

interface=wlan0
driver=rtl871xdrv
 
ssid=HACKER_WIFI
channel=4
 
wpa=1
wpa_passphrase=cmonboy123
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
 
wmm_enabled=1
auth_algs=3
macaddr_acl=0

check status of hostapd

sudo service hostapd status

because of driver problems you have to use a different one

wget http://dl.dropbox.com/u/1663660/hostapd/hostapd.zip
unzip hostapd.zip && \
sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.original && \
sudo mv hostapd /usr/sbin/hostapd.edimax && \
sudo ln -sf /usr/sbin/hostapd.edimax /usr/sbin/hostapd && \
sudo chown root.root /usr/sbin/hostapd && \
sudo chmod 755 /usr/sbin/hostapd

dhcp-config for this file /etc/dnsmasq.conf
interface=wlan0
no-dhcp-interface=eth0
dhcp-range=interface:wlan0,10.0.0.2,10.0.0.20,255.255.255.0,infinite
dhcp-option=3,10.0.0.1

log-facility=/var/log/dnsmasq.log
address=/#/10.0.0.1
interface=wlan0
except-interface=eth0
dhcp-range=wlan0,10.0.0.10,10.0.0.250,12h
no-resolv
log-queries

check status of dnsmasq

sudo service dnsmasq status

check config here /etc/sysctl.conf if this line is active
net.ipv4.ip_forward=1

create this file /etc/network/if-up.d/router.sh and add
iptables –table nat –append POSTROUTING –out-interface eth0 -j MASQUERADE
iptables –append FORWARD –in-interface wlan0 -j ACCEPT

make it executable
sudo chmod 755 /etc/network/if-up.d/router.sh

add this line to /etc/rc.local
ifup wlan0

if „if-up.d“ does not work use save/restore of iptables in /etc/network/interfaces on the bottom
up iptables-restore < /etc/iptables.ipv4.nat
now reboot

infos from here and here

troubleshooting

in case of driver problems see this page and install another driver

problem with wlan0 no ip – see this page
dnsmasq-dhcp[2297]: DHCP packet received on wlan0 which has no address
in /etc/default/ifplugd, the default configuration is this

INTERFACES=“auto“
HOTPLUG_INTERFACES=“all“
ARGS=“-q -f -u0 -d10 -w -I“
SUSPEND_ACTION=“stop“

Simply changing it to this

INTERFACES=“eth0″
HOTPLUG_INTERFACES=“eth0″
ARGS=“-q -f -u0 -d10 -w -I“
SUSPEND_ACTION=“stop“

problems with hostapd

hostapdioctl[RTL_IOCTL_HOSTAPD]: Invalid argument
sudo apt-get remove -y wolfram-engine

info from here

Advertisements

Kommentar verfassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

WordPress.com-Logo

Du kommentierst mit Deinem WordPress.com-Konto. Abmelden / Ändern )

Twitter-Bild

Du kommentierst mit Deinem Twitter-Konto. Abmelden / Ändern )

Facebook-Foto

Du kommentierst mit Deinem Facebook-Konto. Abmelden / Ändern )

Google+ Foto

Du kommentierst mit Deinem Google+-Konto. Abmelden / Ändern )

Verbinde mit %s