View previous topic :: View next topic |
Author |
Message |
Jim6 Tux's lil' helper
Joined: 08 Apr 2005 Posts: 102
|
Posted: Tue Jun 28, 2005 2:21 pm Post subject: Setting up a box to act as a gateway. {explained} |
|
|
I've just set up a box(2) which connects to the net through eth0 (192.168.1.3) to box 1 (192.168.1.1) which acts as box 2's gateway. I want to be able to connect my laptop to eth1 on box(2) using a crossover cable.
How should I go about doing this? What kind of ip address range should I assign the laptop and eth1? What do I have to do with regard to routing tables with regards to gatways?
Sorry; I don't have much of a clue
Last edited by Jim6 on Thu Jun 30, 2005 3:53 pm; edited 1 time in total |
|
Back to top |
|
|
Voorhees51 Guru
Joined: 05 Nov 2003 Posts: 358
|
Posted: Tue Jun 28, 2005 2:43 pm Post subject: |
|
|
Just a thought.
If you happen to have an extra hub or switch around, you could set the gateway box to be a dhcp server for your internal network, then just set your ip range that it serves, and you should be good to go, just set your other computers that are going to connect to it, to get their IP address by DHCP. |
|
Back to top |
|
|
Jim6 Tux's lil' helper
Joined: 08 Apr 2005 Posts: 102
|
Posted: Tue Jun 28, 2005 11:12 pm Post subject: |
|
|
I would, but don't have one. And I can't afford much of anything these days The setup I've outlined makes sense given the layout of the systems in the flat.
So can anyone help me? {even if just to point me in the right directions(s)} |
|
Back to top |
|
|
beandog Bodhisattva
Joined: 04 May 2003 Posts: 2072 Location: /usa/utah
|
Posted: Tue Jun 28, 2005 11:27 pm Post subject: |
|
|
I would emerge dnsmasq -- its the easiest quickest way of setting up a DHCP server I've seen.
Or, instead of using a DHCP server, you could just manually configure net.ethx (the port you share your connection on) and then manually set your IP address on your laptop.
And then, no matter what you choose, make sure you turn on ip forwarding within iptables. If you look at the ebuild or emerge it again, it will say what you need to set in /proc.
That's a very summarized set of basic instructions. _________________ If it ain't broke, tweak it. dvds | blurays | blog | wiki |
|
Back to top |
|
|
Jim6 Tux's lil' helper
Joined: 08 Apr 2005 Posts: 102
|
Posted: Tue Jun 28, 2005 11:49 pm Post subject: |
|
|
... A little too summarised, I'm afraid
I can't be bothered using DHCP; I'd prefer to keep them static. What kind of ip range would suit?
And where should I start with the ip forwarding? |
|
Back to top |
|
|
beandog Bodhisattva
Joined: 04 May 2003 Posts: 2072 Location: /usa/utah
|
Posted: Wed Jun 29, 2005 2:01 pm Post subject: |
|
|
Any ip range is sufficient as long as you don't have it the same as your device connected to the net.
Here's an example -- I have my internet connection which comes in through my router, then goes to my desktop. I get an ip address on my desktop using dhcp on eth0, so eth0 is 192.168.0.1.
I have a second card in my desktop (eth1) that I manually set the ip address to something else, like 192.168.1.1. To do that, I add this line in /etc/conf.d/net:
Code: | iface_eth1="192.168.1.1 broadcast 192.168.1.255 netmask 255.255.255.0" |
and then I restart /etc/init.d/net.eth1 so it sets everything for me. You can verify the settings by running ifconfig eth1.
Then I grab my crossover cable and plug it into my network card on my laptop, and the other one in the second nic in my desktop.
On my laptop, I manually set eth0 instead of using dhcp in /etc/conf.d/net. The address is going to be the same as in the first one, except I'm using a different ip address:
Code: | iface_eth0="192.168.1.2 broadcast 192.168.1.255 netmask 255.255.255.0" |
That should work, and after you set that up, you should at least be able to ping your desktop (192.168.1.1) from your laptop, but you can't get onto the Internet until you actually setup ip forwarding on your desktop.
The way to do that is you have to have iptables installed and running (emerge net-firewall/iptables; /etc/init.d/iptables start) and then run this command to turn on forwarding:
Code: | echo "1" > /proc/sys/net/ipv4/conf/all/forwarding |
Oh, and of course you'll have to have all the right modules turned on in your kernel before the forwarding will work anyway.
If you want iptables to do that everytime on boot, just add that last command to /etc/conf.d/local.start
Finally, copy your /etc/resolv.conf from your desktop to you laptop, and that should let you get on the 'net.
hth _________________ If it ain't broke, tweak it. dvds | blurays | blog | wiki |
|
Back to top |
|
|
Jim6 Tux's lil' helper
Joined: 08 Apr 2005 Posts: 102
|
Posted: Thu Jun 30, 2005 3:52 pm Post subject: |
|
|
Cool - thanks for the pointers.
Found a tutorial on iptables here and now it's all working
Thanks! |
|
Back to top |
|
|
|