Rasberry Pi 2 クロスケーブル

Rasberry Pi 2 と Arch Linux を、クロスケーブルで接続する方法

Rasberry 側

/etc/network/interfaces

auto lo

iface lo inet loopback
# iface eth0 inet dhcp
iface eth0 inet static
address 192.168.0.10
netmask 255.255.255.0
gateway 192.168.0.1

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
#
# iface default inet dhcp
/etc/rc.local

ifup eth0

/etc/resolv.conf

nameserver 8.8.8.8

SSH サーバー

# systemctl start ssh

ヘッドレスで ssh をスタートさせるには、/boot に、ssh という名前のファイルを置く。

A security update for Raspbian PIXEL

If you want to enable SSH, all you need to do is to put a file called ssh in the /boot/ directory. The contents of the file don’t matter: it can contain any text you like, or even nothing at all. When the Pi boots, it looks for this file; if it finds it, it enables SSH and then deletes the file.
Arch Linux 側

/etc/netctl/profile

Description='A basic static ethernet connection'
Interface=enp3s0f2
Connection=ethernet
IP=static
Address=('192.168.0.1/24')
# Routes=('192.168.0.1/24 via 192.168.0.10')
# Gateway='192.168.0.10'
起動

# systemctl start profile

もし、RTNETLINK answers: File exists というエラーが出たら

# ip addr flush dev enp3s0f2

Enable packet forwarding

# sysctl net.ipv4.ip_forward=1
Enable NAT

# iptables -t nat -A POSTROUTING -o wlp2s0 -j MASQUERADE
# iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
# iptables -A FORWARD -i enp3s0f2 -o wlp2s0 -j ACCEPT
ルーティング (参考)
$ netstat -r
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
default         pocketwifi.home 0.0.0.0         UG        0 0          0 wlp2s0
192.168.0.0     0.0.0.0         255.255.255.0   U         0 0          0 enp3s0f2
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 wlp2s0


Return

Sep/20/2016