Interface as a default gateway
Karl Auer
kauer at biplane.com.au
Sat Mar 14 22:41:28 UTC 2015
On Sat, Mar 14, 2015 at 10:01 AM, Amer <amer7777 at hotmail.com> wrote:
> in interface configuration after the gateway statement I should put
> the IP address of the gateway, I want to put the interface name,
> like eth0, instead.
On Sat, 2015-03-14 at 11:06 -0400, Tom H wrote:
> 1) It would have to be "ip r add 0.0.0.0/0 via ip_add_of_eth0 dev eth0".
The address may not be needed. That is "ip r add 0.0.0.0/0 dev eth0" may
also work. I'm not sure with a virtual network.
> 2) IIRC you've used VB's bridged network mode. Again IIRC because I haven't
> used VB in a while, that means that if your host has, eg, a 192.168.1.x
> address, your VM'll have a 192.168.1.y address. So the gateway has to be
> the same as the host's and not the host's ip address.
With bridged interfaces, there is no requirement for the VM interfaces
to have addresses in the same networks as the host interfaces do. It's
OK to have (say) 192.168.100.00/24 on the VM interfaces and (say)
192.168.200.0/24 on the host interfaces. Or even have NO addresses on
the host interfaces. However, if you actually want to *reach* the VM
interfaces, obviously they have to have addresses in reachable networks.
The gateway address for the VMs can be any address at all, as long as
that address is a) reachable from the VMs and b) on a device that is
able and willing to route packets from the VMs to wherever they need to
go. This would normally be the local router, but depending on where the
VMs are hosted it could be one of the hosts or even one of the VMs. All
you need to do to make a router out of pretty much any Linux box is to
turn on packet forwarding with sysctl.[1]
Regards, K.
[1] There's more to it than that in the real world - packet filtering,
firewalling, NAT, routing protocols and so on. But the fundamental
requirement of forwarding packets between two connected networks is
achieved just by turning on packet forwarding:
sudo sysctl -w net/ipv[4|6]/conf/[all|iface_name]/forwarding=1
E.g.:
sudo sysctl -w net/ipv4/conf/all/forwarding=1
Add a suitable line to /etc/sysctl.conf (or even better, put a suitable
snippet in /etc/sysctl.d) to have the change survive a reboot.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Karl Auer (kauer at biplane.com.au)
http://www.biplane.com.au/kauer
http://twitter.com/kauer389
GPG fingerprint: 3C41 82BE A9E7 99A1 B931 5AE7 7638 0147 2C3C 2AC4
Old fingerprint: EC67 61E2 C2F6 EB55 884B E129 072B 0AF0 72AA 9882
More information about the ubuntu-users
mailing list