LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   how can i set two lan cards in ubuntu server 8.10 (https://www.linuxquestions.org/questions/linux-server-73/how-can-i-set-two-lan-cards-in-ubuntu-server-8-10-a-689053/)

machinakias 12-08-2008 03:35 AM

how can i set two lan cards in ubuntu server 8.10
 
hello all! i need some help pls...
here's the issue: i use ubuntu 8.10 server with two lan cards.

eth0 is set with static ip (192.168.0.2) connected to my modem-router for access internet. this one goes fine...

eth1 is set also static (192.168.0.3) connected to a switch for my clients (windows xp and ubuntu)

i have installed dhcp3 server in my server and cut off dhcp from the router.also works ok....server goes to internet,and my client gets dhcp ip address from the server.

the thing is that i cannot access the internet from my client...
and some times when i get connected to the client i cant access the internet from the server...

what is going wrong?
i tried changing gateway to the eth1 (from 192.168.0.1 to 0.2) but no luck....

please anyone who can help? thanx a lot!

Nibbl3r 12-08-2008 04:20 AM

Did you put in Routes? So your Server knows does it has to forward all requests to the router?

robertjinx 12-08-2008 04:28 AM

you need iptables to do a masquerade and enable "ip_forarding" in your server kernel.

example:

iptables -A POSTROUTING -s 192.168.0.3/255.255.255.0 -d ! 192.168.0.3/255.255.255.0 -o eth0 -j MASQUERADE

echo "1" > /proc/sys/net/ipv4/ip_forward

Something like this will allow eth1 to go through eth0.

Good luck!

machinakias 12-08-2008 07:34 AM

well thanx for your help folks!!! one more thing...

as anwser to Nibbl3r....no i didnt do such a thing...

and robert...do i have to download anything (like iptables or somothing?) to do it?

robertjinx 12-08-2008 07:55 AM

iptables should be already in the system, thats it. just try it and see what happens.

in case of some problems just run: iptables -F to flush all rules.

nausser 01-02-2009 09:18 PM

NAT Configuration in Ubuntu Server 8.10
 
Set your static IP configurations on eth0 and eth1.
Make eth0 your primary or outside interface.(internet) Set eth1 to desired address pool to be used as the default route for dhcp clients.(switch) Do not specify a default gateway for eth1, only eth0.
Edit these settings in the /etc/network/interfaces
See example below:

# The primary network interface (Public)
auto eth0
iface eth0 inet static
address 87.65.23.70
netmask 255.255.255.224
network 87.65.23.64
broadcast 87.65.23.95
gateway 87.65.23.65

# The secondary network interface (Private)
auto eth1
iface eth1 inet static
address 192.168.3.1
netmask 255.255.255.0
network 192.168.3.0
broadcast 192.168.3.255

Now configure your DHCP settings accordingly. Here is what I did:

Uncomment: server-identifier "hostname";

subnet 192.168.3.0 netmask 255.255.255.0 {
range 192.168.3.2 192.168.3.254;
option domain-name-servers 192.168.3.1;
option domain-name "hostname";
option routers 192.168.3.1;
option broadcast-address 192.168.3.255;
default-lease-time 600;
max-lease-time 7200;
}


Now you should be able to pick up addresses from your server; however, clients connected will not have internet access. This is because NAT is not enabled. Linux or in this case Ubuntu calls this masquerading.

Two lines of code does this for us, however, it must be run in a script every time the server starts up.

echo 1 > /proc/sys/net/ipv4/ip_forward

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Run the two above lines for testing. Remember to prefix with sudo to run as root if you aren't logged in as root.

If all is well, add the lines to /etc/rc.local and then add the file to start at boot by running:

chmod +x /etc/rc.local

Test by restarting and release renewing a client and checking for internet access.

Worked for me so I hope this works for you.

Let me know how it goes or if you have more questions.

-Nausser


All times are GMT -5. The time now is 11:53 PM.