I have followed Luis Alvarado's post on Sharing Connection to other PCs (Via Wired Ethernet) up until the "Client PC" part and am now sharing my laptop's internet connection with my Desktop server with an ethernet cable.
However, only my laptop can see the server (at 10.42.0.50), no other machines on the network have access to it. How can I make my server visible to the entire network?
IFCONFIG for client laptop:
eth0 Link encap:Ethernet HWaddr 88:51:fb:fc:53:83
inet addr:10.42.0.1 Bcast:10.42.0.255 Mask:255.255.255.0
inet6 addr: fe80::8a51:fbff:fefc:5383/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:45824 errors:0 dropped:0 overruns:0 frame:0
TX packets:79374 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:3211077 (3.2 MB) TX bytes:119560393 (119.5 MB)
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:48417 errors:0 dropped:0 overruns:0 frame:0
TX packets:48417 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:20154679 (20.1 MB) TX bytes:20154679 (20.1 MB)
virbr0 Link encap:Ethernet HWaddr 26:61:43:c4:5a:eb
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
wlan0 Link encap:Ethernet HWaddr 60:36:dd:05:21:de
inet addr:192.168.1.4 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::6236:ddff:fe05:21de/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1221932 errors:0 dropped:0 overruns:0 frame:0
TX packets:1361697 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:480592551 (480.5 MB) TX bytes:1308414648 (1.3 GB)
IFCONFIG for server:
eth0 Link encap:Ethernet HWaddr 00:16:76:90:b6:87
inet addr:10.42.0.50 Bcast:10.42.0.255 Mask:255.255.255.0
inet6 addr: fe80::216:76ff:fe90:b687/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:23833 errors:0 dropped:0 overruns:0 frame:0
TX packets:13747 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:35930553 (35.9 MB) TX bytes:971695 (971.6 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:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
OK, the issue here is that you have set up your laptop as the gateway. Presumably, you chose the "Automatic" rather than the "Manual" approach on the guide you followed. You need to go back to network settings on the sever and set it to manual:
In the above picture, I have set the following:
Address: 192.168.1.50
: this is the IP address of the server. The important part is the192.168.1
, this will make sure that your server is on the same network as the rest of your local network. The last number,50
, I chose randomly, all that is needed is that it be a number beyond the range of addresses that your DHCP server allocates. This is usually your router and you should check the settings just to be sure, but 50 should be fine.Netmask: 255.255.255.0
: This is to make sure that the server is on the same subnet, for more details see here.Gateway: 192.168.1.1
: This is the address of your router, based on theifconfig
output you posted, this should be correct.DNS: 212.27.40.240
: This is the address of the DNS server, the server you contact in order to translate numeric IPs into host names likegoogle.com
. I have chosen the OpenDNS server but you can use another, just copy the settings from your laptop's connection.Once you have done that, just reconnect and your server should be visible at
192.168.1.50
.If you don't have a GUI (you can install one very easily on the Server edition by the way), you'll need to define all this in the file
/etc/network/interfaces
. Open it with a text editor (usingnano
as an example but you can useemacs
or whatever you are most comfortable with):It probably looks like this:
Make it look like this:
Save the file (with
nano
: Ctrl+O, then Enter, then Ctrl+X)That sets up the network settings, the DNS server might not be necessary. If after making the changes above you can't connect to http://google.com but you can connect to, for example
74.125.195.139
(that's google.fr in case you're wondering) you will need to configure the DNS servers. To do this, open the file/etc/resolv.conf
with nano:And add this line:
Now, disconnect, reconnect and you should be fine.
This answer presumes several things (like IP's and that you have bash) and may not work out as you it's intended, please proceed with care.
If I read your question correctly, you want that the port 80 on your server is available to the LAN/wlan0 device, and that the server can just connect to internet fine. Well, first of all, reconfigure everything as it's shown in the question otherwise I can not guarantee this will work out. Second, do backups of the configuration just in case you break something along the way. This includes a dump of your
iptables
. Just usingiptables-save
. This script needs to be saved on your laptop.Ok, the script just needs to be saved somewhere and just execute it as super user (using sudo). Each time you boot your laptop, you should execute the script again.
Now the script is well commented, but the interesting part is where it says "Forwarding". It figuratively translates package information from one network to other. In this case, it translate everything sent from your server as if comes out from your laptop and everything that reach port 80 to your laptop gets redirected to the server.
The script is based on this helper http://www.slackware.com/~alien/efg/index.php