TritonDataCenter / smartos-live

For more information, please see http://smartos.org/ For any questions that aren't answered there, please join the SmartOS discussion list: https://smartos.topicbox.com/groups/smartos-discuss
1.57k stars 246 forks source link

router zone without default route (DHCP) #315

Open jeffpc opened 10 years ago

jeffpc commented 10 years ago

I use SmartOS (joyent_20131003T221245Z) as a router at home. Specifically, I have a router zone which gets has two nics:

Whenever the router zone boots (regardless of it is a system boot or just I restart the router zone), it gets IP, etc. from the ISP, however the default route is not set.

[root@router ~]# ipadm show-addr
ADDROBJ           TYPE     STATE        ADDR
lo0/v4            static   ok           127.0.0.1/8
net0/?            dhcp     ok           98.209.XXX.YYY/22
net1/_a           static   ok           172.27.0.1/24
lo0/v6            static   ok           ::1/128
[root@router ~]# netstat -nr

Routing Table: IPv4
  Destination           Gateway           Flags  Ref     Use     Interface
-------------------- -------------------- ----- ----- ---------- ---------
98.209.XXX.0         98.209.XXX.YYY       U         3          0 net0
127.0.0.1            127.0.0.1            UH        2          0 lo0
172.27.0.0           172.27.0.1           U         9       6982 net1

Routing Table: IPv6
  Destination/Mask            Gateway                   Flags Ref   Use    If
--------------------------- --------------------------- ----- --- ------- -----
::1                         ::1                         UH      2       0 lo0

Adding the default route manually "fixes" the problem...until next reboot.

[root@router ~]# route add -net default 98.209.XXX.1
[root@router ~]# ping google.com
google.com is alive

The config for the zone:

{
  "zonename": "6b2aa4ad-f4c4-4813-b4e4-a87c6f61b40d",
  "zonepath": "/zones/6b2aa4ad-f4c4-4813-b4e4-a87c6f61b40d",
  "autoboot": true,
  "brand": "joyent",
  "limit_priv": "default",
  "create_timestamp": "2012-11-17T23:47:08.780Z",
  "image_uuid": "60a3b1fa-0674-11e2-abf5-cb82934a8e24",
  "cpu_shares": 100,
  "zfs_io_priority": 100,
  "max_lwps": 2000,
  "max_physical_memory": 256,
  "max_locked_memory": 256,
  "max_swap": 256,
  "billing_id": "00000000-0000-0000-0000-000000000000",
  "owner_uuid": "00000000-0000-0000-0000-000000000000",
  "tmpfs": 256,
  "hostname": "router",
  "dns_domain": "local",
  "alias": "router",
  "v": 1,
  "resolvers": [
    "8.8.8.8"
  ],
  "nics": [
    {
      "interface": "net0",
      "mac": "72:0e:d5:2e:df:d3",
      "nic_tag": "external",
      "primary": true,
      "ip": "dhcp",
      "allow_ip_spoofing": "1"
    },
    {
      "interface": "net1",
      "mac": "52:f7:60:09:6c:16",
      "nic_tag": "admin",
      "ip": "172.27.0.1",
      "netmask": "255.255.255.0",
      "allow_ip_spoofing": "1"
    }
  ],
  "uuid": "6b2aa4ad-f4c4-4813-b4e4-a87c6f61b40d",
  "zone_state": "running",
  "zoneid": 15,
  "last_modified": "2014-03-21T16:01:50.000Z",
  "server_uuid": "00010203-0405-0607-0809-0a0b0c0d0e0f",
  "state": "running",
  "customer_metadata": {},
  "internal_metadata": {},
  "tags": {},
  "routes": {},
  "quota": 10,
  "zfs_root_recsize": 131072,
  "zfs_filesystem": "zones/6b2aa4ad-f4c4-4813-b4e4-a87c6f61b40d",
  "zpool": "zones",
  "snapshots": []
}
elijah commented 10 years ago

Your net0 doesn't have a defaultgateway attribute assigned - IIRC it should. Figuring out 'why not' will probably be what should explain the lack of route.

--e

On Fri, Mar 21, 2014 at 11:48 AM, jeffpc notifications@github.com wrote:

I use SmartOS (joyent_20131003T221245Z) as a router at home. Specifically, I have a router zone which gets has two nics:

  • net0 (external): the uplink to the cable modem. It gets IP config via DHCP.
  • net1 (admin): the home network. The IP config is assigned statically via vmadm.

Whenever the router zone boots (regardless of it is a system boot or just I restart the router zone), it gets IP, etc. from the ISP, however the default route is not set.

[root@router ~]# ipadm show-addr ADDROBJ TYPE STATE ADDR lo0/v4 static ok 127.0.0.1/8 net0/ http://127.0.0.1/8net0/? dhcp ok 98.209.XXX.YYY/22 net1/_a static ok 172.27.0.1/24 lo0/v6 http://172.27.0.1/24lo0/v6 static ok ::1/128 [root@router ~]# netstat -nr

Routing Table: IPv4 Destination Gateway Flags Ref Use Interface


98.209.XXX.0 98.209.XXX.YYY U 3 0 net0 127.0.0.1 127.0.0.1 UH 2 0 lo0 172.27.0.0 172.27.0.1 U 9 6982 net1

Routing Table: IPv6 Destination/Mask Gateway Flags Ref Use If


::1 ::1 UH 2 0 lo0

Adding the default route manually "fixes" the problem...until next reboot.

[root@router ~]# route add -net default 98.209.XXX.1 [root@router ~]# ping google.comgoogle.com is alive

The config for the zone:

{ "zonename": "6b2aa4ad-f4c4-4813-b4e4-a87c6f61b40d", "zonepath": "/zones/6b2aa4ad-f4c4-4813-b4e4-a87c6f61b40d", "autoboot": true, "brand": "joyent", "limit_priv": "default", "create_timestamp": "2012-11-17T23:47:08.780Z", "image_uuid": "60a3b1fa-0674-11e2-abf5-cb82934a8e24", "cpu_shares": 100, "zfs_io_priority": 100, "max_lwps": 2000, "max_physical_memory": 256, "max_locked_memory": 256, "max_swap": 256, "billing_id": "00000000-0000-0000-0000-000000000000", "owner_uuid": "00000000-0000-0000-0000-000000000000", "tmpfs": 256, "hostname": "router", "dns_domain": "local", "alias": "router", "v": 1, "resolvers": [ "8.8.8.8" ], "nics": [ { "interface": "net0", "mac": "72:0e:d5:2e:df:d3", "nic_tag": "external", "primary": true, "ip": "dhcp", "allow_ip_spoofing": "1" }, { "interface": "net1", "mac": "52:f7:60:09:6c:16", "nic_tag": "admin", "ip": "172.27.0.1", "netmask": "255.255.255.0", "allow_ip_spoofing": "1" } ], "uuid": "6b2aa4ad-f4c4-4813-b4e4-a87c6f61b40d", "zone_state": "running", "zoneid": 15, "last_modified": "2014-03-21T16:01:50.000Z", "server_uuid": "00010203-0405-0607-0809-0a0b0c0d0e0f", "state": "running", "customer_metadata": {}, "internal_metadata": {}, "tags": {}, "routes": {}, "quota": 10, "zfs_root_recsize": 131072, "zfs_filesystem": "zones/6b2aa4ad-f4c4-4813-b4e4-a87c6f61b40d", "zpool": "zones", "snapshots": [] }

Reply to this email directly or view it on GitHubhttps://github.com/joyent/smartos-live/issues/315 .

naisanza commented 9 years ago

Shouldn't vmadm find the gateway from the nic_tag? Or I wonder if it will work if you set "gateway" to "dhcp"?