Sharing "things" between Ubuntu Studio 11.10 and...

Ralf Mardorf ralf.mardorf at alice-dsl.net
Sat Feb 18 18:51:16 UTC 2012


# gedit /home/spinymouse/adhoc
# cat /home/spinymouse/adhoc
#! /bin/sh
# sh ./adhoc
# https://help.ubuntu.com/community/WifiDocs/Adhoc

device=wlan0
sudo service network-manager stop
sudo ip link set $device down
sudo iwconfig $device mode ad-hoc
sudo iwconfig $device channel 4
sudo iwconfig $device essid 'oz'
sudo iwconfig $device key 1324354657
# sudo dhclient $device
sudo ip addr add 169.254.34.2/16 dev $device

#
http://www.linuxquestions.org/questions/slackware-14/routing-ip-masquerade-nat-question-880715/

# default policies
/usr/sbin/iptables -t nat -P POSTROUTING ACCEPT
/usr/sbin/iptables -t nat -P OUTPUT ACCEPT
/usr/sbin/iptables -t nat -P PREROUTING ACCEPT
/usr/sbin/iptables -t filter -P INPUT DROP
/usr/sbin/iptables -t filter -P FORWARD DROP
/usr/sbin/iptables -t filter -P OUTPUT DROP

# NAT on behalf of secondary LAN 
/usr/sbin/iptables -t nat -A POSTROUTING -s 192.168.2.0/255.255.255.0 -j
SNAT
--to-source 192.168.1.xxx

# forward packets from/to secondary LAN
/usr/sbin/iptables -t filter -A FORWARD -s 192.168.2.0/255.255.255.0 -j
ACCEPT
/usr/sbin/iptables -t filter -A FORWARD -d 192.168.2.0/255.255.255.0 -j
ACCEPT

exit 0

# sh /home/spinymouse/adhoc
network-manager stop/waiting
/home/spinymouse/adhoc: 18: /usr/sbin/iptables: not found
/home/spinymouse/adhoc: 19: /usr/sbin/iptables: not found
/home/spinymouse/adhoc: 20: /usr/sbin/iptables: not found
/home/spinymouse/adhoc: 21: /usr/sbin/iptables: not found
/home/spinymouse/adhoc: 22: /usr/sbin/iptables: not found
/home/spinymouse/adhoc: 23: /usr/sbin/iptables: not found
/home/spinymouse/adhoc: 26: /usr/sbin/iptables: not found
/home/spinymouse/adhoc: 27: --to-source: not found
/home/spinymouse/adhoc: 30: /usr/sbin/iptables: not found
/home/spinymouse/adhoc: 31: /usr/sbin/iptables: not found

FWIW, the iPad still can connect to "oz" and I assume connecting to the
Internet still won't work. Perhaps better, as long as there isn't a
password required. Judges of my hometown Oberhausen Rheinland pronounce
people guilty if something forbidden happens, even if everything was
protected and somebody cracked the protection. It's the owner's fault if
somebody was able to hack the protection.

# synaptic

Ok, it's installed to /sbin.

# gedit /home/spinymouse/adhoc
# cat /home/spinymouse/adhoc
#! /bin/sh
# sh ./adhoc
# https://help.ubuntu.com/community/WifiDocs/Adhoc

device=wlan0
sudo service network-manager stop
sudo ip link set $device down
sudo iwconfig $device mode ad-hoc
sudo iwconfig $device channel 4
sudo iwconfig $device essid 'oz'
sudo iwconfig $device key 1324354657
# sudo dhclient $device
sudo ip addr add 169.254.34.2/16 dev $device

#
http://www.linuxquestions.org/questions/slackware-14/routing-ip-masquerade-nat-question-880715/

# default policies
sudo iptables -t nat -P POSTROUTING ACCEPT
sudo iptables -t nat -P OUTPUT ACCEPT
sudo iptables -t nat -P PREROUTING ACCEPT
sudo iptables -t filter -P INPUT DROP
sudo iptables -t filter -P FORWARD DROP
sudo iptables -t filter -P OUTPUT DROP

# NAT on behalf of secondary LAN 
sudo iptables -t nat -A POSTROUTING -s 192.168.2.0/255.255.255.0 -j SNAT
\
--to-source 192.168.1.xxx

# forward packets from/to secondary LAN
sudo iptables -t filter -A FORWARD -s 192.168.2.0/255.255.255.0 -j
ACCEPT
sudo iptables -t filter -A FORWARD -d 192.168.2.0/255.255.255.0 -j
ACCEPT

exit 0

Intended to run as user, anyway ...

# sh /home/spinymouse/adhoc
stop: Unknown instance: 
RTNETLINK answers: File exists
iptables v1.4.10: Bad IP address "192.168.1.xxx"

Try `iptables -h' or 'iptables --help' for more information.

# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:1e:8c:80:2a:eb  
          inet6 addr: fe80::21e:8cff:fe80:2aeb/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:53230 errors:0 dropped:0 overruns:0 frame:0
          TX packets:44777 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:50841001 (50.8 MB)  TX bytes:6468092 (6.4 MB)
          Interrupt:43 Base address:0x8000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:16 errors:0 dropped:0 overruns:0 frame:0
          TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:1296 (1.2 KB)  TX bytes:1296 (1.2 KB)

ppp0      Link encap:Point-to-Point Protocol  
          inet addr:85.182.19.232  P-t-P:213.191.89.25
Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1492  Metric:1
          RX packets:52025 errors:0 dropped:0 overruns:0 frame:0
          TX packets:43534 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:3 
          RX bytes:49624075 (49.6 MB)  TX bytes:5467008 (5.4 MB)

The iPad still claims it's connected to "oz", for DHCP and BootIP it shows:

IP-Adresse: 169.254.187.135
Teilnetzmaske: 255.255.0.0 (I guess it's "subnet mask")

But the connection to the Internet doesn't work anymore *reboot*.




More information about the Ubuntu-Studio-users mailing list