network cards configuration

Don´t be shy, Linux is fun! =)
Post Reply
User avatar
l0ngb1t
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 598
Joined: 15 Apr 2009, 16:00
15
Contact:

network cards configuration

Post by l0ngb1t »

i have a linux pc with 2 network cards
i wan't to connect the first network card to the router and the other to the switch
so the traffic pass the server before it enter the network so it can be filtered by the firewall installed on linux

so how do i do such configuration ?
what are the commands ?
There is an UNEQUAL amount of good and bad in most things, the trick is to work out the ratio and act accordingly. "The Jester"

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11636
Joined: 06 Apr 2005, 16:00
19
Location: In your eye floaters.
Contact:

Re: network cards configuration

Post by bad_brain »

it's pretty straight forward, the file to edit is /etc/network/interfaces (at least in Debian / Ubuntu, if you use a different distro let us me know).

here's an example entry for a network interface with a static IP:

Code: Select all

#automatically enable the interface when booting
auto eth0
#interface name, TCP/IP interface, static IP
#notice that the first NIC is eth0, 2nd eth1, etc.
iface eth0 inet static
#IP of the interface
        address 192.168.0.5
#netmask, should be self-explanatory
        netmask 255.255.255.0
#broadcast address, make sure it fits to the netmask
        broadcast 192.168.0.255
 #gateway, like the router for internet access for example
        gateway 192.168.0.1
and now the same for a NIC (the 2nd one) that gets his address via DHCP:

Code: Select all

auto eth1
iface eth1 inet dhcp
when you have saved the entry restart networking:

Code: Select all

/etc/init.d/networking restart
I experienced on Debian that it sometimes behaves a little bitchy and you have to reboot in case the NIC isn't working properly after that command.

of course you can also use the ifconfig and route commands, but then the settings will not be permanent and are lost after a reboot.

:wink:
Image

User avatar
l0ngb1t
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 598
Joined: 15 Apr 2009, 16:00
15
Contact:

Re: network cards configuration

Post by l0ngb1t »

i am using RedHat
by just configuring the ip for each network card will be enough to forward the traffic for one to another ?
There is an UNEQUAL amount of good and bad in most things, the trick is to work out the ratio and act accordingly. "The Jester"

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11636
Joined: 06 Apr 2005, 16:00
19
Location: In your eye floaters.
Contact:

Re: network cards configuration

Post by bad_brain »

ok, in RedHat the paths and the syntax is a little different, have a look here:
http://www.cyberciti.biz/faq/redhat-net ... iguration/" onclick="window.open(this.href);return false;

and no, you will have to set up iptables rules to forward and filter traffic. you can do this with a few basic rules which of course don't really make much use of the firewall abilities, so it makes the most sense to set it up as stateful inspection firewall which is a little more complicated. of course you also have to set up the box as gateway.

sadly it's too much to post as step by step guide, but those links will help you to start:
http://www.yolinux.com/TUTORIALS/LinuxT ... teway.html" onclick="window.open(this.href);return false;
https://wiki.archlinux.org/index.php/Si ... l_firewall" onclick="window.open(this.href);return false;

:wink:
Image

Post Reply