LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-17-2014, 11:36 PM   #1
cin_
Member
 
Registered: Dec 2010
Posts: 281

Rep: Reputation: 24
internet connection sharing : ubuntu ICS


i am trying to set up internet connection sharing on my ubuntu box

i have an internet connection coming in from wlan0
and i am trying to pipe it out of eth0

Code:
ifconfig
eth0      Link encap:Ethernet  HWaddr blah:blah   
          inet6 addr: fe80::ae16:2dff:fe0c:2ad5/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:86163 errors:0 dropped:155 overruns:0 frame:0
          TX packets:1808 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:50718618 (50.7 MB)  TX bytes:469236 (469.2 KB)

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:65536  Metric:1
          RX packets:40954 errors:0 dropped:0 overruns:0 frame:0
          TX packets:40954 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:4150244 (4.1 MB)  TX bytes:4150244 (4.1 MB)

wlan0     Link encap:Ethernet  HWaddr blah:blah  
          inet addr:192.168.1.109  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::225:22ff:fe42:cfc7/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:10656245 errors:0 dropped:0 overruns:0 frame:0
          TX packets:13915510 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:7017759989 (7.0 GB)  TX bytes:15390432267 (15.3 GB)

i have tried a number of tutorials:
https://help.ubuntu.com/community/In...nectionSharing
http://www.howtoforge.com/internet-c...ading-on-linux
http://www.backtrack-linux.org/forum...ad.php?t=28206
and on and on, if you can search it down on the internet i've tried it
i think i am doing a poor job of altering the tuts to my own use case..

the thing that really bothers me is that i had it running smooth nearly two months ago for about three weeks then i had to move the server and so i unplugged it and i guess the iptables was flushed,
now i am unable to get it back.. whatever that magical configuration was it is gone now

here are two scripts i pieced together, pulled from the ubuntu tut and modified, to avoid losing my setup again in case of reboot:

flush for a hard reset:
Code:
#!/bin/sh
echo "Stopping firewall and allowing everyone..."
sudo iptables -F
sudo iptables -X
 sudo iptables -t nat -F
 sudo iptables -t nat -X
 sudo iptables -t mangle -F
 sudo iptables -t mangle -X
 sudo iptables -P INPUT ACCEPT
 sudo iptables -P FORWARD ACCEPT
 sudo iptables -P OUTPUT ACCEPT
echo "3x17"
am i setting the correct ips: 192.168.1.1; if my inbound connection is wlan0 with an addr of:
wlan0 inet addr:192.168.1.109

setup legwork:
Code:
#!/bin/sh 
# 
# internet connection sharing wlan0 is the gate way 
# eth0 is the lan port this might use a straight ethernet cable to a router wan port or a switch or a single PC
# 192.168.2.2 is the port that is being used by the lan for access I changed it to 192.168.2.254 and set fixed addresses for the wan and router
#
# change wlan0 to ppp0 and you can use this for mobile broadband connection sharing
#
sudo ip link set dev eth0 up
sudo ip addr add 192.168.1.1/24 dev eth0
sudo sysctl net.ipv4.ip_forward=1
sudo iptables -t nat -A POSTROUTING -o wlan0 -s 192.168.1.1/24 -j MASQUERADE
sudo iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 3074 -j DNAT --to-destination 192.168.1.1
sudo iptables -t nat -A PREROUTING -i wlan0 -p udp -m multiport --dports 88,3074 -j DNAT --to-destination 192.168.1.1
sudo iptables -A FORWARD -i wlan0 -d 192.168.1.1 -p tcp --dport 3074 -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -d 192.168.1.1 -p udp -m multiport --dports 88,3074 -j ACCEPT
sudo /etc/init.d/dnsmasq restart
sudo /etc/init.d/networking restart
sudo /etc/init.d/dns-clean restart
sudo /etc/init.d/wicd restart
echo "3x17"
any help greatly appreciated, thanks

Last edited by cin_; 06-19-2014 at 02:21 PM. Reason: gramm`err
 
Old 06-19-2014, 02:56 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,042

Rep: Reputation: 3632Reputation: 3632Reputation: 3632Reputation: 3632Reputation: 3632Reputation: 3632Reputation: 3632Reputation: 3632Reputation: 3632Reputation: 3632Reputation: 3632
We don't know what the status of the scripts/system could be now. Might boot to a live media and try this. http://askubuntu.com/questions/35985...rough-ethernet
 
Old 06-19-2014, 11:28 PM   #3
cin_
Member
 
Registered: Dec 2010
Posts: 281

Original Poster
Rep: Reputation: 24
figured

i was trying a number of different ips and decided to try to automate the ip designation and the ics began working..
perhaps i was missing one of the declarations or i needed to use an ip more closely associated with my incoming signal

here's the script

Code:
#!/bin/sh 
#first argument is where the signal is coming in, and the second argument is where the signal is going out

# internet connection sharing $1 is the gate way 
# $2 is the lan port this might use a straight ethernet cable to a router wan port or a switch or a single PC
#
# change $1 to ppp0 and you can use this for mobile broadband connection sharing
#

helper() {
  echo "  -h for this dialog"
  echo "  $0  ARG1 ARG2"
  echo "      ARG1 :: line in device"
  echo "      ARG2 :: line out device"
}

clean() {
  echo "Stopping firewall and allowing everyone..."
  sudo iptables -F
  sudo iptables -X
  sudo iptables -t nat -F
  sudo iptables -t nat -X
  sudo iptables -t mangle -F
  sudo iptables -t mangle -X
  sudo iptables -P INPUT ACCEPT
  sudo iptables -P FORWARD ACCEPT
  sudo iptables -P OUTPUT ACCEPT
}

ics() {
  #theip="192.168.1.1" #example
  theip="$(ifconfig "$1" | grep "inet addr" | cut -d":" -f2 | cut -d" " -f1 | cut -d"." -f1,2,3)"".1" 
  sudo ip link set dev "$2" up
  sudo ip addr add "${theip}"/24 dev "$2"
  sudo sysctl net.ipv4.ip_forward=1
  sudo iptables -t nat -A POSTROUTING -o "$1" -s "${theip}"/24 -j MASQUERADE
  sudo iptables -t nat -A PREROUTING -i "$1" -p tcp --dport 3074 -j DNAT --to-destination "${theip}"
  sudo iptables -t nat -A PREROUTING -i "$1" -p udp -m multiport --dports 88,3074 -j DNAT --to-destination "${theip}"
  sudo iptables -A FORWARD -i "$1" -d "${theip}" -p tcp --dport 3074 -j ACCEPT
  sudo iptables -A FORWARD -i "$1" -d "${theip}" -p udp -m multiport --dports 88,3074 -j ACCEPT
  sudo /etc/init.d/dnsmasq restart
  sudo /etc/init.d/networking restart
  sudo /etc/init.d/dns-clean restart
  sudo /etc/init.d/wicd restart
}

if [ "$#" -lt 2 ]; then
  case "$1" in
    "clean")clean;;
    *)helper;;
  esac
else
  ics $1 $2
fi

echo "3x17"
#./ics wlan0 eth0

Last edited by cin_; 06-19-2014 at 11:46 PM. Reason: gramm`err
 
  


Reply

Tags
internet connection, iptables, routing, wlan


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Question concerning the security of ICS in Ubuntu rywres2010 Linux - Security 2 06-04-2011 12:32 AM
Ubuntu ICS Cut Off by Firewall pmascari Linux - Newbie 2 10-07-2010 03:06 PM
ICS-- wired Ubuntu 7.10 to vista over ad hoc wifi hydroscrog Linux - Wireless Networking 3 01-10-2008 08:24 PM
[help] ubuntu: configuring ics on it kazi090 Linux - Newbie 2 11-27-2007 03:15 AM
XP to Ubuntu ICS : file configuration query. uncle-c Linux - Networking 19 11-09-2007 03:23 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 05:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration