How to set default gateway?

We are evaluating RancherOS as a host OS for our transition to containers. We’re running on KVM using an ISO install. The server has a single network interface (eth0) on a private LAN. We’re able to ssh into the server from another server on the private network. We now need to install dependencies which require access to the public internet.

For all our other servers, which are using CentOS 7, we have a gateway setup thru a single server which has access to the public internet. We want to do the same for the RancherOS server but I’m having trouble with getting the gateway to operate. This is probably due to unfamiliarity with cloud-config and RancherOS in general. So far I’ve tried the following:

1) ros config set rancher.network.interfaces.eth0.gateway 10.14.194.15
2) ros config set rancher.network.interfaces.eth*.gateway 10.14.194.15
3) route add default gw 10.14.194.15

10.14.194.15 is the internal IP for the gateway, which is also the machine we’re using to SSH into the RancherOS machine. Neither #1 or #2 work, as determined by issuing “ping google.com”. Furthermore, after rebooting, we are no longer able to SSH into the machine. The ping only succeeds with #3, however it doesn’t persist after reboot.

Any suggestions are appreciated.

I used the cloud-config to set a static IP when installing my servers, can’t remeber on the top of my head exactly what I wrote. I do know I followed the documentation and it worked. If I do ros config get rancher.network.interfaces.eth0.gateway it gives me the IP of the gateway server so your number 1 should work.

So maybe not something rancher specific but rather general networking, for example: are you sure the rancher server is on the same 10.14… network, is the netmask set correctly, do you have nameservers working et c.

Thanks for the response. I know that the gateway was on the same network, since I was able to SSH into the RancherOS server from the gateway server.

After two days of experimentation I found a cloud config which worked. Here it is:

rancher:
  network:
    post_cmds:
    - ip route add default via 10.14.194.15

my cloud-init for my http proxy airgap demo looks like

#cloud-init
rancher:
  services_include:
    pihole: true
    http-proxy: true
    registry-mirror: true
  password: rancher
  environment:
    # for pihole
    ServerIP: 10.11.11.1
    WEBPASSWORD: rancher
  network:
    interfaces:
      # the airgapped private network
      eth1:
        addresses:
        - 10.11.11.1/24
        gateway: 10.11.11.1
    dns:
      nameservers:
      - 11.11.11.1
  repositories:
    roast:
      url: https://roastlink.github.io/
  # note: these are sven's home registies
  docker:
    registry_mirror: "http://10.10.10.23:5555"
    insecure_registry:
    - 10.10.10.23:5000
    - arian:5000
  system_docker:
    registry_mirror: "http://10.10.10.23:5555"
    insecure_registry:
    - 10.10.10.23:5000
    - arian:5000
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaC1yc2
1 Like