How can I set my route address?

Discussions related to using VirtualBox on Linux hosts.
Post Reply
hack3rcon
Posts: 204
Joined: 28. Feb 2016, 10:44

How can I set my route address?

Post by hack3rcon »

Hello,
I have two VMs, one is a Debian VM and another is Windows OS. My Debian VM have two NICs as below:

Code: Select all

# ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.2.15  netmask 255.255.255.0  broadcast 10.0.2.255
        inet6 fe80::a00:27ff:fe79:3b43  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:79:3b:43  txqueuelen 1000  (Ethernet)
        RX packets 783  bytes 60408 (58.9 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 514  bytes 62950 (61.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.2  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::a00:27ff:fee6:c57c  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:e6:c5:7c  txqueuelen 1000  (Ethernet)
        RX packets 136  bytes 14117 (13.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 777  bytes 49490 (48.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 696  bytes 66020 (64.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 696  bytes 66020 (64.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
One is "NAT" and another is "Internal network". The Debian VM connected to the internet via NAT and another NIC using by DHCP service for give IP to the Windows OS VM. How can I set my "default gateway" so that Windows VM can use my Debian VM for access to the internet?

Thank you.
hack3rcon
Posts: 204
Joined: 28. Feb 2016, 10:44

Re: How can I set my route address?

Post by hack3rcon »

More information:
The "enp0s8" use static IP as below:

Code: Select all

auto enp0s8
iface enp0s8 inet static
    address 192.168.0.2
    netmask 255.255.255.0
    broadcast 192.168.0.255
My Debian have a DHCP service that give IP to Windows OS. My DHCP config is:

Code: Select all

# cat /etc/dhcp/dhcpd.conf
default-lease-time 600;
max-lease-time 7200;

allow booting;

# in this example, we serve DHCP requests from 192.168.0.(3 to 253)
# and we have a router at 192.168.0.1
subnet 192.168.0.0 netmask 255.255.255.0 {
  range 192.168.0.3 192.168.0.253;
  option broadcast-address 192.168.0.255;
  option routers 192.168.0.1;             # our router
  option domain-name-servers 192.168.0.1; # our router, again
  filename "pxelinux.0"; # (this we will provide later)
  INTERFACES="enp0s8";
}
And:

Code: Select all

# ip route
default via 10.0.2.2 dev enp0s3 proto static metric 100 
10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15 metric 100 
192.168.0.0/24 dev enp0s8 proto kernel scope link src 192.168.0.2 
Windows OS give IP from Debian. How can I write a route that Windows OS can connect to the internet via Debian?

Thank you.
Post Reply