Forward internet connection to another machine.
What the fuck is this ?
If one wants to forward his internet connection to another machine.
Easiest way to explain what this is, is by showing it up like this :
Router* ---> Your computer ---> Second computer.
*Depending on if you use a router or not... heh..
What you need:
The tutorial is for ethernet cards. I have not tried using wireless, but with some modifications you should be able to manage doing that. Also I will be using IPv4 but not IPv6.
Configure the network cards on your computer
So, lets start of by configuring our network cards.
net0 is the one connected out to the network.
net1 is the one connected to the second machine.
Make sure net0 is configured just as normally but with static IP.
Now, net1 should be something like this :
IP: 192.168.0.1
Netmask : 255.255.255.0
Now take a look at your second computer.
The network should be configured like this :
IP : 192.168.0.2 (Anything from 192.168.0.2-254 just not the same as net1)
Netmask: 255.255.255.0
Default Router : 192.168.0.1
Primary DNS : The DNS server you use. (you should be able to use 8.8.8.8 (Google))
Configuring iptables and your machine
First of all lets make sure your computer allows ip.forwarding...
there are 2 ways to do this :
echo “1″ > /proc/sys/net/ipv4/ip_forward
or
sysctl net.ipv4.ip_forward=1
Now, get to your computer and put these rules in iptables :
iptables -t nat -A POSTROUTING -o net0 -j MASQUERADE
To explain this a little :
-t nat Match NAT packet matching table and specifies the built-in POSTROUTING chain for NAT on the firewall's external networking device (net0).
-A POSTROUTING POSTROUTING allows packets to be altered as they are leaving the firewall's external device.
-o net0 external networking device.
-j MASQUERADE is specified to mask the private IP address of a node with the external IP address of the firewall/gateway.
Then save those rules with :
iptables-save
Now if you run iptables -L the output should be like this :
That should do it and you should be able to connect to the internet on both computer.
If you have any trouble, ask away ;*
Have fun ;**
What the fuck is this ?
If one wants to forward his internet connection to another machine.
Easiest way to explain what this is, is by showing it up like this :
Router* ---> Your computer ---> Second computer.
*Depending on if you use a router or not... heh..
What you need:
- Linux machine with 2 ethernet network cards
- second computer
The tutorial is for ethernet cards. I have not tried using wireless, but with some modifications you should be able to manage doing that. Also I will be using IPv4 but not IPv6.
Configure the network cards on your computer
So, lets start of by configuring our network cards.
net0 is the one connected out to the network.
net1 is the one connected to the second machine.
Make sure net0 is configured just as normally but with static IP.
Now, net1 should be something like this :
IP: 192.168.0.1
Netmask : 255.255.255.0
Now take a look at your second computer.
The network should be configured like this :
IP : 192.168.0.2 (Anything from 192.168.0.2-254 just not the same as net1)
Netmask: 255.255.255.0
Default Router : 192.168.0.1
Primary DNS : The DNS server you use. (you should be able to use 8.8.8.8 (Google))
Configuring iptables and your machine
First of all lets make sure your computer allows ip.forwarding...
there are 2 ways to do this :
echo “1″ > /proc/sys/net/ipv4/ip_forward
or
sysctl net.ipv4.ip_forward=1
Now, get to your computer and put these rules in iptables :
iptables -t nat -A POSTROUTING -o net0 -j MASQUERADE
To explain this a little :
-t nat Match NAT packet matching table and specifies the built-in POSTROUTING chain for NAT on the firewall's external networking device (net0).
-A POSTROUTING POSTROUTING allows packets to be altered as they are leaving the firewall's external device.
-o net0 external networking device.
-j MASQUERADE is specified to mask the private IP address of a node with the external IP address of the firewall/gateway.
Then save those rules with :
iptables-save
Now if you run iptables -L the output should be like this :
PHP Code
<?php
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
That should do it and you should be able to connect to the internet on both computer.
If you have any trouble, ask away ;*
Have fun ;**
