General discussion

Locked

how to setting up multihome in linux

By riyadi71 ·
i have a computer with 2 ehternet card, and i want this computer act as routers, one ethernet card connect to my private organization and others to connect to public address. any body can tell me steps to make it multihome in linux ??
thank you before.

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by cpfeiffe In reply to how to setting up multiho ...

I thought linux did this by default (I mostly work with AIX, HP-UX and Solaris, which don't do it by default). At any rate, all you need to do is enable IP forwarding (that's the thing I thought linux did by default). To be sure you can edit /etc/sysctl.conf and put a line in there that says net.ipv4.ip_forward = 1. If you are using ipv6 you would have to put one in there for that as well. Then its just a matter of setting up your routes so the traffic goes out the right interface. You can create a simple start script (say /etc/rc2.d/S80routes) and use the route command to add the routes you need. With two interfaces it is easy. You can set the next hop from one of your interfaces as the default route and then only need to add specific routes for traffic that should go to the next hop of the other interface. Once you have thse two things done reboot and you should be set. Good luck.

Collapse -

by cpfeiffe In reply to how to setting up multiho ...

I thought linux did this by default (I mostly work with AIX, HP-UX and Solaris, which don't do it by default). At any rate, all you need to do is enable IP forwarding (that's the thing I thought linux did by default). To be sure you can edit /etc/sysctl.conf and put a line in there that says net.ipv4.ip_forward = 1. If you are using ipv6 you would have to put one in there for that as well. Then its just a matter of setting up your routes so the traffic goes out the right interface. You can create a simple start script (say /etc/rc2.d/S80routes) and use the route command to add the routes you need. With two interfaces it is easy. You can set the next hop from one of your interfaces as the default route and then only need to add specific routes for traffic that should go to the next hop of the other interface. Once you have thse two things done reboot and you should be set. Good luck.

Collapse -

by marsh In reply to how to setting up multiho ...

the best way to nat between ethernet card is to add the following lines to the file /etc/rc.local

echo 1 > /proc/sys/net/ipv4/ip_forward # Enables packet forwarding
echo 1 > /proc/sys/net/ipv4/tcp_syncookies # DOS flooding
echo 1 > /proc/sys/net/ipv4/conf/all/rp_filter # source address verification (spoofing)
echo 1 > /proc/sys/net/ipv4/conf/eth0/rp_filter # source address verification (spoofing)
echo 1 > /proc/sys/net/ipv4/conf/eth1/rp_filter # source address verification (spoofing)

# Delete and flush. Default table is "filter". Others like "nat" must be explicitly stated.
iptables --flush # Flush all the rules in filter and nat tables
iptables --table nat --flush
iptables --table mangle --flush
iptables --delete-chain # Delete all chains that are not in default filter and nat table
iptables --table nat --delete-chain
iptables --table mangle --delete-chain

# Set up IP FORWARDing and Masquerading
iptables --append FORWARD --in-interface eth0 --out-interface eth1 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables --append FORWARD --in-interface eth1 --out-interface eth0 -j ACCEPT
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE


in the example, eth0 attaches to the isp and eth1 attaches to a vpn.

eth0 and eth1 must still be configured for an appropriate ip number. this does not provide dhcp server, but does support static ips.

Back to Linux Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums