wiki:linux/Network

Mail, Mail/Mutt, Mail/mbsync, iptables, nmap, ntpdate, route, ssh, ssh/scp, ssh/sshfs, wlan



Guide to IP Layer Network Administration with Linux
Linux Home Networking
Heise Netzwerkrechner


Connect two laptops and share internet access

Connect two Linux machines via ethernet
ArchLinux Wiki: Internet share
Connecting to a network via another pc

Assuming that

  • Laptop-1 is connected with internet via wlan to router/gateway 192.168.0.1
  • Laptop-2 is connected with Laptop-1 via lan

Note: Ensure that both laptops are connected together within another subnet as for the wireless network

Laptop-1:

Setup ethernet card

# ifconfig eth0 192.168.1.1 netmask 255.255.255.0 up

Enable forwarding

# echo 1 > /proc/sys/net/ipv4/ip_forward

Use iptables to enable NAT

# iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE

Don't know... but for me it works without these 2 commands too?
# iptables -A FORWARD -i eth0 -o wlan0 -j ACCEPT
# iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT

Laptop-2:

Setup ethernet card

# ifconfig eth0 192.168.1.2 netmask 255.255.255.0 up

Route through Laptop-1's gateway

route add default gw 192.168.1.1
Last modified 5 years ago Last modified on Dec 17, 2014, 10:11:05 AM