Based on this question can the following be done:
- Router with DHCP connected to NIC A on Box 1 - Machine B connected to NIC B on Box 1
I need Machine B to get a DHCP IP address from the Router on NIC A. Currently the setup and configuration is as follows:
- NIC A DHCP Assigned IP: 10.0.x.x (255.255.255.224) - NIC B Static IP: 10.1.x.x (255.255.255.252)
I have ipv4_forwarding on however I can't assign a static IP to the Machine B. What do I need to do to get all traffic from NIC A to flow through NIC B. Or more specifically how can I get Machine B to get an IP address from the DHCP on the router.
- Do I need to setup IPTables? If so where do I start?
- Do I need to setup a route on the linux box? How?
- It can't be done?
To Clarify
This box is NOT the router. There is already a router in place. This is a linux box used for Samba Shares and Virtual Machines. There is however some machines that can't be connect to the main switch, however they can be connected through another hub to this machine.
In Short This machine is sitting in the middle.
You've got three hosts:
Unless
Machine "R"
(your router) knows that10.1.0.0/16
routes through10.0.0.2
it simply will not work.You have three choices:
To create a bridge, is really straightforward. On Machine "A":
Then configure
br0
to have the IP address that you want to have (say by runningdhclient br0
).Then, Machine "B" should be able to use
dhclient eth0
and get an IP address from Machine "R"Bridges come with a whole bunch of problems, not the least of which being the fact that a lot of devices have buggy STP support.
If you get Machine "R" to create your routing table, you'll need Machine "A" to enable proxy arp:
Other machines on your network will need to accept ICMP redirects. I've seen at least two printers that don't by default. Your mileage may vary.
Finally, enabling Network Address Translation is really a simple matter of:
where
$IP
is the address given byMachine "R"
for use. There are a number of tools that automate this.You should bridge the two network interfaces; this way, the middle computr will act just like a network hub, passing traffic between the two ports in a completely transparent way. No routing, no configurations to do, the other computer and the router will "just" be able to talk to each other (and to the bridging computer, of course).
Why do not bind dhcp server on both interfaces instead ?
by default dhcpd should already listen on every interface (if no parameter is given to the daemon)... so I guess you have only to change your dhcpd.conf in order to manage the netmask on eth1 too ... and the daemon will serve on this interface too.
EDIT after Diago reply Sorry I have misunderstood your question. I don't delete the answer for others reference if useful.
You need to configure DHCP Relay Agent in your linux box. The DHCP Relay Agent allows you to relay DHCP request from one subnet to other DHCP servers in different subnets. The linux command to do DHCP relay is dhcrelay
Also you need to check if you can reach the DHCP server from Machine B (check my answer to your other question to configure routes and default gateway) and that no firewall rules in your server are blocking packets from Machine B to the DHCP server.
If you followed the directions on the question you linked to then the box is a router. The ip_forward = 1 setting enables routing. If that is not what you want, then you'll need to set it up as a bridge.
By having the box setup as a router you are making things more complex then it sounds like you want/need. Configuring the system with two interfaces as a bridge is probably the easiest option. If you need the box to actually be a router then you'll have to consider the other options.
You could setup a dhcp relay agent on the computer, but you will also need to add a route to your router so it can access the inside address space, and you will need to add an additional scope to the router for the internal address space.
You could simply setup a DHCP server on the box with two interfaces and serve the addresses to your inside network. This may be the simplest thing to setup if simply making box with two interfaces a bridge isn't an option.
Box 1 needs to be set up as a dhcp relay agent.