Alright heres what I needed to do.
I have a gentoo vm on my mac.
The Gentoo vm has two interfaces, eth0 which is bridged and eth1 which is shared with my mac.
Upon boot, both interfaces become “UG” status (in a netstat -rn) meaning they are both default gateways. This works while I’m at work since I’m on the comapny lan anyway so either way, stuff is going the right way.
However, when going home, eth0 is going to get a local IP and so is my mac. But, when I start my vpn connection on my mac, as long as I port all my traffic through eth1 (on my gentoo vm), my vm can use the vpn just fine. This means, I need to entirely bypass eth0 for both DNS and obviously as a gateway.
There are basically two ways to do this:
- Just disable the interface (easier)
- Modify a few files to manually specify the dns server and ensure the route is removed from the routing table also through editing files (harder)
I choose the harder way.
Step 1: DNS
To do this, your will need to edit /etc/conf.d/net with something like:
I also ensured that I had no DHCP setup for any of my interfaces in that file. Either way, dns still works on those interfaces anyway for whatever reason…gentoo, i dont get you.
Now you also need to edit /etc/dhcpd.conf and remove “domain_name_servers” from:
option domain_name_servers, domain_name, domain_search, host_name
Now hopefully your dns will hold. For some reason, this took me a few reboots to actually hold. Not sure what was going on there. Obviously, to check that things are working, “cat /etc/resolv.conf” and make sure your dns server is in there (on top).
Step 2: Remove eth0 as a default gw
Yeah so..normally, you would probably do something like:
routes_eth1=“default via 172.16.16.2” routes_eth0=“”
in your /etc/conf.d/net file. That doesn’t work for me. So. guess what!? Time to add something to run at boot that runs a:
route del default gw 192.168.1.1
Ohh and incase you didn’t know, gentoo runs anything in “/etc/local.d/*.start” at boot therefore, you would make a script like “startstuffs.start” and put stuff in there.
—- A simpler way?
Yep. Essentially, I’ve realized that I will need eth0 to be the primary interface while at work for certain scripts and such that I’m doing. Yet, I’ll still need eth1 too while at work just not as a default gw. So.
1) When at work, “route del default gw 172.16.16.2?.
2) When at home, “ifconfig eth0 down”.
So I basically need to write a script that can tell when im at home or at work (probably can just look at the IP that I’m leased on eth0, if its 10., I’m at work, if its 192., I’m at home) and run those commands, running at boot of course or on a cron (so I don’t have to reboot the vm when I come to and from work).
AHHHH I’m tired of [email protected]$#^@#$%^$%