11

Ubuntu 11.04 (PC-1) is connected to PC-2 (Windows XP) with LAN cable (crossover direct cable)
Internet access is through USB wireless modem accessing router in separate room

If I boot in Windows 7 (PC-1 has dual boot) I have no problem to connect to PC-2, at the same time being connected to Internet, even sharing my Internet connection with PC-2. I set static IP address and Subnet mask on both PCs and that's all for bare connection. Additionally I have set Remote Desktop Sharing and Internet connection sharing, which works as expected.

My problem:

  1. I can't find a way to connect Ubuntu with PC-2 (Wired LAN connection)
  2. When I was using Debian (month ago, as my first Linux experiance) I used Wicd and I could connect to PC-2, but I could not have Internet connection at the same time (either Wired or Wireless)

Can someone enlighten a bit this network issues, as man pages or help files aren't for bare mortals like me, but perhaps for network experts, as I did not understood a word in it

Thanks

zetah
  • 9,673

1 Answers1

9

you need to go into network manager and change your ip4 settings to shared to other computers

enter image description here

here is the other method using ip tables

this will set the ip of your ethernet card

sudo ip addr add 192.168.1.1/24 dev eth0

and this will configure the nat

sudo iptables -A FORWARD -o wlan0 -i eth0 -s 192.168.1.0/24 -m conntrack --ctstate NEW -j ACCEPT
sudo iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A POSTROUTING -t nat -j MASQUERADE

if the connection you are using for internet is different from wlan0 change that so if you are using mobile broadband it will most likely be ppp0

when you have done that you can save the settings by doing

sudo iptables-save > filename

and to reload the settings

iptables-restore < filename

the restore is needed because after a reboot iptables will forget what the settings entered above if you want it to load every time just put the restore line in /etc/rc.local

dave
  • 316
  • PC-2 has static IP address: 192.168.1.2. I tried editing Routes (grayed button on your screenshot) and assigning IP 192.168.1.1 to PC-1 as that is set as Default gateway on PC-2. Unfortunately no results - I can't see PC-2 and I did log out - log in. I also tried this: [link] (http://askubuntu.com/questions/10741/how-to-set-up-dual-wired-and-wireless-connections) without success and your suggestion without success – zetah Aug 25 '11 at 05:53
  • ok forgot windows only has one set of rules for ip address i will edit my post to use iptables instead – dave Aug 25 '11 at 10:37
  • Thanks Dave, but still no luck. I can't see PC-2 in Nautilus, nor I can connect with Remmina. I booted in Windows 7 to see if there are maybe some problems, but everything is fine there - I can connect to PC-2 filesystem and use RDC. Here are contents of the iptables file: http://pastebin.com/raw.php?i=0XVQpC79 – zetah Aug 25 '11 at 15:33
  • i do have another suggestion i changed the post slightly if you could set the iptable with eth0 instead of eth1 and also when you connect to internet is that through wifi – dave Aug 25 '11 at 18:52
  • Now I can connect to PC-2 :) but Internet connection does not work. I now have both Wired (eth0) and Wireless (wlan0 I assume?) connected. If I want to use Internet I have to disconnect Wired connection and lose connection to PC-2. I enabled "Shared to other computers" in Wired (eth0), then in both Wired and Wireless profiles in NetworkManager, with same result. Here is iptables file now: http://pastebin.com/raw.php?i=0czy4GJ6 – zetah Aug 26 '11 at 02:30
  • i think it is prioritising eth0 over wlan0 for internet if you set your wired ip4 to manual on your ubuntu pc set the ip address to 192.168.1.1 you netmask to 255.255.255.0 and leave the gateway empty it won't default to eth0 you may want to add a second entry in wired with a gateway for when you connect the other way with internet on the windows pc – dave Aug 26 '11 at 16:22